~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/tests/test_revision.py

  • Committer: Jelmer Vernooij
  • Date: 2011-10-12 01:00:11 UTC
  • mfrom: (14133 devel)
  • mto: This revision was merged to the branch mainline in revision 14141.
  • Revision ID: jelmer@canonical.com-20111012010011-1hqgg5b30ciywbsa
MergeĀ lp:launchpad.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Tests for Revisions."""
25
25
    )
26
26
from canonical.launchpad.interfaces.account import AccountStatus
27
27
from canonical.launchpad.interfaces.lpstorm import IMasterObject
28
 
from lp.scripts.garbo import RevisionAuthorEmailLinker
29
28
from canonical.launchpad.webapp.interfaces import (
30
29
    DEFAULT_FLAVOR,
31
30
    IStoreSelector,
40
39
    RevisionSet,
41
40
    )
42
41
from lp.registry.model.karma import Karma
 
42
from lp.scripts.garbo import RevisionAuthorEmailLinker
43
43
from lp.services.log.logger import DevNullLogger
44
44
from lp.testing import (
45
45
    TestCaseWithFactory,
309
309
    def testAllowPrivateReturnsPrivateBranch(self):
310
310
        # If the allow_private flag is set, then private branches can be
311
311
        # returned if they are the best match.
312
 
        b1 = self.makeBranchWithRevision(1)
 
312
        self.makeBranchWithRevision(1)
313
313
        b2 = self.makeBranchWithRevision(1, owner=self.author)
314
314
        removeSecurityProxy(b2).explicitly_private = True
315
315
        self.assertEqual(b2, self.revision.getBranch(allow_private=True))
503
503
        # The revision must be in a branch for the product.
504
504
        # returned.
505
505
        rev1 = self._makeRevisionInBranch(product=self.product)
506
 
        rev2 = self._makeRevisionInBranch()
 
506
        self._makeRevisionInBranch()
507
507
        self.assertEqual([rev1], self._getRevisions())
508
508
 
509
509
 
526
526
        # The revision must be in a branch for the product.
527
527
        # returned.
528
528
        rev1 = self._makeRevisionInBranch(product=self.product)
529
 
        rev2 = self._makeRevisionInBranch()
 
529
        self._makeRevisionInBranch()
530
530
        self.assertEqual([rev1], self._getRevisions())
531
531
 
532
532
    def testProjectRevisions(self):
534
534
        another_product = self.factory.makeProduct(project=self.project)
535
535
        rev1 = self._makeRevisionInBranch(product=self.product)
536
536
        rev2 = self._makeRevisionInBranch(product=another_product)
537
 
        rev3 = self._makeRevisionInBranch()
 
537
        self._makeRevisionInBranch()
538
538
        self.assertEqual([rev2, rev1], self._getRevisions())
539
539
 
540
540
 
553
553
    def testRevisionAuthorMatchesRevision(self):
554
554
        # The revision author returned with the revision is the same as the
555
555
        # author for the revision.
556
 
        rev1 = self._makeRevisionInBranch(product=self.product)
 
556
        self._makeRevisionInBranch(product=self.product)
557
557
        results = self._getRecentRevisions()
558
 
        self.assertEqual(1, len(results))
559
 
        revision, revision_author = results[0]
 
558
        [(revision, revision_author)] = results
560
559
        self.assertEqual(revision.revision_author, revision_author)
561
560
 
562
561
    def testRevisionsMustBeInABranchOfProduct(self):
563
562
        # The revisions returned revision must be in a branch for the product.
564
563
        rev1 = self._makeRevisionInBranch(product=self.product)
565
 
        rev2 = self._makeRevisionInBranch()
566
 
        self.assertEqual([(rev1, rev1.revision_author)],
567
 
                         self._getRecentRevisions())
 
564
        self._makeRevisionInBranch()
 
565
        self.assertEqual(
 
566
            [(rev1, rev1.revision_author)], self._getRecentRevisions())
568
567
 
569
568
    def testRevisionsMustBeInActiveBranches(self):
570
569
        # The revisions returned revision must be in a branch for the product.
636
635
        self._breakTransaction()
637
636
        self.assertEqual(1, len(revisions))
638
637
        revision = revisions[0]
639
 
        self.assertEqual(self.branches[0].last_scanned_id,
640
 
                         revision.revision_id)
 
638
        self.assertEqual(last_scanned_id, revision.revision_id)
641
639
        # By accessing to the revision_author we can confirm that the
642
640
        # revision author has in fact been retrieved already.
643
641
        revision_author = revision.revision_author