Merge lp:~lifeless/launchpad/registry into lp:launchpad
Proposed by
Robert Collins
Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Jelmer Vernooij | ||||||||||||||||
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 | Approve | |
Review via email: mp+31830@code.launchpad.net |
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.
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...