示例#1
0
class TestInstantiation(test_helper.MoxTestCase):
    def setUp(self):
        super(TestInstantiation, self).setUp()
        fv1 = FakeVersion()
        fv1.append_package_file(FakePackageFile())
        installed_version = VersionAdapter(fv1)
        fv2 = FakeVersion("1.2.4")
        fv2.append_package_file(FakePackageFile())
        candidate_version = VersionAdapter(fv2)
        self.versions_by_origin = {
            "Debian": [VersionAdapter(FakeVersion("foo"))],
            "Another": [VersionAdapter(FakeVersion("bar")), VersionAdapter(FakeVersion("baz"))],
        }
        self.s = Status("foo", installed_version, candidate_version, self.versions_by_origin)

    def testCorrectness(self):
        self.assertEquals(self.s.package_name, "foo")
        self.assertEquals(self.s.installed_version.string, "1.2.3")
        self.assertEquals(self.s.candidate_version.string, "1.2.4")
        installed_ver_pkgs = self.s.installed_version.files
        self.assertEquals(installed_ver_pkgs[0].origin, "Debian")
        self.assertEquals(self.s.versions_from("Debian")[0].string, "foo")
        self.assertEquals(self.s.versions_from("Another")[0].string, "bar")
        self.assertEquals(self.s.versions_from("Another")[1].string, "baz")
        self.assertEquals(self.s.versions_from("nowhere"), [])
        all = self.s.all_available_versions()
        self.assertEquals(len(all), 3)
        all_strings = [v.string for v in all]
        all_strings.sort()
        self.assert_("foo" in [v.string for v in all])
        self.assert_("bar" in [v.string for v in all])

    def testStringification(self):
        self.assertMatches(str(self.s), r"<Status foo .*1\.2\.3.*->.*1\.2\.4.*\[Debian: foo\]")
        self.assertMatches(str(self.s), r"<Status foo .*1\.2\.3.*->.*1\.2\.4.*\[Another: bar,baz\]")
示例#2
0
class Test_Instantiation_Without_Official_Versions(test_helper.MoxTestCase):
    def setUp(self):
        super(Test_Instantiation_Without_Official_Versions, self).setUp()
        fv1 = FakeVersion('1.2.5')
        fv1.append_package_file(FakePackageFile())
        installed_version = VersionAdapter(fv1)
        fv2 = FakeVersion('1.2.6')
        fv2.append_package_file(FakePackageFile())
        candidate_version = VersionAdapter(fv2)
        self.versions_by_origin = {
            'NonDebian': [VersionAdapter(FakeVersion('foo'))]
        }
        self.s = Status('foo', installed_version, candidate_version,
                        self.versions_by_origin)

    def testCorrectness(self):
        self.assertEquals(self.s.package_name, 'foo')
        self.assertEquals(self.s.installed_version.string, '1.2.5')
        self.assertEquals(self.s.candidate_version.string, '1.2.6')
        installed_ver_pkgs = self.s.installed_version.files
        self.assertEquals(installed_ver_pkgs[0].origin, 'Debian')
        self.assertEquals(self.s.versions_from('NonDebian')[0].string, 'foo')
        self.assertEquals(self.s.versions_from('nowhere'), [])

    def testStringification(self):
        self.assertMatches(str(self.s),
                           r'<Status foo .*1\.2\.5.*->.*1\.2\.6.*')
示例#3
0
 def setUp(self):
     super(Test_Instantiation_Without_Official_Versions, self).setUp()
     fv1 = FakeVersion('1.2.5')
     fv1.append_package_file(FakePackageFile())
     installed_version = VersionAdapter(fv1)
     fv2 = FakeVersion('1.2.6')
     fv2.append_package_file(FakePackageFile())
     candidate_version = VersionAdapter(fv2)
     self.versions_by_origin = {
         'NonDebian': [VersionAdapter(FakeVersion('foo'))]
     }
     self.s = Status('foo', installed_version, candidate_version,
                     self.versions_by_origin)
