Esempio n. 1
0
def load_configuration(yaml_string, kw=None, missing_fmt=None):
    environ = rec_env.load_configuration(yaml_string, kw, missing_fmt)
    environ = update_model_type(environ)

    #if environ.get('API', 0) != API_VERSION:
    #    print fc.red('Error: Configuration outdated')
    #    ref = yaml.safe_load(
    #      os.path.join(os.path.dirname(__file__), 'api.yaml'))
    #    report_differences(environ, ref)
    #    raise APIVersionException

    if 'ensemble' in environ:
        environs = []
        ensemble = environ['ensemble']
        environ.pop('ensemble')
        for member in ensemble.keys():
            new_env = update_environ(environ, ensemble, member)
            new_env = update_model_type(environ)
            environs.append(new_env)

        # TODO: ignoring for now, but need to think on how to run
        # multiple environs (one for each ensemble member).
        # Maybe use the Fabric JobQueue, which abstracts
        # multiprocessing?

    return environ
Esempio n. 2
0
def load_configuration(yaml_string, kw=None, missing_fmt=None):
    environ = rec_env.load_configuration(yaml_string, kw, missing_fmt)
    environ = update_model_type(environ)

    #if environ.get('API', 0) != API_VERSION:
    #    print fc.red('Error: Configuration outdated')
    #    ref = yaml.safe_load(
    #      os.path.join(os.path.dirname(__file__), 'api.yaml'))
    #    report_differences(environ, ref)
    #    raise APIVersionException

    if 'ensemble' in environ:
        environs = []
        ensemble = environ['ensemble']
        environ.pop('ensemble')
        for member in ensemble.keys():
            new_env = update_environ(environ, ensemble, member)
            new_env = update_model_type(environ)
            environs.append(new_env)

        # TODO: ignoring for now, but need to think on how to run
        # multiple environs (one for each ensemble member).
        # Maybe use the Fabric JobQueue, which abstracts
        # multiprocessing?

    return environ
Esempio n. 3
0
def test_recursive_circular_variables():
    # Notice: if this fails we probably made an AI or a parallel universe.
    with pytest.raises(RuntimeError):
        env = load_configuration(CIRCULAR_YAML)
Esempio n. 4
0
def test_int_values():
    env = load_configuration(TEST_YAML)
    assert env['api_version'] == 1
Esempio n. 5
0
def test_recursive_replace_nested_complex():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['auth'] == "uat.urltest.net/auth"
Esempio n. 6
0
def test_recursive_replace_nested_simple():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['provision'] == "mycarrier.uat.urltest.net"
Esempio n. 7
0
def test_recursive_replace_boolean_values():
    env = load_configuration(TEST_YAML)
    assert env['features']['contacts'] is True
    assert env['features']['backup'] is False
Esempio n. 8
0
def test_recursive_replace_with_keywords():
    env = load_configuration(TEST_YAML, {'environment': 'dev'})
    assert env['url'] == "mycarrier.localhost"
Esempio n. 9
0
def test_recursive_replace():
    env = load_configuration(TEST_YAML)
    assert env['url'] == "mycarrier.uat.urltest.net"
Esempio n. 10
0
def test_recursive_circular_variables():
    # Notice: if this fails we probably made an AI or a parallel universe.
    with pytest.raises(RuntimeError):
        env = load_configuration(CIRCULAR_YAML)
Esempio n. 11
0
def test_int_values():
    env = load_configuration(TEST_YAML)
    assert env['api_version'] == 1
Esempio n. 12
0
def test_recursive_replace_nested_complex():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['auth'] == "uat.urltest.net/auth"
Esempio n. 13
0
def test_recursive_replace_nested_simple():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['provision'] == "mycarrier.uat.urltest.net"
Esempio n. 14
0
def test_recursive_replace_boolean_values():
    env = load_configuration(TEST_YAML)
    assert env['features']['contacts'] is True
    assert env['features']['backup'] is False
Esempio n. 15
0
def test_recursive_replace_with_keywords():
    env = load_configuration(TEST_YAML, {'environment': 'dev'})
    assert env['url'] == "mycarrier.localhost"
Esempio n. 16
0
def test_recursive_replace():
    env = load_configuration(TEST_YAML)
    assert env['url'] == "mycarrier.uat.urltest.net"