Пример #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)
	def testWithCandidate(self):
		fake_version = FakeVersion('1.2')
		fake_version.append_package_file(FakePackageFile())
		self.mock_depcache.get_candidate_ver(self.a_fake_package).AndReturn(fake_version)
		self.mox.ReplayAll()

		version_adapter = self.dca.get_candidate_version(self.package_adapter)
		self.assertEquals(version_adapter.string, '1.2')
	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)
Пример #4
0
    def test_returns_none_in_common_case(self):
        """Common case means: package with identical, officially-available
		current and candidate versions, which is also the newest available
		version."""
        self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']), True)
        self.fp.append_version(FakeVersion._create('1.2.2', ['Debian']))
        pa = PackageAdapter(self.fp)
        pa.candidate_version = pa.current_version
        self.assertEquals(self.checker.check(pa), None)
Пример #5
0
 def test_returns_none_in_common_case_when_all_versions_available_additionally_from_unofficial_source(
         self):
     self.fp.append_version(
         FakeVersion._create('1.2.3', ['Debian', 'UnOfficial']), True)
     self.fp.append_version(
         FakeVersion._create('1.2.2', ['Debian', 'UnOfficial']))
     pa = PackageAdapter(self.fp)
     pa.candidate_version = pa.current_version
     self.assertEquals(self.checker.check(pa), None)
Пример #6
0
	def test_returns_none_in_common_case(self):
		"""Common case means: package with identical, officially-available
		current and candidate versions, which is also the newest available
		version."""
		self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']), True)
		self.fp.append_version(FakeVersion._create('1.2.2', ['Debian']))
		pa = PackageAdapter(self.fp)
		pa.candidate_version = pa.current_version
		self.assertEquals(self.checker.check(pa), None)
	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])
Пример #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
    def testWithCandidate(self):
        fake_version = FakeVersion('1.2')
        fake_version.append_package_file(FakePackageFile())
        self.mock_depcache.get_candidate_ver(
            self.a_fake_package).AndReturn(fake_version)
        self.mox.ReplayAll()

        version_adapter = self.dca.get_candidate_version(self.package_adapter)
        self.assertEquals(version_adapter.string, '1.2')
Пример #10
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')
Пример #11
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])
Пример #12
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')
Пример #13
0
 def setUp(self):
     super(Test_Package_And_Version_Reading, self).setUp()
     self.fake = FakePackage()
     v1 = FakeVersion()
     v1.ver_str = '1.2.3'
     v1.append_package_file(FakePackageFile())
     fpf = FakePackageFile()
     fpf.not_automatic = 1
     v1.append_package_file(fpf)
     v2 = FakeVersion()
     v2.ver_str = '4.5.6'
     self.fake.version_list.append(v1)
     self.fake.version_list.append(v2)
     self.fake.current_ver = v1
     self.set_up_package_adapter_and_replay_all()
Пример #14
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)
Пример #15
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)
Пример #16
0
    def test_aborts_on_package_without_current_version(self):
        """CacheAdapter should not pass such objects to us. It's better to know
		in such cases. If there will ever be a need to support this, it can be
		changed."""
        self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']), True)
        pa = PackageAdapter(self.fp)
        pa.candidate_version = pa.current_version
        pa.current_version = None
        self.assertRaises(ValueError, self.checker.check, pa)
Пример #17
0
	def test_aborts_on_package_without_current_version(self):
		"""CacheAdapter should not pass such objects to us. It's better to know
		in such cases. If there will ever be a need to support this, it can be
		changed."""
		self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']), True)
		pa = PackageAdapter(self.fp)
		pa.candidate_version = pa.current_version
		pa.current_version = None
		self.assertRaises(ValueError, self.checker.check, pa)
Пример #18
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)
class TestBaseVersionAdapter(test_helper.MoxTestCase):
	def setUp(self):
		super(TestBaseVersionAdapter, self).setUp()
		self.setUpFakeVersion()
		self.setUpVersionAdapter()
	def setUpFakeVersion(self):
		self.fake_version = FakeVersion()
	def setUpVersionAdapter(self):
		self.va = VersionAdapter(self.fake_version)
	def testString(self):
		self.assertEquals(self.va.string, '1.2.3')
	def testLenOfFilesListPositive(self):
		"If there is a version, it must come from at least one file (dpkg status)."
		self.assert_(self.va.files > 0)
	def testBasicStringification(self):
		self.assertMatches(str(self.va), r'<VersionAdapter 1.2.3')
	def setUpAddAFile(self):
		self.fake_version.append_package_file(FakePackageFile(path = '/b/lah'))
