def setUp(self):
     super(CheckerCheckTestCase, self).setUp()
     self.fp = FakePackage()
     self.apt_pkg_adapter = AptPkgAdapter(
         self._create_mock_apt_pkg_module())
     self.apt_pkg_adapter.init()
     self.setUpChecker()
class TestBasePackageAdapter(test_helper.MoxTestCase):
	def setUp(self):
		super(TestBasePackageAdapter, self).setUp()
		self.fake_package = FakePackage()
		self.setUp_mangle_fake_package()
		self.pa = PackageAdapter(self.fake_package)
		self.setUp_mangle_package_adapter()
		self.facter = self._create_mock_facter('Debian')
		self.apt_pkg_adapter = AptPkgAdapter(self._create_mock_apt_pkg_module())
		self.apt_pkg_adapter.init()
		self.status = self.pa.get_status(self.facter)
	def setUp_mangle_fake_package(self):
		pass
	def setUp_mangle_package_adapter(self):
		pass
	def testProperties(self):
		self.assertEquals(self.pa.name, 'afake')
		self.assertEquals(self.pa.apt_package, self.fake_package)
	def testLenOfVersionsNonNegative(self):
		self.assert_(self.pa.versions >= 0)
	def testBasicStringificationWorks(self):
		self.assertContains(str(self.pa), 'PackageAdapter')
	def setUpAddAVersion(self, source = 'NonDebian', version = 'blah'):
		self.fake_package.append_version(FakeVersion._create(version, [source]))
	def test_get_status_returns_an_object(self):
		self.assert_(self.status)
		self.assertEquals(self.status.package_name, 'afake')
		self.assertEquals(self.status.installed_version, self.pa.current_version)
		self.assertEquals(self.status.candidate_version, self.pa.candidate_version)
		self.assert_(len(self.status.versions_by_origin) >= 0)
	def setUp(self):
		super(TestBasePackageAdapter, self).setUp()
		self.fake_package = FakePackage()
		self.setUp_mangle_fake_package()
		self.pa = PackageAdapter(self.fake_package)
		self.setUp_mangle_package_adapter()
		self.facter = self._create_mock_facter('Debian')
		self.apt_pkg_adapter = AptPkgAdapter(self._create_mock_apt_pkg_module())
		self.apt_pkg_adapter.init()
		self.status = self.pa.get_status(self.facter)
 def setUp(self):
     super(TestDepCacheAdapter, self).setUp()
     self.mock_depcache = self.mox.CreateMock(apt_pkg.DepCache)
     self.a_fake_package = FakePackage()
     self.package_adapter = PackageAdapter(self.a_fake_package)
     self.dca = DepCacheAdapterFactory().create_depcache_adapter(
         self.mock_depcache)
class CheckerCheckTestCase(test_helper.MoxTestCase):
    """Common plumbing."""
    def setUp(self):
        super(CheckerCheckTestCase, self).setUp()
        self.fp = FakePackage()
        self.apt_pkg_adapter = AptPkgAdapter(
            self._create_mock_apt_pkg_module())
        self.apt_pkg_adapter.init()
        self.setUpChecker()

    def setUpChecker(self):
        self.checker = Checker(self._create_mock_facter('Debian'))

    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 _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 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()
Example #7
0
class CheckerCheckTestCase(test_helper.MoxTestCase):
	"""Common plumbing."""
	def setUp(self):
		super(CheckerCheckTestCase, self).setUp()
		self.fp = FakePackage()
		self.apt_pkg_adapter = AptPkgAdapter(self._create_mock_apt_pkg_module())
		self.apt_pkg_adapter.init()
		self.setUpChecker()
	def setUpChecker(self):
		self.checker = Checker(self._create_mock_facter('Debian'))
	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 _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
Example #8
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'
	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'
 def setUp(self):
     super(VersionCheckerTest, self).setUp()
     self.fp = FakePackage()
     self.facter = self._create_mock_facter('Debian')
     self.setUpChecker()
 def set_up_fake_cache_tweak(self):
     self.fake_cache.append_package(FakePackage())
 def set_up_fake_cache_tweak(self):
     self.fake_cache.append_package(
         FakePackage(current_state=apt_pkg.CURSTATE_UNPACKED))
 def set_up_fake_cache_tweak(self):
     self.fake_cache.append_package(
         FakePackage(current_state=apt_pkg.CURSTATE_HALF_CONFIGURED))
 def set_up_fake_cache_tweak(self):
     self.fake_cache.append_package(FakePackage(name='foo'))
     self.fake_cache.append_package(FakePackage(name='foo'))
Example #15
0
	def setUp(self):
		super(CheckerCheckTestCase, self).setUp()
		self.fp = FakePackage()
		self.apt_pkg_adapter = AptPkgAdapter(self._create_mock_apt_pkg_module())
		self.apt_pkg_adapter.init()
		self.setUpChecker()