def test_load_json(): with temporary_file() as fp: fp.write(MESOS_CONFIG) fp.flush() env = AuroraConfigLoader.load(fp.name) job = env["jobs"][0] with temporary_file() as fp: fp.write(json.dumps(job.get())) fp.flush() new_job = AuroraConfigLoader.load_json(fp.name) assert new_job == job
def test_load_json(): with temporary_file() as fp: fp.write(MESOS_CONFIG) fp.flush() env = AuroraConfigLoader.load(fp.name) job = env['jobs'][0] with temporary_file() as fp: fp.write(json.dumps(job.get())) fp.flush() new_job = AuroraConfigLoader.load_json(fp.name) assert new_job == job
def test_pick(): with temporary_file() as fp: fp.write(MESOS_CONFIG) fp.flush() env = AuroraConfigLoader.load(fp.name) hello_world = env["jobs"][0] assert AuroraConfig.pick(env, "hello_world", None) == hello_world env["jobs"][0] = env["jobs"][0](name="something_{{else}}") assert str(AuroraConfig.pick(env, "something_else", [{"else": "else"}]).name()) == ("something_else")
def test_load(): with temporary_file() as fp: fp.write(MESOS_CONFIG) fp.flush() fp.seek(0) for config in (fp.name, fp): env = AuroraConfigLoader.load(config) assert "jobs" in env and len(env["jobs"]) == 1 hello_world = env["jobs"][0] assert hello_world.name().get() == "hello_world"
def test_load(): with temporary_file() as fp: fp.write(MESOS_CONFIG) fp.flush() fp.seek(0) for config in (fp.name, fp): env = AuroraConfigLoader.load(config) assert 'jobs' in env and len(env['jobs']) == 1 hello_world = env['jobs'][0] assert hello_world.name().get() == 'hello_world'
def test_pick(): with temporary_file() as fp: fp.write(MESOS_CONFIG) fp.flush() env = AuroraConfigLoader.load(fp.name) hello_world = env['jobs'][0] assert AuroraConfig.pick(env, 'hello_world', None) == hello_world env['jobs'][0] = env['jobs'][0](name='something_{{else}}') assert str( AuroraConfig.pick(env, 'something_else', [{ 'else': 'else' }]).name()) == ('something_else')
def test_empty_config(): with temporary_file() as fp: fp.flush() AuroraConfigLoader.load(fp.name)
def test_bad_config(): with temporary_file() as fp: fp.write(BAD_MESOS_CONFIG) fp.flush() with pytest.raises(AuroraConfigLoader.InvalidConfigError): AuroraConfigLoader.load(fp.name)
def test_enoent(): nonexistent_file = tempfile.mktemp() with pytest.raises(AuroraConfigLoader.NotFound): AuroraConfigLoader.load(nonexistent_file)