Beispiel #1
0
def test_bool_value_to_python():
    # This path can never run in the current configuration because proto
    # values are the only thing ever saved, and `to_python` is a read method.
    #
    # However, we test idempotency for consistency with `to_proto` and
    # general resiliency.
    marshal = BaseMarshal()
    assert marshal.to_python(wrappers_pb2.BoolValue, True) is True
    assert marshal.to_python(wrappers_pb2.BoolValue, False) is False
    assert marshal.to_python(wrappers_pb2.BoolValue, None) is None
def test_timestamp_to_python_idempotent():
    # This path can never run in the current configuration because proto
    # values are the only thing ever saved, and `to_python` is a read method.
    #
    # However, we test idempotency for consistency with `to_proto` and
    # general resiliency.
    marshal = BaseMarshal()
    py_value = "f.b.d,f.c"
    assert marshal.to_python(field_mask_pb2.FieldMask, py_value) is py_value
def test_duration_to_python_idempotent():
    # This path can never run in the current configuration because proto
    # values are the only thing ever saved, and `to_python` is a read method.
    #
    # However, we test idempotency for consistency with `to_proto` and
    # general resiliency.
    marshal = BaseMarshal()
    py_value = timedelta(seconds=240)
    assert marshal.to_python(duration_pb2.Duration, py_value) is py_value
def test_timestamp_to_python_idempotent():
    # This path can never run in the current configuration because proto
    # values are the only thing ever saved, and `to_python` is a read method.
    #
    # However, we test idempotency for consistency with `to_proto` and
    # general resiliency.
    marshal = BaseMarshal()
    py_value = DatetimeWithNanoseconds(2012, 4, 21, 15, tzinfo=timezone.utc)
    assert marshal.to_python(timestamp_pb2.Timestamp, py_value) is py_value