Exemplo 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
Exemplo 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
Exemplo 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)
Exemplo n.º 4
0
def test_int_values():
    env = load_configuration(TEST_YAML)
    assert env['api_version'] == 1
Exemplo n.º 5
0
def test_recursive_replace_nested_complex():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['auth'] == "uat.urltest.net/auth"
Exemplo n.º 6
0
def test_recursive_replace_nested_simple():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['provision'] == "mycarrier.uat.urltest.net"
Exemplo 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
Exemplo n.º 8
0
def test_recursive_replace_with_keywords():
    env = load_configuration(TEST_YAML, {'environment': 'dev'})
    assert env['url'] == "mycarrier.localhost"
Exemplo n.º 9
0
def test_recursive_replace():
    env = load_configuration(TEST_YAML)
    assert env['url'] == "mycarrier.uat.urltest.net"
Exemplo 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)
Exemplo n.º 11
0
def test_int_values():
    env = load_configuration(TEST_YAML)
    assert env['api_version'] == 1
Exemplo n.º 12
0
def test_recursive_replace_nested_complex():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['auth'] == "uat.urltest.net/auth"
Exemplo n.º 13
0
def test_recursive_replace_nested_simple():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['provision'] == "mycarrier.uat.urltest.net"
Exemplo 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
Exemplo n.º 15
0
def test_recursive_replace_with_keywords():
    env = load_configuration(TEST_YAML, {'environment': 'dev'})
    assert env['url'] == "mycarrier.localhost"
Exemplo n.º 16
0
def test_recursive_replace():
    env = load_configuration(TEST_YAML)
    assert env['url'] == "mycarrier.uat.urltest.net"