Exemple #1
0
def test_add_flow_to_github_already_added():
    storage = GitHub(repo="test/repo", path="flow.py")

    f = Flow("test")
    assert f.name not in storage
    assert storage.add_flow(f) == "flow.py"
    assert f.name in storage

    with pytest.raises(ValueError):
        storage.add_flow(f)
Exemple #2
0
def test_add_flow_to_github_storage():
    storage = GitHub(repo="test/repo", path="flow.py")

    f = Flow("test")
    assert f.name not in storage
    assert storage.add_flow(f) == "flow.py"
    assert f.name in storage
Exemple #3
0
def test_get_flow_github(monkeypatch):
    f = Flow("test")

    github = MagicMock()
    monkeypatch.setattr("prefect.utilities.git.Github", github)

    monkeypatch.setattr(
        "prefect.environments.storage.github.extract_flow_from_file",
        MagicMock(return_value=f),
    )

    with pytest.raises(ValueError):
        storage = GitHub(repo="test/repo")
        storage.get_flow()

    storage = GitHub(repo="test/repo", path="flow")

    assert f.name not in storage
    flow_location = storage.add_flow(f)

    new_flow = storage.get_flow(flow_location)
    assert new_flow.run()