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
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)
def test_int_values(): env = load_configuration(TEST_YAML) assert env['api_version'] == 1
def test_recursive_replace_nested_complex(): env = load_configuration(TEST_YAML) assert env['clients']['ios']['auth'] == "uat.urltest.net/auth"
def test_recursive_replace_nested_simple(): env = load_configuration(TEST_YAML) assert env['clients']['ios']['provision'] == "mycarrier.uat.urltest.net"
def test_recursive_replace_boolean_values(): env = load_configuration(TEST_YAML) assert env['features']['contacts'] is True assert env['features']['backup'] is False
def test_recursive_replace_with_keywords(): env = load_configuration(TEST_YAML, {'environment': 'dev'}) assert env['url'] == "mycarrier.localhost"
def test_recursive_replace(): env = load_configuration(TEST_YAML) assert env['url'] == "mycarrier.uat.urltest.net"