Esempio n. 1
0
    def test_batch_package(self):
        cfg = self.make_empty_config(['mopack.yml'])

        metadata = commands.Metadata()
        metadata.add_package(AptPackage(
            'foo', _options=cfg.options,
            config_file=os.path.abspath('mopack.yml'),
        ))

        with mock.patch('mopack.commands.fetch', return_value=metadata), \
             mock.patch.object(AptPackage, 'resolve_all') as mresolve, \
             mock.patch.object(commands.Metadata, 'save') as msave:  # noqa
            commands.resolve(cfg, self.pkgdir)
            mresolve.assert_called_once()
            msave.assert_called_once()
Esempio n. 2
0
    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)
Esempio n. 3
0
    def test_batch_package_failure(self):
        cfg = self.make_empty_config(['mopack.yml'])

        metadata = commands.Metadata()
        metadata.add_package(AptPackage(
            'foo', _options=cfg.options,
            config_file=os.path.abspath('mopack.yml'),
        ))

        with mock.patch('mopack.commands.fetch', return_value=metadata), \
             mock.patch.object(AptPackage, 'resolve_all',
                               side_effect=RuntimeError()) as mresolve, \
             mock.patch.object(AptPackage, 'clean_post') as mclean, \
             mock.patch.object(commands.Metadata, 'save') as msave:  # noqa
            with self.assertRaises(RuntimeError):
                commands.resolve(cfg, self.pkgdir)
            mresolve.assert_called_once()
            mclean.assert_called_once()
            msave.assert_called_once()
Esempio n. 4
0
 def test_empty(self):
     with mock.patch('mopack.log.info') as mlog, \
          mock.patch.object(commands.Metadata, 'save') as msave:  # noqa
         commands.resolve(self.make_empty_config(), self.pkgdir)
         mlog.assert_called_once_with('no inputs')
         msave.assert_not_called()