~launchpad-pqm/launchpad/devel

13597.1.1 by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint.
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
8687.15.22 by Karl Fogel
Add the copyright header block to the remaining .py files.
2
# GNU Affero General Public License version 3 (see the file LICENSE).
8275.3.1 by Jonathan Lange
Add new model class SuiteSourcePackage, to represent a particular pocket
3
4
"""Tests for ISuiteSourcePackage."""
5
6
__metaclass__ = type
7
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
8
from lp.registry.interfaces.pocket import PackagePublishingPocket
8275.3.1 by Jonathan Lange
Add new model class SuiteSourcePackage, to represent a particular pocket
9
from lp.registry.model.suitesourcepackage import SuiteSourcePackage
8275.3.19 by Jonathan Lange
Fix up import locations.
10
from lp.testing import TestCaseWithFactory
14612.2.1 by William Grant
format-imports on lib/. So many imports.
11
from lp.testing.layers import DatabaseFunctionalLayer
8275.3.1 by Jonathan Lange
Add new model class SuiteSourcePackage, to represent a particular pocket
12
13
14
class TestSuiteSourcePackage(TestCaseWithFactory):
15
16
    layer = DatabaseFunctionalLayer
17
18
    def test_construction(self):
19
        # A SuiteSourcePackage is constructed from an `IDistroSeries`, a
20
        # `PackagePublishingPocket` enum and an `ISourcePackageName`. These
21
        # are all provided as attributes.
13597.1.1 by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint.
22
        distroseries = self.factory.makeDistroSeries()
8275.3.1 by Jonathan Lange
Add new model class SuiteSourcePackage, to represent a particular pocket
23
        pocket = PackagePublishingPocket.RELEASE
24
        sourcepackagename = self.factory.makeSourcePackageName()
25
        ssp = SuiteSourcePackage(distroseries, pocket, sourcepackagename)
26
        self.assertEqual(distroseries, ssp.distroseries)
27
        self.assertEqual(pocket, ssp.pocket)
28
        self.assertEqual(sourcepackagename, ssp.sourcepackagename)
29
30
    def test_sourcepackage(self):
31
        # A SuiteSourcePackage has a `sourcepackage` property, which is an
32
        # ISourcePackage that represents the sourcepackagename, distroseries
33
        # pair.
8275.3.20 by Jonathan Lange
Move makeSuiteSourcePackage to factory.
34
        ssp = self.factory.makeSuiteSourcePackage()
8275.3.1 by Jonathan Lange
Add new model class SuiteSourcePackage, to represent a particular pocket
35
        package = ssp.distroseries.getSourcePackage(ssp.sourcepackagename)
36
        self.assertEqual(package, ssp.sourcepackage)
13677.3.3 by Steve Kowalik
Revert 3 broken tests and fix the accidental deletion in test_suitesourcepackage
37
38
    def test_suite(self):
39
        # The `suite` property of a `SuiteSourcePackage` is a string of the
40
        # distro series name followed by the pocket suffix.
41
        ssp = self.factory.makeSuiteSourcePackage()
42
        self.assertEqual(ssp.distroseries.getSuite(ssp.pocket), ssp.suite)
43
44
    def test_distribution(self):
45
        # The `distribution` property of a `SuiteSourcePackage` is the
46
        # distribution that the object's distroseries is associated with.
47
        ssp = self.factory.makeSuiteSourcePackage()
48
        self.assertEqual(ssp.distroseries.distribution, ssp.distribution)
49
50
    def test_path(self):
51
        # The `path` property of a `SuiteSourcePackage` is a string that has
52
        # the distribution name followed by the suite followed by the source
53
        # package name, separated by slashes.
54
        ssp = self.factory.makeSuiteSourcePackage()
55
        self.assertEqual(
56
            '%s/%s/%s' % (
57
                ssp.distribution.name, ssp.suite, ssp.sourcepackagename.name),
58
            ssp.path)
59
60
    def test_repr(self):
61
        # The repr of a `SuiteSourcePackage` includes the path and clearly
62
        # refers to the type of the object.
63
        ssp = self.factory.makeSuiteSourcePackage()
64
        self.assertEqual('<SuiteSourcePackage %s>' % ssp.path, repr(ssp))
65
66
    def test_equality(self):
67
        ssp1 = self.factory.makeSuiteSourcePackage()
68
        ssp2 = SuiteSourcePackage(
69
            ssp1.distroseries, ssp1.pocket, ssp1.sourcepackagename)
70
        self.assertEqual(ssp1, ssp2)
71
72
    def test_displayname(self):
73
        # A suite source package has a display name.
74
        ssp = self.factory.makeSuiteSourcePackage()
75
        self.assertEqual(
76
            '%s in %s' % (ssp.sourcepackagename.name, ssp.suite),
77
            ssp.displayname)