Ejemplo n.º 1
0
    def test_custom_preprocess_multiple_commands(self, ld_mock, env_mock,
                                                 rs_mock, get_mock, pth_mock):
        self.config.custom_preprocess = ['/bin/true', '/bin/false']
        driver = GitRepoDriver(cfg_options=self.config)
        driver.preprocess(package_name='foo')

        directory = '%s/package_info/openstack/foo' % self.config.datadir

        expected = [
            mock.call([
                'DLRN_PACKAGE_NAME=foo',
                'DLRN_DISTGIT=%s' % directory,
                'DLRN_SOURCEDIR=%s/foo' % self.config.datadir,
                'DLRN_USER=myuser', '/bin/true'
            ],
                      _cwd=directory,
                      _env={'LANG': 'C'}),
            mock.call([
                'DLRN_PACKAGE_NAME=foo',
                'DLRN_DISTGIT=%s' % directory,
                'DLRN_SOURCEDIR=%s/foo' % self.config.datadir,
                'DLRN_USER=myuser', '/bin/false'
            ],
                      _cwd=directory,
                      _env={'LANG': 'C'})
        ]

        self.assertEqual(env_mock.call_args_list, expected)
        self.assertEqual(env_mock.call_count, 2)
Ejemplo n.º 2
0
    def test_custom_preprocess_multiple_commands(self, ld_mock, env_mock,
                                                 rs_mock, get_mock):
        self.config.custom_preprocess = ['/bin/true', '/bin/false']
        driver = GitRepoDriver(cfg_options=self.config)
        driver.preprocess(package_name='foo')

        directory = '%s/package_info/openstack/foo' % self.config.datadir

        expected = [mock.call(
            ['DLRN_PACKAGE_NAME=foo',
             'DLRN_DISTGIT=%s' % directory,
             'DLRN_SOURCEDIR=%s/foo' % self.config.datadir,
             'DLRN_USER=myuser',
             '/bin/true'],
            _cwd=directory,
            _env={'LANG': 'C'}),
            mock.call(
            ['DLRN_PACKAGE_NAME=foo',
             'DLRN_DISTGIT=%s' % directory,
             'DLRN_SOURCEDIR=%s/foo' % self.config.datadir,
             'DLRN_USER=myuser',
             '/bin/false'],
            _cwd=directory,
            _env={'LANG': 'C'})
            ]

        self.assertEqual(env_mock.call_args_list, expected)
        self.assertEqual(env_mock.call_count, 2)
Ejemplo n.º 3
0
 def test_getinfo_failure(self, refresh_mock, sh_mock):
     refresh_mock.return_value = [None, None, None]
     driver = GitRepoDriver(cfg_options=self.config)
     package = {'upstream': 'test', 'name': 'test'}
     info, skipped = driver.getinfo(package=package,
                                    project="test",
                                    dev_mode=True)
     self.assertEqual(info, [])
     self.assertEqual(skipped, True)
Ejemplo n.º 4
0
    def test_custom_preprocess_fail(self, ld_mock, rs_mock):
        self.config.custom_preprocess = ['/bin/nonexistingcommand']
        driver = GitRepoDriver(cfg_options=self.config)
        os.makedirs(
            os.path.join(self.config.datadir, 'package_info/openstack/foo'))

        self.assertRaises(RuntimeError, driver.preprocess, package_name='foo')
Ejemplo n.º 5
0
 def test_getpackages(self, listdir_mock, sh_mock):
     listdir_mock.return_value = []
     driver = GitRepoDriver(cfg_options=self.config)
     packages = driver.getpackages(dev_mode=True)
     self.assertEqual(packages, [])
Ejemplo n.º 6
0
 def test_getpackages(self, listdir_mock, sh_mock):
     listdir_mock.return_value = []
     driver = GitRepoDriver(cfg_options=self.config)
     packages = driver.getpackages(dev_mode=True)
     self.assertEqual(packages, [])
Ejemplo n.º 7
0
 def test_getinfo(self, refresh_mock, sh_mock):
     refresh_mock.return_value = [None, None, None]
     driver = GitRepoDriver(cfg_options=self.config)
     package = {'upstream': 'test', 'name': 'test'}
     info = driver.getinfo(package=package, project="test", dev_mode=True)
     self.assertEqual(info, [])