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