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 TestDepCacheAdapter(test_helper.MoxTestCase):
    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)

    def testNoCandidate(self):
        self.mock_depcache.get_candidate_ver(
            self.a_fake_package).AndReturn(None)
        self.mox.ReplayAll()

        version_adapter = self.dca.get_candidate_version(self.package_adapter)
        self.assertEquals(version_adapter, None)

    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')
class TestDepCacheAdapter(test_helper.MoxTestCase):
	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)
	def testNoCandidate(self):
		self.mock_depcache.get_candidate_ver(self.a_fake_package).AndReturn(None)
		self.mox.ReplayAll()

		version_adapter = self.dca.get_candidate_version(self.package_adapter)
		self.assertEquals(version_adapter, None)
	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')
Example #4
0
def run(verbose):
    facter = Facter()
    reporter = Reporter()
    apt_pkg_adapter = AptPkgAdapter(apt_pkg)
    apt_pkg_adapter.init()
    cache_adapter = apt_pkg_adapter.get_cache_adapter(CacheAdapterFactory(),
                                                      reporter, NullProgress())
    apt_depcache_adapter = apt_pkg_adapter.get_depcache_adapter(
        DepCacheAdapterFactory())
    package_adapter_factory = PackageAdapterFactory(apt_depcache_adapter)
    checker = Checker(facter, verbose)
    config = Config()
    config_finder = ConfigFinder('/etc/apt/forktracer.conf',
                                 '/etc/apt/forktracer.d')
    config_parser = ConfigParser()
    for path, file in config_finder:
        config_parser.load(file, config)
    if verbose:
        policy = VerbosePolicy()
    else:
        policy = Policy(apt_pkg_adapter, facter, config)
    cache_adapter.run(checker, policy, package_adapter_factory)
	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)