コード例 #1
0
ファイル: test_spec.py プロジェクト: freyes/bundletester
    def test_deploy_cmd(self):
        model = fake_model()
        options = FakeOptions(juju_major_version=2)

        suite = spec.Suite(model, options)
        cmd = suite._deploy_cmd('foo-bundle')
        self.assertEqual(cmd, ['juju', 'deploy', 'foo-bundle'])
コード例 #2
0
ファイル: test_spec.py プロジェクト: freyes/bundletester
    def test_bundle_deploy_file(self):
        model = fake_model()

        class options(object):
            tests_yaml = None

        suite = spec.Suite(model, options)
        suite._config = config.Parser(**{'bundle_deploy': 'mydeployfile'})
        with mock.patch('bundletester.spec.os.path.isfile') as isfile, \
                mock.patch('bundletester.spec.os.access') as access:
            fullpath = os.path.join(model['testdir'],
                                    suite.config.bundle_deploy)

            def _isfile(path):
                if path == fullpath:
                    return True
                return os.path.isfile(path)

            def _access(path, flags):
                if path == fullpath:
                    return True
                return os.access(path, flags)

            isfile.side_effect = _isfile
            access.side_effect = _access
            self.assertEqual(suite.deploy_cmd(), [fullpath])
コード例 #3
0
    def test_timeout(self):
        model = models.Bundle({
            'directory': '',
            'testdir': '',
            'bundle': 'mybundle.yaml',
        })

        class options(object):
            tests_yaml = None
            verbose = True
            deployment = None

        suite = spec.Suite(model, options)
        suite._config = config.Parser(**{
            'bundle_deploy': True,
            'deployment_timeout': 60,
        })
        with mock.patch('bundletester.spec.os.path.exists') as exists:

            def _exists(path):
                if path == model['bundle']:
                    return True
                return os.path.exists(path)

            exists.side_effect = _exists
            self.assertEqual(
                suite.deploy_cmd(),
                ['juju-deployer', '-Wvd', '-c', model['bundle'], '-t', '60'])
コード例 #4
0
ファイル: test_spec.py プロジェクト: freyes/bundletester
    def test_not_bundle(self):
        model = models.Charm({'directory': '', 'testdir': ''})

        class options(object):
            tests_yaml = None

        suite = spec.Suite(model, options)
        self.assertIsNone(suite.deploy_cmd())
コード例 #5
0
ファイル: test_spec.py プロジェクト: freyes/bundletester
    def test_bundle_deploy_is_false(self):
        model = models.Bundle({'directory': '', 'testdir': ''})

        class options(object):
            tests_yaml = None

        suite = spec.Suite(model, options)
        suite._config = config.Parser(**{
            'bundle_deploy': False,
        })
        self.assertIsNone(suite.deploy_cmd())
コード例 #6
0
ファイル: test_spec.py プロジェクト: freyes/bundletester
    def test_deploy_cmd_plan_and_budget(self):
        model = fake_model()
        options = FakeOptions(juju_major_version=2)
        options.deploy_plan = 'foo'
        options.deploy_budget = 'bar'

        suite = spec.Suite(model, options)
        cmd = suite._deploy_cmd('foo-bundle')
        self.assertEqual(cmd, [
            'juju', 'deploy', 'foo-bundle', '--plan', 'foo', '--budget', 'bar'
        ])
コード例 #7
0
ファイル: test_spec.py プロジェクト: freyes/bundletester
    def test_bundle_deploy_is_true_juju_1(self):
        model = fake_model()
        options = FakeOptions(juju_major_version=1)

        suite = spec.Suite(model, options)
        suite._config = config.Parser(**{'bundle_deploy': True})
        with mock.patch('bundletester.spec.os.path.exists') as exists:

            def _exists(path):
                if path == model['bundle']:
                    return True
                return os.path.exists(path)

            exists.side_effect = _exists
            self.assertEqual(suite.deploy_cmd(),
                             ['juju-deployer', '-Wvd', '-c', model['bundle']])
コード例 #8
0
ファイル: test_spec.py プロジェクト: freyes/bundletester
    def test_timeout(self):
        model = fake_model()
        options = FakeOptions(juju_major_version=2)

        suite = spec.Suite(model, options)
        suite._config = config.Parser(**{
            'bundle_deploy': True,
            'deployment_timeout': 60,
        })
        with mock.patch('bundletester.spec.os.path.exists') as exists:

            def _exists(path):
                if path == model['bundle']:
                    return True
                return os.path.exists(path)

            exists.side_effect = _exists
            self.assertEqual(suite.deploy_cmd(),
                             ['juju', 'deploy', 'mybundle.yaml'])
            cmd = suite.wait_cmd()
            self.assertEqual(cmd, ['juju-wait', '-v', '-t', '60'])
コード例 #9
0
    def test_run_suite(self):
        logging.basicConfig(level=logging.CRITICAL)
        parser = config.Parser()
        parser.bootstrap = False
        options = O()
        options.dryrun = True
        options.environment = 'local'
        options.failfast = True
        options.tests_yaml=None
        model = models.TestDir({'name': 'testdir',
                                'directory': TEST_FILES,
                                'testdir': TEST_FILES})

        suite = spec.Suite(model, options=options)
        suite.spec(locate('test02'))
        self.assertEqual(suite[0].name, 'test02')
        run = runner.Runner(suite, options)

        results = list(run())
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['returncode'], 0)