Пример #1
0
class Test_ConfigParser(test_helper.MoxTestCase):
    def setUp(self):
        super(Test_ConfigParser, self).setUp()
        self.cp = ConfigParser()
        self.c = self.mox.CreateMock(Config)

    def test_loading_empty_file(self):
        self.mox.ReplayAll()
        self.assertEquals(self.cp.load([], self.c), [])

    def test_loading_invalid_syntax_file(self):
        fake_file = ['\n', 'invalid line\n']
        self.mox.ReplayAll()
        self.assertRaisesWithMessageContaining(Exception, 'line 2',
                                               self.cp.load, fake_file)

    def test_loading_invalid_stanza_file(self):
        fake_file = ['\n', 'package:val\n', 'acCepT-OrigiN: val2\n']
        self.mox.ReplayAll()
        self.assertRaisesWithMessageContaining(Exception, 'line 3',
                                               self.cp.load, fake_file)

    def test_loading_valid_file(self):
        fake_file = [
            '\n', 'package:val\n', 'acCepT-OrigiN: val2\n',
            ' track-oriGin : a  spaced val \n', 'track-version:foo'
        ]
        self.c.add(mox.Func(lambda stanza: stanza.get('package') == 'val'))
        self.mox.ReplayAll()

        ret = self.cp.load(fake_file, self.c)
        self.assertEquals(len(ret), 1)
        self.assertEquals(ret[0].get('package'), 'val')
Пример #2
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)
Пример #3
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)
Пример #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)
Пример #5
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)
Пример #6
0
class Test_ConfigParser(test_helper.MoxTestCase):
	def setUp(self):
		super(Test_ConfigParser, self).setUp()
		self.cp = ConfigParser()
		self.c = self.mox.CreateMock(Config)
	def test_loading_empty_file(self):
		self.mox.ReplayAll()
		self.assertEquals(self.cp.load([], self.c), [])
	def test_loading_invalid_syntax_file(self):
		fake_file = ['\n', 'invalid line\n']
		self.mox.ReplayAll()
		self.assertRaisesWithMessageContaining(Exception, 'line 2', self.cp.load, fake_file)
	def test_loading_invalid_stanza_file(self):
		fake_file = ['\n', 'package:val\n', 'acCepT-OrigiN: val2\n']
		self.mox.ReplayAll()
		self.assertRaisesWithMessageContaining(Exception, 'line 3', self.cp.load, fake_file)
	def test_loading_valid_file(self):
		fake_file = ['\n', 'package:val\n', 'acCepT-OrigiN: val2\n', ' track-oriGin : a  spaced val \n', 'track-version:foo']
		self.c.add(mox.Func(lambda stanza: stanza.get('package') == 'val'))
		self.mox.ReplayAll()

		ret = self.cp.load(fake_file, self.c)
		self.assertEquals(len(ret), 1)
		self.assertEquals(ret[0].get('package'), 'val')
Пример #7
0
 def setUp(self):
     super(Test_ConfigParser, self).setUp()
     self.cp = ConfigParser()
     self.c = self.mox.CreateMock(Config)
Пример #8
0
	def setUp(self):
		super(Test_ConfigParser, self).setUp()
		self.cp = ConfigParser()
		self.c = self.mox.CreateMock(Config)