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)
Ejemplo n.º 2
0
 def setUp(self):
     super(TestPolicyBase, self).setUp()
     self.apt_pkg_adapter = AptPkgAdapter(
         self._create_mock_apt_pkg_module())
     self.apt_pkg_adapter.init()
     self.mock_facter = self._create_mock_facter('Debian')
     self.set_up_policy_creation()
Ejemplo n.º 3
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()
Ejemplo n.º 4
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
	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)
Ejemplo n.º 6
0
class TestPolicyBase(test_helper.MoxTestCase):
	def _create_mock_version_adapter(self, version_string):
		if version_string == None:
			return None
		mva = self.mox.CreateMock(VersionAdapter)
		mva.files = []
		if type(version_string) == tuple:
			mva.string = version_string[0]
			for o in version_string[1]:
				mva.files.append(PackageFileAdapter(FakePackageFile(origin = o)))
		else:
			mva.string = version_string
			mva.files.append(PackageFileAdapter(FakePackageFile(origin = 'Debian')))
		return mva
	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)
	def _create_mock_config(self, hashes):
		stanzas = []
		for hash in hashes:
			stanza = ConfigStanza()
			stanza.set('package', 'apackage', 1)
			stanza.set('accept-origin', hash['accepted_origin'], 2)
			stanza.set('track-origin', hash['track_origin'], 3)
			stanza.set('track-version', hash['track_version'], 4)
			stanza.finish(4)
			stanzas.append(stanza)
		mock_config = self.struct()
		mock_config.package = lambda name: name == 'apackage' and stanzas or []
		return mock_config
	def setUp(self):
		super(TestPolicyBase, self).setUp()
		self.apt_pkg_adapter = AptPkgAdapter(self._create_mock_apt_pkg_module())
		self.apt_pkg_adapter.init()
		self.mock_facter = self._create_mock_facter('Debian')
		self.set_up_policy_creation()
	def set_up_policy_creation(self):
		self.policy = Policy(self.apt_pkg_adapter, self.mock_facter, self._create_mock_config([]))
	def assert_should_report_yes(self, current_version, candidate_version, official_versions, package = 'apackage', other_versions = {}):
		s = self._create_mock_status(package, current_version, candidate_version, official_versions, other_versions = other_versions)
		self.assert_(self.policy.should_report(s))
	def assert_should_report_NOT(self, current_version, candidate_version, official_versions, package = 'apackage', other_versions = {}):
		s = self._create_mock_status(package, current_version, candidate_version, official_versions, other_versions = other_versions)
		self.assert_(not self.policy.should_report(s))
	def test_missing_version(self):
		self.mox.ReplayAll()
		self.assert_should_report_yes('2.1~1', None, ['2.1'])
		self.assert_should_report_yes(None, '2.1~1', ['2.1'])
		self.assert_should_report_yes('2.1~1', '2.1~1', [])
Ejemplo n.º 7
0
    def finishSetUp(self):
        self.apt_pkg_adapter = AptPkgAdapter(self.apt_pkg)
        self.apt_pkg_adapter.init()
        cache_adapter_factory = CacheAdapterFactory()
        self.package_adapter_factory = PackageAdapterFactory(
            DepCacheAdapter(self.apt_depcache))
        self.cache_adapter = self.apt_pkg_adapter.get_cache_adapter(
            cache_adapter_factory, self.reporter, self.mock_progress)

        config_finder = ConfigFinder('test-data/config')
        config_parser = ConfigParser()
        self.config = Config()
        for path, file in config_finder:
            config_parser.load(file, self.config)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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