示例#4
0
	def testFormattingSameVersion(self):
		v = self.struct()
		v.string = '1.2'
		status = Status('apackage', v, v)
		report = self.reporter.format(status)
		self.assertNotContains(report, '[')
		self.assertContains(report, 'apackage (1.2)')
示例#5
0
	def testFormattingNoCurrentVersion(self):
		v1 = self.struct()
		v1.string = '1.2'
		status = Status('apackage', None, v1)
		report = self.reporter.format(status)
		self.assertContains(report, '(->1.2')
		self.assertNotContains(report, '[')
示例#6
0
	def testFormattingNoCandidateVersion(self):
		v1 = self.struct()
		v1.string = '1.2'
		status = Status('apackage', v1, None)
		report = self.reporter.format(status)
		self.assertContains(report, '1.2->)')
		self.assertNotContains(report, '[')
示例#7
0
 def setUp(self):
     super(TestInstantiation, self).setUp()
     fv1 = FakeVersion()
     fv1.append_package_file(FakePackageFile())
     installed_version = VersionAdapter(fv1)
     fv2 = FakeVersion('1.2.4')
     fv2.append_package_file(FakePackageFile())
     candidate_version = VersionAdapter(fv2)
     self.versions_by_origin = {
         'Debian': [VersionAdapter(FakeVersion('foo'))],
         'Another': [
             VersionAdapter(FakeVersion('bar')),
             VersionAdapter(FakeVersion('baz'))
         ]
     }
     self.s = Status('foo', installed_version, candidate_version,
                     self.versions_by_origin)
示例#8
0
class TestInstantiation(test_helper.MoxTestCase):
    def setUp(self):
        super(TestInstantiation, self).setUp()
        fv1 = FakeVersion()
        fv1.append_package_file(FakePackageFile())
        installed_version = VersionAdapter(fv1)
        fv2 = FakeVersion('1.2.4')
        fv2.append_package_file(FakePackageFile())
        candidate_version = VersionAdapter(fv2)
        self.versions_by_origin = {
            'Debian': [VersionAdapter(FakeVersion('foo'))],
            'Another': [
                VersionAdapter(FakeVersion('bar')),
                VersionAdapter(FakeVersion('baz'))
            ]
        }
        self.s = Status('foo', installed_version, candidate_version,
                        self.versions_by_origin)

    def testCorrectness(self):
        self.assertEquals(self.s.package_name, 'foo')
        self.assertEquals(self.s.installed_version.string, '1.2.3')
        self.assertEquals(self.s.candidate_version.string, '1.2.4')
        installed_ver_pkgs = self.s.installed_version.files
        self.assertEquals(installed_ver_pkgs[0].origin, 'Debian')
        self.assertEquals(self.s.versions_from('Debian')[0].string, 'foo')
        self.assertEquals(self.s.versions_from('Another')[0].string, 'bar')
        self.assertEquals(self.s.versions_from('Another')[1].string, 'baz')
        self.assertEquals(self.s.versions_from('nowhere'), [])
        all = self.s.all_available_versions()
        self.assertEquals(len(all), 3)
        all_strings = [v.string for v in all]
        all_strings.sort()
        self.assert_('foo' in [v.string for v in all])
        self.assert_('bar' in [v.string for v in all])

    def testStringification(self):
        self.assertMatches(
            str(self.s),
            r'<Status foo .*1\.2\.3.*->.*1\.2\.4.*\[Debian: foo\]')
        self.assertMatches(
            str(self.s),
            r'<Status foo .*1\.2\.3.*->.*1\.2\.4.*\[Another: bar,baz\]')
示例#9
0
 def setUp(self):
     super(Test_Instantiation_Without_Official_Versions, self).setUp()
     fv1 = FakeVersion("1.2.5")
     fv1.append_package_file(FakePackageFile())
     installed_version = VersionAdapter(fv1)
     fv2 = FakeVersion("1.2.6")
     fv2.append_package_file(FakePackageFile())
     candidate_version = VersionAdapter(fv2)
     self.versions_by_origin = {"NonDebian": [VersionAdapter(FakeVersion("foo"))]}
     self.s = Status("foo", installed_version, candidate_version, self.versions_by_origin)