Пример #20
0
	def test_does_not_abort_and_returns_a_status_object_on_package_without_candidate_version(self):
		"""Because a candidate version is always reported by apt in normal
		situations, even when the only known version is installed and not
		available anywhere else. One case where no candidate version is
		reported is when there is a pin which cannot be met."""
		self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']), True)
		pa = PackageAdapter(self.fp)
		pa.candidate_version = None
		status = self.checker.check(pa)
		self.assert_(status != None)
Пример #21
0
    def test_does_not_abort_and_returns_a_status_object_on_package_without_candidate_version(
            self):
        """Because a candidate version is always reported by apt in normal
		situations, even when the only known version is installed and not
		available anywhere else. One case where no candidate version is
		reported is when there is a pin which cannot be met."""
        self.fp.append_version(FakeVersion._create('1.2.3', ['Debian']), True)
        pa = PackageAdapter(self.fp)
        pa.candidate_version = None
        status = self.checker.check(pa)
        self.assert_(status != None)
Пример #22
0
	def setUp(self):
		super(Test_Package_And_Version_Reading, self).setUp()
		self.fake = FakePackage()
		v1 = FakeVersion()
		v1.ver_str = '1.2.3'
		v1.append_package_file(FakePackageFile())
		fpf = FakePackageFile()
		fpf.not_automatic = 1
		v1.append_package_file(fpf)
		v2 = FakeVersion()
		v2.ver_str = '4.5.6'
		self.fake.version_list.append(v1)
		self.fake.version_list.append(v2)
		self.fake.current_ver = v1
		self.set_up_package_adapter_and_replay_all()
class TestBaseVersionAdapter(test_helper.MoxTestCase):
    def setUp(self):
        super(TestBaseVersionAdapter, self).setUp()
        self.setUpFakeVersion()
        self.setUpVersionAdapter()

    def setUpFakeVersion(self):
        self.fake_version = FakeVersion()

    def setUpVersionAdapter(self):
        self.va = VersionAdapter(self.fake_version)

    def testString(self):
        self.assertEquals(self.va.string, '1.2.3')

    def testLenOfFilesListPositive(self):
        "If there is a version, it must come from at least one file (dpkg status)."
        self.assert_(self.va.files > 0)

    def testBasicStringification(self):
        self.assertMatches(str(self.va), r'<VersionAdapter 1.2.3')

    def setUpAddAFile(self):
        self.fake_version.append_package_file(FakePackageFile(path='/b/lah'))
Пример #24
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)
Пример #25
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)
Пример #26
0
 def test_package_without_candidate_version_and_current_unofficial(self):
     self.fp.current_ver = FakeVersion._create('1.2.2', ['NotDebian'])
     pa = PackageAdapter(self.fp)
     pa.candidate_version = None
     status = self.checker.check(pa)
     self.assert_(status != None)
	def setUpFakeVersion(self):
		self.fake_version = FakeVersion()
