예제 #1
0
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")
예제 #2
0
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
예제 #3
0
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"
예제 #4
0
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'
예제 #5
0
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
예제 #6
0
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')
예제 #7
0
def test_empty_config():
    with temporary_file() as fp:
        fp.flush()
        AuroraConfigLoader.load(fp.name)
예제 #8
0
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)
예제 #9
0
def test_enoent():
    nonexistent_file = tempfile.mktemp()
    with pytest.raises(AuroraConfigLoader.NotFound):
        AuroraConfigLoader.load(nonexistent_file)
예제 #10
0
def test_empty_config():
    with temporary_file() as fp:
        fp.flush()
        AuroraConfigLoader.load(fp.name)
예제 #11
0
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)
예제 #12
0
def test_enoent():
    nonexistent_file = tempfile.mktemp()
    with pytest.raises(AuroraConfigLoader.NotFound):
        AuroraConfigLoader.load(nonexistent_file)