Ejemplo n.º 10
0
	def finishSetUp(self):
		self.apt_pkg_adapter = AptPkgAdapter(self.apt_pkg)
		self.apt_pkg_adapter.init()
		cache_adapter_factory = CacheAdapterFactory()
		self.package_adapter_factory = PackageAdapterFactory(DepCacheAdapter(self.apt_depcache))
		self.cache_adapter = self.apt_pkg_adapter.get_cache_adapter(cache_adapter_factory, self.reporter, self.mock_progress)

		config_finder = ConfigFinder('test-data/config')
		config_parser = ConfigParser()
		self.config = Config()
		for path, file in config_finder:
			config_parser.load(file, self.config)
 def setUp(self):
     super(Test_Base_Cache_Adapter, self).setUp()
     self.set_up_fake_cache()
     self.mock_policy = self.mox.CreateMock(Policy)
     self.mock_reporter = self.mox.CreateMock(Reporter)
     self.mock_depcache_adapter = self.mox.CreateMock(DepCacheAdapter)
     self.package_adapter_factory = PackageAdapterFactory(
         self.mock_depcache_adapter)
     self.set_up_apt_pkg()
     self.apt_pkg_adapter = AptPkgAdapter(self.fake_apt_pkg_module)
     self.ca = CacheAdapterFactory().create_cache_adapter(
         self.fake_cache, self.apt_pkg_adapter, self.mock_reporter)
     self.mock_checker = self.mox.CreateMock(Checker)
     self.version_adapter = self.mox.CreateMock(VersionAdapter)
     self.version_adapter.string = '1.2.3'
     self.mock_status = self.mox.CreateMock(Status)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
class TestIntegraton(test_helper.MoxTestCase):
    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 finishSetUp(self):
        self.apt_pkg_adapter = AptPkgAdapter(self.apt_pkg)
        self.apt_pkg_adapter.init()
        cache_adapter_factory = CacheAdapterFactory()
        self.package_adapter_factory = PackageAdapterFactory(
            DepCacheAdapter(self.apt_depcache))
        self.cache_adapter = self.apt_pkg_adapter.get_cache_adapter(
            cache_adapter_factory, self.reporter, self.mock_progress)

        config_finder = ConfigFinder('test-data/config')
        config_parser = ConfigParser()
        self.config = Config()
        for path, file in config_finder:
            config_parser.load(file, self.config)

    def test_verbose(self):
        # lib6 - never
        self.reporter.report(
            mox.Func(lambda o: o.package_name == 'libspf')).InAnyOrder()
        self.reporter.report(
            mox.Func(lambda o: o.package_name == 'libfoobar')).InAnyOrder()
        self.reporter.report(
            mox.Func(lambda o: o.package_name == 'git-core')).InAnyOrder()
        self.mox.ReplayAll()

        self.finishSetUp()
        checker = Checker(self.facter, True)
        policy = VerbosePolicy()
        self.cache_adapter.run(checker, policy, self.package_adapter_factory)

    def test_non_verbose_empty_config(self):
        # libc6 - never
        self.reporter.report(
            mox.Func(lambda o: o.package_name == 'libspf')).InAnyOrder()
        # libfoobar - never
        self.reporter.report(
            mox.Func(lambda o: o.package_name == 'git-core')).InAnyOrder()
        self.mox.ReplayAll()

        self.finishSetUp()
        checker = Checker(self.facter)
        policy = Policy(self.apt_pkg_adapter, self.facter, Config())
        self.cache_adapter.run(checker, policy, self.package_adapter_factory)

    def test_non_verbose(self):
        # libc6 - never
        self.reporter.report(mox.Func(lambda o: o.package_name == 'libspf'))
        # libfoobar - never
        # git-core - never
        self.mox.ReplayAll()

        self.finishSetUp()
        checker = Checker(self.facter)
        policy = Policy(self.apt_pkg_adapter, self.facter, self.config)
        self.cache_adapter.run(checker, policy, self.package_adapter_factory)
Ejemplo n.º 14
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()
Ejemplo n.º 15
0
 def setUp(self):
     super(Base_Apt_Pkg_Adapter_Test, self).setUp()
     self.create_mock_apt_pkg()
     self.set_up_mock_apt_pkg()
     self.apa = AptPkgAdapter(self.mock_apt_pkg)
     self.set_up_apa()
Ejemplo n.º 16
0
	def setUp(self):
		super(TestPolicyBase, self).setUp()
		self.apt_pkg_adapter = AptPkgAdapter(self._create_mock_apt_pkg_module())
		self.apt_pkg_adapter.init()
		self.mock_facter = self._create_mock_facter('Debian')
		self.set_up_policy_creation()
