Exemplo n.º 1
0
def test_predownloaded():
    params = {
        "to": "tmpfs",
        "rootfs": {
            "url": "downloads://rootfs.xz"
        },
        "namespace": "common",
    }
    job = Job(1234, {}, None)
    destdir = job.mkdtemp("some-other-action")
    action = PreDownloadedAction("rootfs", urlparse("downloads://rootfs.xz"),
                                 destdir, params)
    action.job = job

    filename = Path(action.job.tmp_dir) / "downloads/common/rootfs.xz"
    filename.parent.mkdir(parents=True)
    filename.touch()

    action.data = {}
    action.parameters = {"namespace": "common"}
    action.validate()
    action.run(None, 4242)
    mapped_path = action.get_namespace_data(action="download-action",
                                            label="rootfs",
                                            key="file")
    assert mapped_path == (destdir + "/rootfs.xz")
    assert Path(mapped_path).exists()
Exemplo n.º 2
0
def test_predownloaded_missing_file(tmpdir):
    job = Job(1234, {}, None)
    destdir = job.mkdtemp("some-other-action")
    action = PreDownloadedAction("rootfs", urlparse("downloads://missing.xz"), destdir)
    action.job = job
    action.parameters = {"namespace": "common"}
    with pytest.raises(JobError) as exc:
        action.run(None, 4242)