示例#1
0
def test_get_flow_returns_flow():
    with tempfile.TemporaryDirectory() as tmpdir:
        storage = Local(directory=tmpdir)
        f = Flow("test")
        loc = storage.add_flow(f)
        runner = storage.get_flow(loc)
        assert runner == f
示例#2
0
def test_get_flow_from_file_returns_flow(tmpdir):
    contents = """from prefect import Flow\nf=Flow('test-flow')"""

    full_path = os.path.join(tmpdir, "flow.py")

    with open(full_path, "w") as f:
        f.write(contents)

    f = Flow("test-flow")
    storage = Local(stored_as_script=True, path=full_path)
    storage.add_flow(f)

    flow = storage.get_flow(full_path)
    assert flow.run()
示例#3
0
def test_multiple_flows_in_storage():
    with tempfile.TemporaryDirectory() as tmpdir:
        s = Local(directory=tmpdir)
        f = Flow("test")
        g = Flow("other")
        z = Flow("not")
        f_loc = s.add_flow(f)
        g_loc = s.add_flow(g)

        assert "test" in s
        assert "other" in s
        assert "not" not in s

        assert s.get_flow(f_loc) == f
        assert s.get_flow(g_loc) == g

        assert s.flows["test"] == f_loc
        assert s.flows["other"] == g_loc
示例#4
0
def test_get_flow_raises_if_flow_not_present():
    s = Local()
    with pytest.raises(ValueError):
        s.get_flow("test")