Merge lp:~cjwatson/launchpad/testfix-import-warnings into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17754
Proposed branch: lp:~cjwatson/launchpad/testfix-import-warnings
Merge into: lp:launchpad
Diff against target: 43 lines (+5/-3)
2 files modified
lib/lp/soyuz/browser/archivesubscription.py (+2/-2)
lib/lp/soyuz/tests/test_archive_subscriptions.py (+3/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/testfix-import-warnings
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+272228@code.launchpad.net

Commit message

Listify result of getBySubscriberWithActiveToken to avoid doing the eager load twice.

Description of the change

Listify result of getBySubscriberWithActiveToken to avoid doing the eager load twice.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/browser/archivesubscription.py'
--- lib/lp/soyuz/browser/archivesubscription.py 2015-09-23 15:43:43 +0000
+++ lib/lp/soyuz/browser/archivesubscription.py 2015-09-24 11:39:50 +0000
@@ -320,8 +320,8 @@
320 cleaner.320 cleaner.
321 """321 """
322 subscriber_set = getUtility(IArchiveSubscriberSet)322 subscriber_set = getUtility(IArchiveSubscriberSet)
323 subs_with_tokens = subscriber_set.getBySubscriberWithActiveToken(323 subs_with_tokens = list(
324 self.context)324 subscriber_set.getBySubscriberWithActiveToken(self.context))
325325
326 # ArchiveSubscriber.archive is preloaded.326 # ArchiveSubscriber.archive is preloaded.
327 archives = [subscriber.archive for subscriber, _ in subs_with_tokens]327 archives = [subscriber.archive for subscriber, _ in subs_with_tokens]
328328
=== modified file 'lib/lp/soyuz/tests/test_archive_subscriptions.py'
--- lib/lp/soyuz/tests/test_archive_subscriptions.py 2015-01-07 11:26:05 +0000
+++ lib/lp/soyuz/tests/test_archive_subscriptions.py 2015-09-24 11:39:50 +0000
@@ -3,6 +3,7 @@
33
4"""Test Archive features."""4"""Test Archive features."""
55
6from fixtures import FakeLogger
6from storm.store import Store7from storm.store import Store
7from testtools.matchers import Equals8from testtools.matchers import Equals
8from zope.security.interfaces import Unauthorized9from zope.security.interfaces import Unauthorized
@@ -161,6 +162,7 @@
161 self.assertIsNotNone(find_tag_by_id(content, 'ppa-install'))162 self.assertIsNotNone(find_tag_by_id(content, 'ppa-install'))
162163
163 def test_unauthorized_subscriber_for_plus_packages(self):164 def test_unauthorized_subscriber_for_plus_packages(self):
165 self.useFixture(FakeLogger())
164 with person_logged_in(self.owner):166 with person_logged_in(self.owner):
165 self.archive.newSubscription(167 self.archive.newSubscription(
166 self.subscriber, registrant=self.archive.owner)168 self.subscriber, registrant=self.archive.owner)
@@ -191,7 +193,7 @@
191 view = create_initialized_view(193 view = create_initialized_view(
192 subscriber, '+archivesubscriptions', principal=subscriber)194 subscriber, '+archivesubscriptions', principal=subscriber)
193 view.render()195 view.render()
194 self.assertThat(recorder, HasQueryCount(Equals(13)))196 self.assertThat(recorder, HasQueryCount(Equals(12)))
195197
196 def test_getArchiveSubscriptions(self):198 def test_getArchiveSubscriptions(self):
197 # Anyone with 'View' permission on a given person is able to199 # Anyone with 'View' permission on a given person is able to