Ejemplo n.º 1
0
 def test_new_result_with_no_location_serializes_correctly(self):
     s = state.Success(message="test",
                       result=results.S3Result(bucket="foo"))
     serialized = StateSchema().dump(s)
     assert serialized["message"] == "test"
     assert serialized["_result"]["type"] == "S3Result"
     assert serialized["_result"]["location"] is None
Ejemplo n.º 2
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"
Ejemplo n.º 3
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"
Ejemplo n.º 4
0
def test_s3_result():
    schema = StateResultSchema()
    result = results.S3Result(value=42, bucket="foo", location="bar")
    serialized = schema.dump(result)

    assert serialized["type"] == "S3Result"
    assert serialized["location"] == "bar"

    new_result = schema.load(serialized)
    assert isinstance(new_result, results.S3Result)
    assert new_result.bucket == "foo"
    assert new_result.location == "bar"
    assert new_result.value is None
Ejemplo n.º 5
0
 def test_new_result_with_location_deserializes_correctly(self):
     s = state.Success(
         message="test",
         result=results.S3Result(bucket="foo", location="dir/place.txt"),
     )
Ejemplo n.º 6
0
 def test_new_result_with_no_location_serializes_as_no_result(self):
     s = state.Success(message="test", result=results.S3Result(bucket="foo"))