Пример #28
0
	def setUp(self):
		super(TestIntegraton, self).setUp()
		dpkg_status_file = FakePackageFile(type = 'dpkg')
		debian_stable_package_file = FakePackageFile(archive = 'stable')
		debian_proposed_updates_package_file = FakePackageFile(archive = 'stable-proposed-updates')
		debian_security_package_file = FakePackageFile(archive = 'stable-security')
		local_package_file = FakePackageFile(origin = 'SnakeOil, Inc.', archive = 'etch')

		libc6_version = FakeVersion('2.6.1-2etch1')
		libc6_version.append_package_file(debian_stable_package_file)
		libc6_version.append_package_file(debian_security_package_file)
		libc6_updates_version = FakeVersion('2.6.1-2etch2')
		libc6_updates_version.append_package_file(debian_proposed_updates_package_file)
		libc6_updates_version.append_package_file(dpkg_status_file)
		libc6 = FakePackage(name = 'libc6')
		libc6.append_version(libc6_updates_version, True)
		libc6.append_version(libc6_version)

		libspf_version = FakeVersion('0.1-1')
		libspf_version.append_package_file(debian_stable_package_file)
		libspf_updates_version = FakeVersion('0.1-2')
		libspf_updates_version.append_package_file(debian_proposed_updates_package_file)
		libspf_local_version = FakeVersion('0.1-1~sl1')
		libspf_local_version.append_package_file(dpkg_status_file)
		libspf_local_version.append_package_file(local_package_file)
		libspf = FakePackage(name = 'libspf')
		libspf.append_version(libspf_version)
		libspf.append_version(libspf_local_version, True)
		libspf.append_version(libspf_updates_version)

		libfoobar_version = FakeVersion('0.5-5')
		libfoobar_version.append_package_file(debian_stable_package_file)
		libfoobar_local_version = FakeVersion('0.5-5~sl1')
		libfoobar_local_version.append_package_file(dpkg_status_file)
		libfoobar_local_version.append_package_file(local_package_file)
		libfoobar = FakePackage(name = 'libfoobar')
		libfoobar.append_version(libfoobar_version)
		libfoobar.append_version(libfoobar_local_version, True)

		git_version = FakeVersion('1:1.5.2.5-2build1')
		git_version.append_package_file(debian_stable_package_file)
		git_backport_version = FakeVersion('1:1.5.6.3-1.1ubuntu2~mowsiany.1')
		git_backport_version.append_package_file(dpkg_status_file)
		git_backport_version.append_package_file(local_package_file)
		git = FakePackage(name = 'git-core')
		git.append_version(git_version)
		git.append_version(git_backport_version, True)

		self.apt_cache = self.struct()
		self.apt_cache.packages = [git, libc6, libspf, libfoobar]

		self.apt_depcache = self.struct()
		version_table = {
			'libc6': libc6_updates_version,
			'libspf': libspf_local_version,
			'libfoobar': libfoobar_local_version,
			'git-core': git_backport_version}
		self.apt_depcache.get_candidate_ver = lambda o: version_table[o.name]

		self.reporter = self.mox.CreateMock(Reporter)
		self.mock_progress = self.struct()

		self.apt_pkg = self._create_mock_apt_pkg_module()
		test_helper.copy_state_constants(self.apt_pkg, apt_pkg)
		self.apt_pkg.Cache(self.mock_progress).AndReturn(self.apt_cache)

		self.facter = self.mox.CreateMock(Facter)
		self.facter.distributors_id = 'Debian'
Пример #29
0
 def test_returns_a_status_object_on_package_with_same_current_and_candidate_both_only_locally(
         self):
     self.fp.current_ver = FakeVersion._create('1.2.3', ['dpkg'])
     pa = PackageAdapter(self.fp)
     pa.candidate_version = pa.current_version
     self.assert_(self.checker.check(pa) != None)
Пример #30
0
	def test_returns_a_status_object_on_package_with_same_current_and_candidate_both_only_locally(self):
		self.fp.current_ver = FakeVersion._create('1.2.3', ['dpkg'])
		pa = PackageAdapter(self.fp)
		pa.candidate_version = pa.current_version
		self.assert_(self.checker.check(pa) != None)
 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 setUp_mangle_fake_package(self):
		self.setUpAddAVersion()
		self.fake_package.current_ver = FakeVersion('1.xx.yy')
		self.official_version = FakeVersion._create('2.3.4', ['Debian'])
		self.fake_package.append_version(self.official_version)
Пример #33
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
Пример #34
0
	def test_returns_none_in_common_case_when_all_versions_available_additionally_from_unofficial_source(self):
		self.fp.append_version(FakeVersion._create('1.2.3', ['Debian', 'UnOfficial']), True)
		self.fp.append_version(FakeVersion._create('1.2.2', ['Debian', 'UnOfficial']))
		pa = PackageAdapter(self.fp)
		pa.candidate_version = pa.current_version
		self.assertEquals(self.checker.check(pa), None)
