Merge lp:~lifeless/launchpad/registry into lp:launchpad
Proposed by
Robert Collins
on 2010-08-05
| Status: | Merged | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Approved by: | Jelmer Vernooij on 2010-08-05 | ||||||||||||||||
| Approved revision: | no longer in the source branch. | ||||||||||||||||
| Merged at revision: | 11305 | ||||||||||||||||
| Proposed branch: | lp:~lifeless/launchpad/registry | ||||||||||||||||
| Merge into: | lp:launchpad | ||||||||||||||||
| Diff against target: |
140 lines (+87/-3) 3 files modified
lib/lp/testing/matchers.py (+42/-0) lib/lp/testing/tests/test_matchers.py (+43/-2) versions.cfg (+2/-1) |
||||||||||||||||
| To merge this branch: | bzr merge lp:~lifeless/launchpad/registry | ||||||||||||||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Jelmer Vernooij (community) | code | 2010-08-05 | Approve on 2010-08-05 |
|
Review via email:
|
|||
Commit Message
Add a matcher HasQueryCount and a new testtools supporting that.
Description of the Change
Another step along my arc of fixing the /participation API performance. This adds a matcher for query counts and a dependency on a newer testtools to get LessThan.
To post a comment you must log in.
| Robert Collins (lifeless) wrote : | # |
Download full text (12.3 KiB)
| Robert Collins (lifeless) wrote : | # |
Oh, and I am aware of assertStatement
review:
Approve
(code)
| Jelmer Vernooij (jelmer) wrote : | # |
Great to see test matchers in action!

This is what a test using it looks like: ation(TestCaseW ithFactory) : nalLayer ion_query_ limit(self) : makeTeam( ) logged_ in(team. teamowner) : self.factory. makePerson( ), team.teamowner) self.factory. makePerson( ), team.teamowner) viceCaller( ) register( ) (collector. unregister) {'User- Agent': 'AnonNeedsThis' }) l(response. status, 200, (collector, HasQueryCount( LessThan( 24)))
+class TestAPIPartipic
+
+ layer = DatabaseFunctio
+
+ def test_participat
+ # A team with 2 members should only query once for all their
+ # attributes.
+ team = self.factory.
+ with person_
+ team.addMember(
+ team.addMember(
+ webservice = LaunchpadWebSer
+ collector = QueryCollector()
+ collector.
+ self.addCleanup
+ url = "/~%s/participants" % team.name
+ logout()
+ response = webservice.get(url, headers=
+ self.assertEqua
+ "Got %d for url %r with response %r" % (
+ response.status, url, response.body))
+ self.assertThat
and it generates this output: ion_query_ limit| testr load ======= ======= ======= ======= ======= ======= ======= ======= ======= tests.test_ person. TestAPIPartipic ation.test_ participation_ query_limit ------- ------- ------- ------- ------- ------- ------- ------- ------- main-master' , 'SELECT OAuthConsumer. date_created, OAuthConsumer. disabled, OAuthConsumer.id, OAuthConsumer. "key", OAuthConsumer. secret FROM OAuthConsumer WHERE OAuthConsumer."key" IS NULL') main-master' , 'SELECT OAuthConsumer. date_created, OAuthConsumer. disabled, OAuthConsumer.id, OAuthConsumer. "key", OAuthConsumer. secret FROM OAuthConsumer WHERE OAuthConsumer."key" = %s') main-master' , 'SELECT OAuthConsumer. date_created, OAuthConsumer. disabled, OAuthConsumer.id, OAuthConsumer. "key", OAuthConsumer. secret FROM OAuthConsumer WHERE OAuthConsumer."key" = %s') main-master' , 'INSERT INTO OAuthConsumer (date_created, disabled, "key", secret) VALUES (CURRENT_TIMESTAMP AT TIME ZONE \'UTC\', %s, %s, %s) RETURNING OAuthConsumer.id') main-master' , 'SELECT Person.account, Person. addressline1, Person. addressline2, Person.city, Person.country, Person. creation_ comment, Person. creation_ rationale, Person.datecreated, Person. defaultmembersh ipperiod, Person. defaultrenewalp eriod, Person.displayname, Person. hide_email_ addresses, Person. homepage_ content, Person.icon, Person.id, Person.logo, Person. mailing_ list_auto_ subscribe_ policy, Person.merged, Person.mugshot, Person.name, Person. organization, Person. personal_ standing, Person. personal_ standing_ reason, Person.phone, Person.postcode, Person.province, Person.registrant, Person. renewal_ policy, Person. subscriptionpol icy, Person. teamdescription , Person.teamowner, Person. verbose_ bugnotification s, Person.visibility FROM Person WHERE Person.name = %s AND Person.merged IS NULL ORDER BY person_ sort_key( Person. displayname, Person.name)')
running: xvfb-run ./bin/test --subunit -t test_participat
=======
FAIL: lp.registry.
-------
Text attachment: traceback
------------
Traceback (most recent call last):
_StringException: Text attachment: queries
------------
(2, 3, 'launchpad-
(4, 4, 'launchpad-
(5, 5, 'launchpad-
(8, 9, 'launchpad-
(11, 11, 'launchpad-
(12, 13, 'launc...