Exemplo n.º 1
0
    def test_new_result_with_location_deserializes_correctly(self):
        s = state.Success(
            message="test",
            result=results.S3Result(bucket="foo", location="dir/place.txt"),
        )
        schema = StateSchema()
        new_state = schema.load(schema.dump(s))

        assert new_state.is_successful()
        assert new_state.result is None
        assert new_state._result.bucket == "foo"
        assert isinstance(new_state._result, results.S3Result)
        assert new_state._result.location == "dir/place.txt"
Exemplo n.º 2
0
    def test_cached_inputs_are_serialized_correctly(self):
        s = state.Cached(
            message="test",
            result=results.PrefectResult(value=1, location="1"),
            cached_inputs=dict(
                x=results.PrefectResult(location='"foo"'),
                y=results.PrefectResult(location='"bar"'),
            ),
        )
        schema = StateSchema()
        serialized = schema.dump(s)

        assert serialized["cached_inputs"]["x"]["location"] == '"foo"'
        assert serialized["cached_inputs"]["y"]["location"] == '"bar"'

        new_state = schema.load(serialized)

        assert new_state.cached_inputs["x"].location == '"foo"'
        assert new_state.cached_inputs["y"].location == '"bar"'
Exemplo n.º 3
0
def test_can_deserialize_old_no_result(old_json):
    schema = StateSchema()

    state = schema.load(old_json)
    assert state.is_successful()
Exemplo n.º 4
0
    def test_new_result_with_location_serializes_correctly(self):
        s = state.Success(
            message="test",
            result=results.S3Result(bucket="foo", location="dir/place.txt"),
        )
        serialized = StateSchema().dump(s)
        assert serialized["message"] == "test"
        assert serialized["_result"]["type"] == "S3Result"

    def test_new_result_with_location_deserializes_correctly(self):
        s = state.Success(
            message="test",
            result=results.S3Result(bucket="foo", location="dir/place.txt"),
        )
        schema = StateSchema()
        new_state = schema.load(schema.dump(s))

        assert new_state.is_successful()
        assert new_state.result is None
        assert new_state._result.bucket == "foo"
        assert isinstance(new_state._result, results.S3Result)
        assert new_state._result.location == "dir/place.txt"

<<<<<<< HEAD

@pytest.mark.parametrize(
    "old_json",
    [
        {
            "type": "Success",
            "_result": {"type": "NoResultType", "__version__": "0.6.0"},