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 == {}
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
def test_simple_formatter_layer_name_cant_contain_separator(): f = dags.SimpleFormatter() with pytest.raises(dags.exceptions.LayerNameContainsSeparator): f.generate("foo:bar", 0)
def test_simple_formatter_can_parse_as_expected(layer, index, name): f = dags.SimpleFormatter() assert f.parse(name) == (layer, index)
def test_simple_formatter_default_args_work_as_expected(layer, index, name): f = dags.SimpleFormatter() assert f.generate(layer, index) == name
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))
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)