예제 #1
0
def test_add_flow_raises_if_name_conflict():
    storage = Bytes()
    f = Flow("test")
    res = storage.add_flow(f)
    g = Flow("test")
    with pytest.raises(ValueError, match='name "test"'):
        storage.add_flow(g)
예제 #2
0
def test_build_returns_self():
    s = Bytes()
    assert s.build() is s

    f = Flow("test")
    s.add_flow(f)
    assert s.build() is s
예제 #3
0
def test_add_flow_raises_if_name_conflict():
    storage = Bytes()
    f = Flow("test")
    res = storage.add_flow(f)
    g = Flow("test")
    with pytest.raises(ValueError) as exc:
        storage.add_flow(g)
    assert 'name "test"' in str(exc.value)
예제 #4
0
def test_containment():
    s = Bytes()
    f = Flow("test")
    s.add_flow(f)

    assert True not in s
    assert f not in s
    assert "test" in s
    assert Flow("other") not in s
    assert "other" not in s
예제 #5
0
def test_get_runner_returns_flow_or_flow_runner_responds_to_config():
    s = Bytes()
    f = Flow("test")
    s.add_flow(f)

    with set_temporary_config(
        {"engine.flow_runner.default_class": CloudFlowRunner}):
        runner = s.get_runner("test", return_flow=False)
        assert isinstance(runner, CloudFlowRunner)
        assert runner.flow == f
예제 #6
0
def test_add_flow_to_storage():
    storage = Bytes()
    f = Flow("test")
    assert f.name not in storage
    res = storage.add_flow(f)
    assert res == "test"
    assert f.name in storage
예제 #7
0
def test_multiple_flows_in_storage():
    s = Bytes()
    f = Flow("test")
    g = Flow("other")
    z = Flow("not")
    s.add_flow(f)
    s.add_flow(g)

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

    assert s.get_flow("test") == f
    assert s.get_flow("other") == g

    assert isinstance(s.flows["test"], bytes)
    assert isinstance(s.flows["other"], bytes)
예제 #8
0
def test_get_flow_returns_flow():
    s = Bytes()
    f = Flow("test")
    s.add_flow(f)
    runner = s.get_flow("test")
    assert runner == f