def test_builder_types(self): pkg = DirectoryPackage('foo', path=self.srcpath, build='bfg9000', _options=self.make_options(), config_file=self.config_file) self.assertEqual(pkg.builder_types, ['bfg9000']) pkg = DirectoryPackage('foo', path=self.srcpath, _options=self.make_options(), config_file=self.config_file) with self.assertRaises(ConfigurationError): pkg.builder_types
def test_builder_options(self): data = dedent(""" options: builders: bfg9000: toolchain: toolchain.bfg goat: sound: baah packages: foo: source: apt bar: source: directory path: /path/to/src build: bfg9000 """) files = {'mopack.yml': data} with mock.patch('builtins.open', mock_open_files(files)): cfg = Config(['mopack.yml']) cfg.finalize() opts = Options.default() opts.add('builders', 'bfg9000') opts.builders['bfg9000'].toolchain = os.path.abspath('toolchain.bfg') self.assertEqual(cfg.options, opts) pkg1 = AptPackage('foo', _options=opts, config_file='mopack.yml') pkg2 = DirectoryPackage('bar', path=normpath('/path/to/src'), build='bfg9000', _options=opts, config_file='mopack.yml') self.assertEqual(list(cfg.packages.items()), [('foo', pkg1), ('bar', pkg2)])
def test_package(self): cfg = self.make_empty_config(['mopack.yml']) metadata = commands.Metadata() metadata.add_package(DirectoryPackage( 'foo', path='path', build='none', usage='pkg_config', _options=cfg.options, config_file=os.path.abspath('mopack.yml'), )) with mock.patch('mopack.commands.fetch', return_value=metadata), \ mock.patch.object(DirectoryPackage, 'resolve') as mresolve, \ mock.patch.object(commands.Metadata, 'save') as msave: # noqa commands.resolve(cfg, self.pkgdir) mresolve.assert_called_once() self.assertEqual(msave.call_count, 2)
def test_rehydrate(self): opts = self.make_options() pkg = DirectoryPackage('foo', path=self.srcpath, build='bfg9000', _options=opts, config_file=self.config_file) data = through_json(pkg.dehydrate()) self.assertNotIn('pending_usage', data) self.assertEqual(pkg, Package.rehydrate(data, _options=opts)) pkg = DirectoryPackage('foo', path=self.srcpath, _options=opts, config_file=self.config_file) with self.assertRaises(ConfigurationError): data = pkg.dehydrate()
def test_builder_options(self): data = dedent(""" options: builders: bfg9000: toolchain: toolchain.bfg goat: sound: baah packages: foo: source: apt bar: source: directory path: /path/to/src build: bfg9000 """) files = {'mopack.yml': '', 'mopack-child.yml': data} with mock.patch('builtins.open', mock_open_files(files)): parent = Config(['mopack.yml']) with mock.patch('builtins.open', mock_open_files(files)): child = ChildConfig(['mopack-child.yml'], parent=parent) parent.add_children([child]) parent.finalize() opts = Options.default() opts.add('builders', 'bfg9000') self.assertEqual(parent.options, opts) pkg1 = AptPackage('foo', _options=opts, config_file='mopack.yml') pkg2 = DirectoryPackage('bar', path=normpath('/path/to/src'), build='bfg9000', _options=opts, config_file='mopack.yml') self.assertEqual(list(parent.packages.items()), [('foo', pkg1), ('bar', pkg2)])