launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19500
Re: [Merge] lp:~wgrant/launchpad/bug-1501134 into lp:launchpad
Review: Approve
Diff comments:
>
> === modified file 'lib/lp/code/browser/tests/test_branchmergeproposallisting.py'
> --- lib/lp/code/browser/tests/test_branchmergeproposallisting.py 2015-09-25 14:19:36 +0000
> +++ lib/lp/code/browser/tests/test_branchmergeproposallisting.py 2015-09-30 09:05:40 +0000
> @@ -302,6 +267,313 @@
> self.assertIn(identity, view.contents)
>
>
> +class BranchMergeProposalListingTestMixin:
> +
> + layer = DatabaseFunctionalLayer
> +
> + supports_privacy = True
> + supports_git = True
> + supports_bzr = True
> +
> + bzr_branch = None
> + git_ref = None
> +
> + def makeBzrMergeProposal(self):
> + information_type = (
> + InformationType.USERDATA if self.supports_privacy else None)
> + target = self.bzr_branch
> + if target is None:
> + target = self.factory.makeBranch(
> + target=self.bzr_target, information_type=information_type)
> + source = self.factory.makeBranch(
> + target=self.bzr_target, owner=self.owner,
> + information_type=information_type)
> + return self.factory.makeBranchMergeProposal(
> + source_branch=source, target_branch=target,
> + set_state=BranchMergeProposalStatus.NEEDS_REVIEW)
> +
> + def makeGitMergeProposal(self):
> + information_type = (
> + InformationType.USERDATA if self.supports_privacy else None)
> + target = self.git_ref
> + if target is None:
> + [target] = self.factory.makeGitRefs(
> + target=self.git_target, information_type=information_type)
> + [source] = self.factory.makeGitRefs(
> + target=self.git_target, owner=self.owner,
> + information_type=information_type)
> + return self.factory.makeBranchMergeProposalForGit(
> + source_ref=source, target_ref=target,
> + set_state=BranchMergeProposalStatus.NEEDS_REVIEW)
> +
> + def test_bzr(self):
> + """The merges view should be enabled for the target."""
> + if not self.supports_bzr:
> + self.skipTest("Context doesn't support Bazaar branches.")
> + with admin_logged_in():
> + bmp = self.makeBzrMergeProposal()
> + url = canonical_url(bmp, force_local_path=True)
> + browser = self.getViewBrowser(
> + self.context, self.view_name, rootsite='code', user=self.user)
> + self.assertIn(url, browser.contents)
> +
> + def test_git(self):
> + """The merges view should be enabled for the target."""
> + if not self.supports_git:
> + self.skipTest("Context doesn't support Git repositories.")
> + with admin_logged_in():
> + bmp = self.makeGitMergeProposal()
> + url = canonical_url(bmp, force_local_path=True)
> + browser = self.getViewBrowser(
> + self.context, self.view_name, rootsite='code', user=self.user)
> + self.assertIn(url, browser.contents)
> +
> + def test_query_count_bzr(self):
> + if not self.supports_bzr:
> + self.skipTest("Context doesn't support Bazaar branches.")
> + with admin_logged_in():
> + for i in range(7):
> + self.makeBzrMergeProposal()
> + flush_database_caches()
> + with StormStatementRecorder() as recorder:
> + self.getViewBrowser(
> + self.context, self.view_name, rootsite='code', user=self.user)
> + self.assertThat(recorder, HasQueryCount(LessThan(51)))
> +
> + def test_query_count_git(self):
> + if not self.supports_git:
> + self.skipTest("Context doesn't support Git repositories.")
> + with admin_logged_in():
> + for i in range(7):
> + self.makeGitMergeProposal()
> + flush_database_caches()
> + with StormStatementRecorder() as recorder:
> + self.getViewBrowser(
> + self.context, self.view_name, rootsite='code', user=self.user)
> + self.assertThat(recorder, HasQueryCount(LessThan(47)))
> +
> +
> +class MergesTestMixin(BranchMergeProposalListingTestMixin):
> +
> + view_name = '+merges'
> +
> + def test_none(self):
> + """The merges view should be enabled for the target."""
> + browser = self.getViewBrowser(
> + self.context, self.view_name, rootsite='code', user=self.user)
> + self.assertIn("has no merge proposals", browser.contents)
> +
> +
> +class ActiveReviewsTestMixin(BranchMergeProposalListingTestMixin):
> +
> + view_name = '+activereviews'
> +
> + def test_none(self):
> + """The active reviews view should be enabled for the target."""
> + browser = self.getViewBrowser(
> + self.context, self.view_name, rootsite='code', user=self.user)
> + self.assertIn("has no active code reviews", browser.contents)
> +
> +
> +class ProductContextMixin:
> +
> + def setUp(self):
> + super(ProductContextMixin, self).setUp()
> + self.context = self.factory.makeProduct()
> + self.git_target = self.bzr_target = self.context = (
> + self.factory.makeProduct())
Duplicate assignment to self.context.
> + self.user = self.git_target.owner
> + self.owner = None
> +
> +
> +class ProjectGroupContextMixin:
> +
> + def setUp(self):
> + super(ProjectGroupContextMixin, self).setUp()
> + self.context = self.factory.makeProject()
> + self.git_target = self.bzr_target = self.factory.makeProduct(
> + projectgroup=self.context)
> + self.user = self.git_target.owner
> + self.owner = None
> +
> +
> +class DistributionSourcePackageContextMixin:
> +
> + # Distribution branches don't have access_policy set.
> + supports_privacy = False
> +
> + def setUp(self):
> + super(DistributionSourcePackageContextMixin, self).setUp()
> + self.git_target = self.context = (
> + self.factory.makeDistributionSourcePackage())
> + with admin_logged_in():
> + getUtility(IService, "sharing").sharePillarInformation(
> + self.context.distribution, self.context.distribution.owner,
> + self.context.distribution.owner,
> + {InformationType.USERDATA: SharingPermission.ALL})
> + distroseries = self.factory.makeDistroSeries(
> + distribution=self.context.distribution)
> + self.bzr_target = distroseries.getSourcePackage(
> + self.context.sourcepackagename)
> + self.user = self.context.distribution.owner
> + self.owner = None
> +
> +
> +class SourcePackageContextMixin:
> +
> + # Distribution branches don't have access_policy set.
> + supports_privacy = False
> + supports_git = False
> +
> + def setUp(self):
> + super(SourcePackageContextMixin, self).setUp()
> + self.bzr_target = self.context = self.factory.makeSourcePackage()
> + self.user = self.context.distribution.owner
> + self.owner = None
> +
> +
> +class PersonContextMixin:
> +
> + def setUp(self):
> + super(PersonContextMixin, self).setUp()
> + self.context = self.factory.makePerson()
> + self.bzr_target = self.git_target = self.factory.makeProduct()
> + self.user = self.bzr_target.owner
> + self.owner = self.context
> +
> +
> +class PersonProductContextMixin:
> +
> + def setUp(self):
> + super(PersonProductContextMixin, self).setUp()
> + self.context = PersonProduct(
> + self.factory.makePerson(), self.factory.makeProduct())
> + self.bzr_target = self.git_target = self.context.product
> + self.user = self.context.product.owner
> + self.owner = self.context.person
> +
> +
> +class BranchContextMixin:
> +
> + supports_git = False
> +
> + def setUp(self):
> + super(BranchContextMixin, self).setUp()
> + self.bzr_target = self.factory.makeProduct()
> + self.context = self.bzr_branch = self.factory.makeBranch(
> + target=self.bzr_target)
> + self.user = self.bzr_target.owner
> + self.owner = None
> +
> +
> +class GitRefContextMixin:
> +
> + supports_bzr = False
> +
> + def setUp(self):
> + super(GitRefContextMixin, self).setUp()
> + self.git_target = self.factory.makeProduct()
> + self.context = self.git_ref = self.factory.makeGitRefs(
> + target=self.git_target)[0]
> + self.user = self.git_target.owner
> + self.owner = None
> +
> +
> +class TestProductMerges(
> + ProductContextMixin, MergesTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestProjectGroupMerges(
> + ProjectGroupContextMixin, MergesTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestDistributionSourcePackageMerges(
> + DistributionSourcePackageContextMixin, MergesTestMixin,
> + BrowserTestCase):
> +
> + pass
> +
> +
> +class TestSourcePackageMerges(
> + SourcePackageContextMixin, MergesTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestPersonMerges(PersonContextMixin, MergesTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestPersonProductMerges(
> + PersonProductContextMixin, MergesTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestBranchMerges(BranchContextMixin, MergesTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestGitRefMerges(GitRefContextMixin, MergesTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestProductActiveReviews(
> + ProductContextMixin, ActiveReviewsTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestProjectGroupActiveReviews(
> + ProjectGroupContextMixin, ActiveReviewsTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestDistributionSourcePackageActiveReviews(
> + DistributionSourcePackageContextMixin, ActiveReviewsTestMixin,
> + BrowserTestCase):
> +
> + pass
> +
> +
> +class TestSourcePackageActiveReviews(
> + SourcePackageContextMixin, ActiveReviewsTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestPersonActiveReviews(
> + PersonContextMixin, ActiveReviewsTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestPersonProductActiveReviews(
> + PersonProductContextMixin, ActiveReviewsTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestBranchActiveReviews(
> + BranchContextMixin, ActiveReviewsTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> +class TestGitRefActiveReviews(
> + GitRefContextMixin, ActiveReviewsTestMixin, BrowserTestCase):
> +
> + pass
> +
> +
> class ActiveReviewGroupsTestMixin:
> """Tests for groupings used for active reviews."""
>
--
https://code.launchpad.net/~wgrant/launchpad/bug-1501134/+merge/272880
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
References