Esempio n. 1
0
def test_ensure_keys():
    sample_config_file = "conf/sample-team-conf.yaml"
    ozy_conf = parse_ozy_conf(sample_config_file)

    tmp_ozy_conf = ozy_conf.copy()
    del tmp_ozy_conf['templates']['hashicorp']['type']
    config = resolve(ozy_conf['apps']['nomad'], ozy_conf['templates'])
    assert config
    with pytest.raises(OzyError):
        ensure_keys('nomad', config, 'type')
Esempio n. 2
0
 def __init__(self, name, root_config):
     self._name = name
     self._root_config = root_config
     self._config = resolve(root_config['apps'][name], self._root_config.get('templates', {}))
     self._executable_path = self._config.get('executable_path', self.name)
     self._relocatable = self._config.get('relocatable', True)
     self._post_install = fixup_post_install(self._config.get('post_install', []))
     self._version, install_type = ensure_keys(name, self._config, 'version', 'type')
     if install_type not in SUPPORTED_INSTALLERS:
         raise OzyError(f"Unsupported installation type '{install_type}'")
     self._installer = SUPPORTED_INSTALLERS[install_type](name, self._config)
Esempio n. 3
0
def test_resolve():
    sample_config_file = "conf/sample-team-conf.yaml"
    ozy_conf = parse_ozy_conf(sample_config_file)
    templates = ozy_conf['templates']
    config = ozy_conf['apps']['nomad']

    with pytest.raises(OzyError):
        bad_templates = templates.copy()
        del bad_templates['hashicorp']
        resolve(config, bad_templates)

    # with a version check turned on, the below 3 LOC will verify that flipping config and template is caught.
    # try intentionally switching them
    # with pytest.raises(OzyError):
    #    resolve(config=templates, templates=config)

    good_resolved = resolve(config, templates)
    assert 'url' in good_resolved
    assert 'template' in good_resolved
    assert 'type' in good_resolved
    assert 'app_name' in good_resolved
    assert 'version' in good_resolved
    assert 'sha256' in good_resolved
    assert 'sha256_gpg_key' in good_resolved