示例#10
0
 def setUp(self):
     super(TestInstantiation, self).setUp()
     fv1 = FakeVersion()
     fv1.append_package_file(FakePackageFile())
     installed_version = VersionAdapter(fv1)
     fv2 = FakeVersion("1.2.4")
     fv2.append_package_file(FakePackageFile())
     candidate_version = VersionAdapter(fv2)
     self.versions_by_origin = {
         "Debian": [VersionAdapter(FakeVersion("foo"))],
         "Another": [VersionAdapter(FakeVersion("bar")), VersionAdapter(FakeVersion("baz"))],
     }
     self.s = Status("foo", installed_version, candidate_version, self.versions_by_origin)
示例#11
0
	def testFormatting(self):
		v1 = self.struct()
		v1.string = '1.2'
		v2 = self.struct()
		v2.string = '1.3'
		v3, v4 = self.struct(), self.struct()
		v3.string = '1.2.3'
		v4.string = 'x.y.z'
		status = Status('apackage', v1, v2, {'Debian': [v3, v4], 'another origin': [v3, v4]})
		report = self.reporter.format(status)
		self.assertContains(report, 'apackage (1.2->1.3) ')
		self.assertContains(report, ' [Debian: 1.2.3 x.y.z]')
		self.assertContains(report, ' [another origin: 1.2.3 x.y.z]')
示例#12
0
class Test_Instantiation_Without_Official_Versions(test_helper.MoxTestCase):
    def setUp(self):
        super(Test_Instantiation_Without_Official_Versions, self).setUp()
        fv1 = FakeVersion("1.2.5")
        fv1.append_package_file(FakePackageFile())
        installed_version = VersionAdapter(fv1)
        fv2 = FakeVersion("1.2.6")
        fv2.append_package_file(FakePackageFile())
        candidate_version = VersionAdapter(fv2)
        self.versions_by_origin = {"NonDebian": [VersionAdapter(FakeVersion("foo"))]}
        self.s = Status("foo", installed_version, candidate_version, self.versions_by_origin)

    def testCorrectness(self):
        self.assertEquals(self.s.package_name, "foo")
        self.assertEquals(self.s.installed_version.string, "1.2.5")
        self.assertEquals(self.s.candidate_version.string, "1.2.6")
        installed_ver_pkgs = self.s.installed_version.files
        self.assertEquals(installed_ver_pkgs[0].origin, "Debian")
        self.assertEquals(self.s.versions_from("NonDebian")[0].string, "foo")
        self.assertEquals(self.s.versions_from("nowhere"), [])

    def testStringification(self):
        self.assertMatches(str(self.s), r"<Status foo .*1\.2\.5.*->.*1\.2\.6.*")
 def get_status(self, facter):
     """Creates a new Status object based on this one, given a Facter."""
     versions_by_origin = {}
     for version in self.versions:
         for pfa in version.files:
             origin = pfa.origin
             if not origin:
                 continue
             if versions_by_origin.has_key(origin):
                 versions_by_origin[origin].append(version)
             else:
                 versions_by_origin[origin] = [version]
     return Status(self.name, self.current_version, self.candidate_version,
                   versions_by_origin)
示例#14
0
 def _create_mock_status(self,
                         package,
                         current_version,
                         candidate_version,
                         _official_versions,
                         other_versions={}):
     official_versions = [
         self._create_mock_version_adapter(v) for v in _official_versions
     ]
     vbo = {}
     vbo['Debian'] = official_versions
     for o, vers in other_versions.items():
         vbo[o] = [
             self._create_mock_version_adapter((
                 v,
                 o,
             )) for v in vers
         ]
     return Status(package,
                   self._create_mock_version_adapter(current_version),
                   self._create_mock_version_adapter(candidate_version),
                   vbo)