예제 #1
0
def test_serialise_invalid_version(gitlab_api):
    runner = Runner.register("https://gitlab.cern.ch", gitlab_api.token)
    serialised_runner = json.loads(runner.dumps())
    serialised_runner[0] = 2
    as_string = json.dumps(serialised_runner)

    with pytest.raises(ValueError):
        Runner.loads(as_string)

    with tempfile.NamedTemporaryFile(mode="wt") as fp:
        json.dump(as_string, fp)
        fp.flush()
        with pytest.raises(ValueError):
            Runner.load(fp.name)
예제 #2
0
def test_serialise(gitlab_api):
    runner = Runner.register(
        "https://gitlab.cern.ch",
        gitlab_api.token,
        name="The runner name",
        description="The runner description",
        active=True,
        locked=False,
        run_untagged=True,
        tags=["dirac", "docker", "cvmfs"],
        maximum_timeout=24 * 60 * 60,
        version="1.0",
        revision="a94b1e",
        platform="linux",
        architecture="x86_64",
        executor="dirac",
    )

    as_string = runner.dumps()
    runner_from_string = Runner.loads(as_string)
    assert runner == runner_from_string

    with tempfile.NamedTemporaryFile() as fp:
        runner.dump(fp.name)
        runner_from_file = Runner.load(fp.name)
    assert runner == runner_from_file