~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/tests/test_bugtracker_components.py

[r=sinzui][bug=617695] For Bryce: Implements UI for displaying
 components registered at a remote bug tracker.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2010-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
"""Test for components and component groups (products) in bug trackers."""
7
7
 
8
8
__all__ = []
9
9
 
10
 
import unittest
11
10
import transaction
12
11
 
13
12
from canonical.launchpad.ftests import login_person
21
20
    )
22
21
 
23
22
 
24
 
class TestBugTrackerComponent(TestCaseWithFactory):
 
23
class BugTrackerComponentTestCase(TestCaseWithFactory):
25
24
 
26
25
    layer = DatabaseFunctionalLayer
27
26
 
28
27
    def setUp(self):
29
 
        super(TestBugTrackerComponent, self).setUp()
 
28
        super(BugTrackerComponentTestCase, self).setUp()
30
29
 
31
30
        regular_user = self.factory.makePerson()
32
31
        login_person(regular_user)
88
87
 
89
88
    def test_link_distro_source_package(self):
90
89
        """Check that a link can be set to a distro source package"""
91
 
        component = self.factory.makeBugTrackerComponent(
 
90
        example_component = self.factory.makeBugTrackerComponent(
92
91
            u'example', self.comp_group)
93
 
        package = self.factory.makeDistributionSourcePackage()
94
 
        self.assertIs(None, component.distro_source_package)
 
92
        dsp = self.factory.makeDistributionSourcePackage(u'example')
95
93
 
96
 
        # Set the source package on the component
97
 
        component.distro_source_package = package
98
 
        self.assertIsNot(None, component.distro_source_package)
 
94
        example_component.distro_source_package = dsp
 
95
        self.assertEqual(dsp, example_component.distro_source_package)
 
96
        comp = self.bug_tracker.getRemoteComponentForDistroSourcePackageName(
 
97
            dsp.distribution, dsp.sourcepackagename)
 
98
        self.assertIsNot(example_component, comp)
99
99
 
100
100
 
101
101
class TestBugTrackerWithComponents(TestCaseWithFactory):
148
148
    def test_multiple_product_bugtracker(self):
149
149
        """Bug tracker with multiple products and components"""
150
150
        # Create several component groups with varying numbers of components
151
 
        comp_group_i = self.bug_tracker.addRemoteComponentGroup(u'alpha')
 
151
        self.bug_tracker.addRemoteComponentGroup(u'alpha')
152
152
 
153
153
        comp_group_ii = self.bug_tracker.addRemoteComponentGroup(u'beta')
154
154
        comp_group_ii.addComponent(u'example-beta-1')
291
291
        component = ws_object(self.launchpad, db_comp)
292
292
        package = ws_object(self.launchpad, db_src_pkg)
293
293
        component.distro_source_package = package
294
 
 
295
 
 
296
 
def test_suite():
297
 
    suite = unittest.TestSuite()
298
 
    suite.addTest(unittest.TestLoader().loadTestsFromName(__name__))
299
 
 
300
 
    return suite