Ejemplo n.º 17
0
class TestPolicyBase(test_helper.MoxTestCase):
    def _create_mock_version_adapter(self, version_string):
        if version_string == None:
            return None
        mva = self.mox.CreateMock(VersionAdapter)
        mva.files = []
        if type(version_string) == tuple:
            mva.string = version_string[0]
            for o in version_string[1]:
                mva.files.append(PackageFileAdapter(FakePackageFile(origin=o)))
        else:
            mva.string = version_string
            mva.files.append(
                PackageFileAdapter(FakePackageFile(origin='Debian')))
        return mva

    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)

    def _create_mock_config(self, hashes):
        stanzas = []
        for hash in hashes:
            stanza = ConfigStanza()
            stanza.set('package', 'apackage', 1)
            stanza.set('accept-origin', hash['accepted_origin'], 2)
            stanza.set('track-origin', hash['track_origin'], 3)
            stanza.set('track-version', hash['track_version'], 4)
            stanza.finish(4)
            stanzas.append(stanza)
        mock_config = self.struct()
        mock_config.package = lambda name: name == 'apackage' and stanzas or []
        return mock_config

    def setUp(self):
        super(TestPolicyBase, self).setUp()
        self.apt_pkg_adapter = AptPkgAdapter(
            self._create_mock_apt_pkg_module())
        self.apt_pkg_adapter.init()
        self.mock_facter = self._create_mock_facter('Debian')
        self.set_up_policy_creation()

    def set_up_policy_creation(self):
        self.policy = Policy(self.apt_pkg_adapter, self.mock_facter,
                             self._create_mock_config([]))

    def assert_should_report_yes(self,
                                 current_version,
                                 candidate_version,
                                 official_versions,
                                 package='apackage',
                                 other_versions={}):
        s = self._create_mock_status(package,
                                     current_version,
                                     candidate_version,
                                     official_versions,
                                     other_versions=other_versions)
        self.assert_(self.policy.should_report(s))

    def assert_should_report_NOT(self,
                                 current_version,
                                 candidate_version,
                                 official_versions,
                                 package='apackage',
                                 other_versions={}):
        s = self._create_mock_status(package,
                                     current_version,
                                     candidate_version,
                                     official_versions,
                                     other_versions=other_versions)
        self.assert_(not self.policy.should_report(s))

    def test_missing_version(self):
        self.mox.ReplayAll()
        self.assert_should_report_yes('2.1~1', None, ['2.1'])
        self.assert_should_report_yes(None, '2.1~1', ['2.1'])
        self.assert_should_report_yes('2.1~1', '2.1~1', [])
Ejemplo n.º 18
0
class TestIntegraton(test_helper.MoxTestCase):
	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 finishSetUp(self):
		self.apt_pkg_adapter = AptPkgAdapter(self.apt_pkg)
		self.apt_pkg_adapter.init()
		cache_adapter_factory = CacheAdapterFactory()
		self.package_adapter_factory = PackageAdapterFactory(DepCacheAdapter(self.apt_depcache))
		self.cache_adapter = self.apt_pkg_adapter.get_cache_adapter(cache_adapter_factory, self.reporter, self.mock_progress)

		config_finder = ConfigFinder('test-data/config')
		config_parser = ConfigParser()
		self.config = Config()
		for path, file in config_finder:
			config_parser.load(file, self.config)

	def test_verbose(self):
		# lib6 - never
		self.reporter.report(mox.Func(lambda o: o.package_name == 'libspf')).InAnyOrder()
		self.reporter.report(mox.Func(lambda o: o.package_name == 'libfoobar')).InAnyOrder()
		self.reporter.report(mox.Func(lambda o: o.package_name == 'git-core')).InAnyOrder()
		self.mox.ReplayAll()

		self.finishSetUp()
		checker = Checker(self.facter, True)
		policy = VerbosePolicy()
		self.cache_adapter.run(checker, policy, self.package_adapter_factory)

	def test_non_verbose_empty_config(self):
		# libc6 - never
		self.reporter.report(mox.Func(lambda o: o.package_name == 'libspf')).InAnyOrder()
		# libfoobar - never
		self.reporter.report(mox.Func(lambda o: o.package_name == 'git-core')).InAnyOrder()
		self.mox.ReplayAll()

		self.finishSetUp()
		checker = Checker(self.facter)
		policy = Policy(self.apt_pkg_adapter, self.facter, Config())
		self.cache_adapter.run(checker, policy, self.package_adapter_factory)

	def test_non_verbose(self):
		# libc6 - never
		self.reporter.report(mox.Func(lambda o: o.package_name == 'libspf'))
		# libfoobar - never
		# git-core - never
		self.mox.ReplayAll()

		self.finishSetUp()
		checker = Checker(self.facter)
		policy = Policy(self.apt_pkg_adapter, self.facter, self.config)
		self.cache_adapter.run(checker, policy, self.package_adapter_factory)