Beispiel #1
0
def test_deserialize_edge():
    t1, t2 = Task("t1"), Task("t2")
    serialized = EdgeSchema().dump(Edge(t1, t2, key="x", mapped=True))
    deserialized = EdgeSchema().load(serialized)
    assert isinstance(deserialized, Edge)
    assert deserialized.key == "x"
    assert deserialized.mapped is True
Beispiel #2
0
def test_deserialize_edge_has_no_task_info():
    """
    Edges only serialize task slugs, so the task names will revert to default.
    """
    t1, t2 = Task("t1"), Task("t2")
    serialized = EdgeSchema().dump(Edge(t1, t2, key="x", mapped=True))
    deserialized = EdgeSchema().load(serialized)

    assert deserialized.upstream_task.name == "Task"
    assert deserialized.downstream_task.name == "Task"
Beispiel #3
0
def test_deserialize_edge_uses_task_cache():
    """
    If a Task Cache is available, the task attributes will use it
    """
    t1, t2 = Task("t1"), Task("t2")
    context = dict(task_cache={t1.slug: t1, t2.slug: t2})
    serialized = EdgeSchema().dump(Edge(t1, t2, key="x", mapped=True))
    deserialized = EdgeSchema(context=context).load(serialized)

    assert deserialized.upstream_task is t1
    assert deserialized.downstream_task is t2
Beispiel #4
0
def test_serialize_edge_only_records_task_slug():
    t1, t2 = Task("t1"), Task("t2")
    serialized = EdgeSchema().dump(Edge(t1, t2, key="x", mapped=True))
    assert serialized["upstream_task"] == {
        "slug": t1.slug,
        "__version__": prefect.__version__,
    }
    assert serialized["downstream_task"] == {
        "slug": t2.slug,
        "__version__": prefect.__version__,
    }
Beispiel #5
0
def test_serialize_edge():
    assert isinstance(EdgeSchema().dump(Edge(Task(), Task())), dict)
Beispiel #6
0
def test_deserialize_empty_dict_without_create_object():
    t = EdgeSchema().load({}, create_object=False)
Beispiel #7
0
def test_deserialize_empty_dict_fails():
    with pytest.raises(TypeError) as exc:
        EdgeSchema().load({})
    assert "required positional arguments" in str(exc).lower()
Beispiel #8
0
def test_serialize_empty_dict():
    assert EdgeSchema().dump({})
Beispiel #9
0
def test_deserialize_empty_dict_fails():
    with pytest.raises(TypeError, match="required positional arguments"):
        EdgeSchema().load({})