~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/tests/test_pillaraffiliation.py

  • Committer: Curtis Hovey
  • Date: 2011-08-18 20:56:37 UTC
  • mto: This revision was merged to the branch mainline in revision 13736.
  • Revision ID: curtis.hovey@canonical.com-20110818205637-ae0pf9aexdea2mlb
Cleaned up doctrings and hushed lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
246
246
        adapter = IHasAffiliation(branch)
247
247
        self.assertEqual(branch.product, adapter.getPillar())
248
248
 
 
249
    def test_getBranch(self):
 
250
        # The branch is the context.
 
251
        branch = self.factory.makeBranch()
 
252
        adapter = IHasAffiliation(branch)
 
253
        self.assertEqual(branch, adapter.getBranch())
 
254
 
 
255
    def test_branch_trusted_reviewer_affiliation(self):
 
256
        # A person who is the branch's trusted reviewer is affiliated.
 
257
        person = self.factory.makePerson()
 
258
        product = self.factory.makeProduct(name='pting')
 
259
        self._check_affiliated_with_product(
 
260
            person, product, 'trusted reviewer')
 
261
 
249
262
    def _check_affiliated_with_distro(self, person, target, role):
250
263
        distroseries = self.factory.makeDistroSeries(distribution=target)
251
264
        sp = self.factory.makeSourcePackage(distroseries=distroseries)
262
275
        self.assertEqual(
263
276
            ("/@@/product-badge", "Pting %s" % role), badges[0])
264
277
 
265
 
    def test_getBranch(self):
266
 
        # The branch is the context.
267
 
        branch = self.factory.makeBranch()
268
 
        adapter = IHasAffiliation(branch)
269
 
        self.assertEqual(branch, adapter.getBranch())
270
 
 
271
 
    def test_branch_trusted_reviewer_affiliation(self):
272
 
        # A person who is the branch's trusted reviewer is affiliated.
273
 
        person = self.factory.makePerson()
274
 
        product = self.factory.makeProduct(name='pting')
275
 
        self._check_affiliated_with_product(
276
 
            person, product, 'trusted reviewer')
277
 
 
278
 
 
279
 
class TestCodeReviewVotePillarAffiliation(_TestBugTaskorBranchMixin,
280
 
                                  TestCaseWithFactory):
 
278
 
 
279
class CodeReviewVotePillarAffiliationTestCase(TestBranchPillarAffiliation):
281
280
 
282
281
    layer = DatabaseFunctionalLayer
283
282
 
296
295
        adapter = IHasAffiliation(vote)
297
296
        self.assertEqual(branch.product, adapter.getPillar())
298
297
 
 
298
    def test_getBranch(self):
 
299
        # The code review vote's target branch is the branch.
 
300
        branch = self.factory.makeBranch()
 
301
        vote = self.makeCodeReviewVote(branch)
 
302
        adapter = IHasAffiliation(vote)
 
303
        self.assertEqual(branch, adapter.getBranch())
 
304
 
299
305
    def _check_affiliated_with_distro(self, person, target, role):
300
306
        distroseries = self.factory.makeDistroSeries(distribution=target)
301
307
        sp = self.factory.makeSourcePackage(distroseries=distroseries)
307
313
 
308
314
    def _check_affiliated_with_product(self, person, target, role):
309
315
        branch = self.factory.makeBranch(product=target)
310
 
        vote = self.makeCodeReviewVote(branch)
311
316
        with person_logged_in(branch.owner):
312
317
            branch.reviewer = person
 
318
        vote = self.makeCodeReviewVote(branch)
313
319
        [badges] = IHasAffiliation(vote).getAffiliationBadges([person])
314
320
        self.assertEqual(
315
321
            ("/@@/product-badge", "Pting %s" % role), badges[0])
316
322
 
317
 
    def test_getBranch(self):
318
 
        # The branch is the context.
319
 
        branch = self.factory.makeBranch()
320
 
        vote = self.makeCodeReviewVote(branch)
321
 
        adapter = IHasAffiliation(vote)
322
 
        self.assertEqual(branch, adapter.getBranch())
323
 
 
324
 
    def test_branch_trusted_reviewer_affiliation(self):
325
 
        # A person who is the branch's trusted reviewer is affiliated.
326
 
        person = self.factory.makePerson()
327
 
        product = self.factory.makeProduct(name='pting')
328
 
        self._check_affiliated_with_product(
329
 
            person, product, 'trusted reviewer')
330
 
 
331
323
 
332
324
class TestDistroSeriesPillarAffiliation(TestCaseWithFactory):
333
325
 
347
339
            owner=owner, driver=driver, name='pting')
348
340
        distroseries = self.factory.makeDistroSeries(
349
341
            registrant=driver, distribution=distribution)
350
 
        [badges] = IHasAffiliation(distroseries).getAffiliationBadges([driver])
 
342
        [badges] = IHasAffiliation(
 
343
            distroseries).getAffiliationBadges([driver])
351
344
        self.assertEqual(
352
345
            ("/@@/distribution-badge", "Pting driver"), badges[0])
353
346
 
360
353
            owner=owner, driver=driver, name='pting')
361
354
        distroseries = self.factory.makeDistroSeries(
362
355
            registrant=owner, distribution=distribution)
363
 
        [badges] = IHasAffiliation(distroseries).getAffiliationBadges([driver])
 
356
        [badges] = IHasAffiliation(
 
357
            distroseries).getAffiliationBadges([driver])
364
358
        self.assertEqual(
365
359
            ("/@@/distribution-badge", "Pting driver"), badges[0])
366
360