Пример #35
0
	def test_package_without_candidate_version_and_current_unofficial(self):
		self.fp.current_ver = FakeVersion._create('1.2.2', ['NotDebian'])
		pa = PackageAdapter(self.fp)
		pa.candidate_version = None
		status = self.checker.check(pa)
		self.assert_(status != None)
 def setUpFakeVersion(self):
     self.fake_version = FakeVersion()
	def test_analyze_version_without_sources_returns_true(self):
		v = VersionAdapter(FakeVersion._create('1.2.3', []))
		self.assert_(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))
Пример #39
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)
	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))
Пример #41
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
 def test_analyze_version_without_sources_returns_true(self):
     v = VersionAdapter(FakeVersion._create('1.2.3', []))
     self.assert_(self.vchecker.analyze(v))
	def setUpAddAVersion(self, source = 'NonDebian', version = 'blah'):
		self.fake_package.append_version(FakeVersion._create(version, [source]))
 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))
Пример #45
0
    def setUp(self):
        super(TestIntegraton, self).setUp()
        dpkg_status_file = FakePackageFile(type='dpkg')
        debian_stable_package_file = FakePackageFile(archive='stable')
        debian_proposed_updates_package_file = FakePackageFile(
            archive='stable-proposed-updates')
        debian_security_package_file = FakePackageFile(
            archive='stable-security')
        local_package_file = FakePackageFile(origin='SnakeOil, Inc.',
                                             archive='etch')

        libc6_version = FakeVersion('2.6.1-2etch1')
        libc6_version.append_package_file(debian_stable_package_file)
        libc6_version.append_package_file(debian_security_package_file)
        libc6_updates_version = FakeVersion('2.6.1-2etch2')
        libc6_updates_version.append_package_file(
            debian_proposed_updates_package_file)
        libc6_updates_version.append_package_file(dpkg_status_file)
        libc6 = FakePackage(name='libc6')
        libc6.append_version(libc6_updates_version, True)
        libc6.append_version(libc6_version)

        libspf_version = FakeVersion('0.1-1')
        libspf_version.append_package_file(debian_stable_package_file)
        libspf_updates_version = FakeVersion('0.1-2')
        libspf_updates_version.append_package_file(
            debian_proposed_updates_package_file)
        libspf_local_version = FakeVersion('0.1-1~sl1')
        libspf_local_version.append_package_file(dpkg_status_file)
        libspf_local_version.append_package_file(local_package_file)
        libspf = FakePackage(name='libspf')
        libspf.append_version(libspf_version)
        libspf.append_version(libspf_local_version, True)
        libspf.append_version(libspf_updates_version)

        libfoobar_version = FakeVersion('0.5-5')
        libfoobar_version.append_package_file(debian_stable_package_file)
        libfoobar_local_version = FakeVersion('0.5-5~sl1')
        libfoobar_local_version.append_package_file(dpkg_status_file)
        libfoobar_local_version.append_package_file(local_package_file)
        libfoobar = FakePackage(name='libfoobar')
        libfoobar.append_version(libfoobar_version)
        libfoobar.append_version(libfoobar_local_version, True)

        git_version = FakeVersion('1:1.5.2.5-2build1')
        git_version.append_package_file(debian_stable_package_file)
        git_backport_version = FakeVersion('1:1.5.6.3-1.1ubuntu2~mowsiany.1')
        git_backport_version.append_package_file(dpkg_status_file)
        git_backport_version.append_package_file(local_package_file)
        git = FakePackage(name='git-core')
        git.append_version(git_version)
        git.append_version(git_backport_version, True)

        self.apt_cache = self.struct()
        self.apt_cache.packages = [git, libc6, libspf, libfoobar]

        self.apt_depcache = self.struct()
        version_table = {
            'libc6': libc6_updates_version,
            'libspf': libspf_local_version,
            'libfoobar': libfoobar_local_version,
            'git-core': git_backport_version
        }
        self.apt_depcache.get_candidate_ver = lambda o: version_table[o.name]

        self.reporter = self.mox.CreateMock(Reporter)
        self.mock_progress = self.struct()

        self.apt_pkg = self._create_mock_apt_pkg_module()
        test_helper.copy_state_constants(self.apt_pkg, apt_pkg)
        self.apt_pkg.Cache(self.mock_progress).AndReturn(self.apt_cache)

        self.facter = self.mox.CreateMock(Facter)
        self.facter.distributors_id = 'Debian'
Пример #46
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