コード例 #1
0
def test_ok_include_key_not_found(server, client, tmp_path, capsys):
    server.data = {"script": [{"include": "second-script"},
                              "install package xxx"]}

    result = zebr0_script.recursive_fetch_script(client, "script", tmp_path)
    assert list(result) == [({"command": "install package xxx", "variant": ""}, zebr0_script.Status.PENDING, tmp_path.joinpath("93d0bf66c73d281fa4d42949bfd05b8b"))]
    assert capsys.readouterr().out == "key 'second-script' not found on server http://localhost:8000\n"
コード例 #2
0
def test_ok_status_unknown(server, client, tmp_path, capsys):
    report_path = tmp_path.joinpath("04e6dca9feed2a2f0858e9d0e1d6dd63")
    report_path.write_text('{"status": "unknown"}')

    server.data = {"script": ["install package yyy"]}

    result = zebr0_script.recursive_fetch_script(client, "script", tmp_path)
    assert list(result) == [({"command": "install package yyy", "variant": ""}, "unknown", report_path)]
    assert capsys.readouterr().out == ""
コード例 #3
0
def test_ok_status_success(server, client, tmp_path, capsys):
    report_path = tmp_path.joinpath("93d0bf66c73d281fa4d42949bfd05b8b")
    report_path.write_text('{"status": "success"}')

    server.data = {"script": ["install package xxx"]}

    result = zebr0_script.recursive_fetch_script(client, "script", tmp_path)
    assert list(result) == [({"command": "install package xxx", "variant": ""}, zebr0_script.Status.SUCCESS, report_path)]
    assert capsys.readouterr().out == ""
コード例 #4
0
def test_ok(server, tmp_path, client, capsys):
    server.data = {"script": ["install package xxx",
                              {"key": "configuration-file", "target": "/etc/xxx/conf.ini"},
                              "chmod 400 /etc/xxx/conf.ini",
                              "hot reload",
                              {"include": "second-script"},
                              {"command": "hot reload", "variant": "after second script"},
                              {"make-coffee": "black"}],
                   "second-script": ["install package yyy",
                                     "yyy configure network"]}

    result = zebr0_script.recursive_fetch_script(client, "script", tmp_path)
    assert list(result) == [({"command": "install package xxx", "variant": ""}, zebr0_script.Status.PENDING, tmp_path.joinpath("93d0bf66c73d281fa4d42949bfd05b8b")),
                            ({"key": "configuration-file", "target": "/etc/xxx/conf.ini"}, zebr0_script.Status.PENDING, tmp_path.joinpath("c065878911c6b3beee171d12fed19aa2")),
                            ({"command": "chmod 400 /etc/xxx/conf.ini", "variant": ""}, zebr0_script.Status.PENDING, tmp_path.joinpath("33d920996bf315e6c81dc2a0d1608d77")),
                            ({"command": "hot reload", "variant": ""}, zebr0_script.Status.PENDING, tmp_path.joinpath("3f0d1217bf8d9f34721b0ed0c55d62ac")),
                            ({"command": "install package yyy", "variant": ""}, zebr0_script.Status.PENDING, tmp_path.joinpath("04e6dca9feed2a2f0858e9d0e1d6dd63")),
                            ({"command": "yyy configure network", "variant": ""}, zebr0_script.Status.PENDING, tmp_path.joinpath("be4631e9648899e6b0f2ceb8b4b39e38")),
                            ({"command": "hot reload", "variant": "after second script"}, zebr0_script.Status.PENDING, tmp_path.joinpath("bbbe6361831c7a84d4ff188cc4c9142b"))]
    assert capsys.readouterr().out == 'malformed task, ignored: {"make-coffee": "black"}\n'
コード例 #5
0
def test_ko_key_not_found(server, client, tmp_path, capsys):
    server.data = {}

    assert list(zebr0_script.recursive_fetch_script(client, "script", tmp_path)) == []
    assert capsys.readouterr().out == "key 'script' not found on server http://localhost:8000\n"
コード例 #6
0
def test_ko_not_a_script(server, client, tmp_path, capsys):
    server.data = {"script": "not a script"}

    assert list(zebr0_script.recursive_fetch_script(client, "script", tmp_path)) == []
    assert capsys.readouterr().out == "key 'script' on server http://localhost:8000 is not a proper yaml or json list\n"