~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/tests/test_dominator.py

  • Committer: Jeroen Vermeulen
  • Date: 2011-09-26 11:05:27 UTC
  • mto: This revision was merged to the branch mainline in revision 14035.
  • Revision ID: jeroen.vermeulen@canonical.com-20110926110527-sas5k9h3h0aqyn12
As per review: add query-count test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
from operator import attrgetter
10
10
 
11
11
import apt_pkg
 
12
from testtools.matchers import LessThan
12
13
from zope.security.proxy import removeSecurityProxy
13
14
 
14
15
from canonical.database.sqlbase import flush_database_updates
25
26
from lp.soyuz.enums import PackagePublishingStatus
26
27
from lp.soyuz.interfaces.publishing import ISourcePackagePublishingHistory
27
28
from lp.soyuz.tests.test_publishing import TestNativePublishingBase
28
 
from lp.testing import TestCaseWithFactory
 
29
from lp.testing import (
 
30
    StormStatementRecorder,
 
31
    TestCaseWithFactory,
 
32
    )
 
33
from lp.testing.matchers import HasQueryCount
29
34
 
30
35
 
31
36
class TestDominator(TestNativePublishingBase):
493
498
        self.assertEqual(
494
499
            [spr, spr, None], [pub.supersededby for pub in pubs])
495
500
 
 
501
    def test_dominatePackage_is_efficient(self):
 
502
        # dominatePackage avoids issuing too many queries.
 
503
        versions = ["1.%s" % revision for revision in xrange(5)]
 
504
        pubs = make_spphs_for_versions(self.factory, versions)
 
505
        with StormStatementRecorder() as recorder:
 
506
            self.makeDominator(pubs).dominatePackage(
 
507
                pubs, versions[2:-1],
 
508
                GeneralizedPublication(True))
 
509
        self.assertThat(recorder, HasQueryCount(LessThan(5)))
 
510
 
496
511
    def test_dominatePackage_advanced_scenario(self):
497
512
        # Put dominatePackage through its paces with complex combined
498
513
        # data.