예제 #1
0
def test_rescue(rescue_dag, rescue_file_text):
    _rescue(rescue_dag, rescue_file_text, formatter=dags.SimpleFormatter())

    assert rescue_dag._nodes["a"].done == {0: True}
    assert rescue_dag._nodes["b"].done == {0: True}
    assert rescue_dag._nodes["c"].done == {}
    assert rescue_dag._nodes["d"].done == {}
예제 #2
0
def test_simple_formatter_with_offset_is_invertible(layer, index, name):
    f = dags.SimpleFormatter(offset=1)

    assert f.parse(f.generate(layer, index)) == (layer, index)
    assert f.generate(*f.parse(name)) == name
예제 #3
0
def test_simple_formatter_layer_name_cant_contain_separator():
    f = dags.SimpleFormatter()

    with pytest.raises(dags.exceptions.LayerNameContainsSeparator):
        f.generate("foo:bar", 0)
예제 #4
0
def test_simple_formatter_can_parse_as_expected(layer, index, name):
    f = dags.SimpleFormatter()

    assert f.parse(name) == (layer, index)
예제 #5
0
def test_simple_formatter_default_args_work_as_expected(layer, index, name):
    f = dags.SimpleFormatter()

    assert f.generate(layer, index) == name
예제 #6
0
def test_bad_index_format_raises_error(format, index):
    f = dags.SimpleFormatter(index_format=format)

    with pytest.raises(dags.exceptions.CannotInvertFormat):
        print(f.generate("layer", index))
예제 #7
0
def test_simple_formatter_layer_name_cant_contain_separator():
    f = dags.SimpleFormatter()

    with pytest.raises(dags.exceptions.LayerNameContainsSeparator):
        f.generate("foo{}bar".format(dags.DEFAULT_SEPARATOR), 0)