Beispiel #1
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'])
Beispiel #2
0
    def test_bundle_deploy_file(self):
        model = models.Bundle({
            'directory': '',
            'testdir': 'tests',
            'bundle': 'mybundle.yaml',
        })

        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])
Beispiel #3
0
def BundleClassifier(directory, options):
    bundle = find_bundle_file(directory, options.bundle)
    if not bundle:
        return None
    return models.Bundle({
        'bundle': bundle,
        'testdir': utils.find_testdir(directory),
        'name': 'bundle',
    })
Beispiel #4
0
    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())
Beispiel #5
0
def BundleClassifier(directory, options):
    bundle = find_bundle_file(directory, options.bundle)
    if not bundle:
        return None
    result = {'bundle': bundle, 'testdir': utils.find_testdir(directory)}
    lp = vcs.Launchpad()
    data = lp.infer_bundle(directory) or {}
    result.update(data)
    if 'name' not in data:
        with open(bundle) as fh:
            metadata = yaml.safe_load(fh)
        # XXX: ambiguous
        result['name'] = metadata.keys()[0]
    return models.Bundle(**result)
Beispiel #6
0
def fake_model():
    return models.Bundle({
        'directory': '',
        'testdir': '',
        'bundle': 'mybundle.yaml',
    })