Exemplo n.º 1
0
 def test_version_max_returns_None_on_empty_list(self):
     self.mox.ReplayAll()
     self.assertEquals(self.apa.version_max([]), None)
     v2 = VersionAdapter(FakeVersion._create('2.0', []))
     v21 = VersionAdapter(FakeVersion._create('2.0~1', []))
     self.assertEquals(self.apa.version_max([v21]), v21)
     self.assertEquals(self.apa.version_max([v2, v21]), v2)
     self.assertEquals(self.apa.version_max([v21, v2]), v2)
Exemplo n.º 2
0
 def __init__(self, apt_package):
     self.apt_package = apt_package
     self.name = apt_package.name
     if apt_package.current_ver:
         self.current_version = VersionAdapter(apt_package.current_ver)
     else:
         self.current_version = None
     self.candidate_version = None
     self.versions = [VersionAdapter(v) for v in apt_package.version_list]
Exemplo n.º 3
0
 def test_version_sort(self):
     self.mox.ReplayAll()
     self.assertEquals(self.apa.version_sort([]), [])
     v1 = VersionAdapter(FakeVersion._create('1', []))
     v0 = VersionAdapter(FakeVersion._create('0', []))
     v2 = VersionAdapter(FakeVersion._create('2.0', []))
     v21 = VersionAdapter(FakeVersion._create('2.0~1', []))
     self.assertEquals(self.apa.version_sort([v21]), [v21])
     self.assertEquals(self.apa.version_sort([v1, v0, v21, v2]),
                       [v2, v21, v1, v0])
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
    def set_up_package_adapter_and_replay_all(self):
        mock_depcache_adapter = self.mox.CreateMock(DepCacheAdapter)
        self.va = VersionAdapter(FakeVersion._create('1.2.4', []))
        mock_depcache_adapter.get_candidate_version(
            mox.Func(lambda pa: pa.name == 'afake')).AndReturn(self.va)
        self.mox.ReplayAll()

        self.p = PackageAdapterFactory(
            mock_depcache_adapter).create_package_adapter(self.fake)
Exemplo n.º 7
0
    def get_candidate_version(self, pkg):
        """Returns a VersionAdapter object representing the candidate version
		of the given PackageAdapter object pkg. Returns None if there is no
		candidate version."""
        apt_version = self.apt_dep_cache.get_candidate_ver(pkg.apt_package)
        if not apt_version:
            return None
        else:
            return VersionAdapter(apt_version)
Exemplo n.º 8
0
 def _prepare_package_with_candidate_from_official_source_and_current_from_unofficial(
         self):
     self.fp.append_version(FakeVersion._create('1.2.2', ['NotDebian']),
                            True)
     self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']))
     pa = PackageAdapter(self.fp)
     pa.candidate_version = VersionAdapter(
         FakeVersion._create('1.2.3', ['Debian']))
     return pa
Exemplo n.º 9
0
 def test_returns_a_status_object_on_package_with_candidate_from_unofficial_source(
         self):
     self.fp.append_version(FakeVersion._create('1.2.3', ['Unofficial']),
                            True)
     self.fp.append_version(FakeVersion._create('1.2', ['Debian']))
     pa = PackageAdapter(self.fp)
     pa.candidate_version = VersionAdapter(
         FakeVersion._create('1.2.5', ['NonDebian']))
     status = self.checker.check(pa)
     self.assert_(status != None)
     self.assertEquals(status.package_name, 'afake')
     self.assertEquals(status.installed_version.string, '1.2.3')
     self.assertEquals(status.candidate_version.string, '1.2.5')
 def assertVersionIsNotOfficiallyAvailable(self):
     self.assert_(not VersionAdapter(
         self.mock_apt_version).is_officially_available(self.mock_facter))
 def setUpVersionAdapter(self):
     self.va = VersionAdapter(self.fake_version)
 def test_analyze_version_in_dpkg_status_file_and_both_official_and_unofficial_source_returns_false(
         self):
     v = VersionAdapter(
         FakeVersion._create('1.2.3', ['dpkg', 'Debian', 'NonDebian']))
     self.assert_(not self.vchecker.analyze(v))
 def test_analyze_version_only_in_dpkg_status_file_returns_true(self):
     v = VersionAdapter(FakeVersion._create('1.2.3', ['dpkg']))
     self.assert_(self.vchecker.analyze(v))
 def test_analyze_version_without_sources_returns_true(self):
     v = VersionAdapter(FakeVersion._create('1.2.3', []))
     self.assert_(self.vchecker.analyze(v))
Exemplo n.º 15
0
 def _prepare_package_with_candidate_different_from_current(self):
     self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']), True)
     pa = PackageAdapter(self.fp)
     pa.candidate_version = VersionAdapter(
         (FakeVersion._create('1.2.4', ['Debian'])))
     return pa