def test_to_native_with_value_field():
    """
    When a DictField has an value-field, to_native should return a dict of elements resulting from
    the application of the value-field's to_native method to each value of the input object dict.
    """
    field = DictField(DateField(format=ISO_8601))
    obj = {"a": date(2000, 1, 1), "b": date(2000, 1, 2)}
    data = field.to_native(obj)
    assert {"a": "2000-01-01", "b": "2000-01-02"} == data
def test_to_native_no_value_field():
    """
    When a DictField has no value-field, to_native should return the data it was given
    un-processed.
    """
    field = DictField()
    obj = {"a": 1, "b": 2}
    data = field.to_native(obj)
    assert obj == data
예제 #3
0
 def test_to_native_no_value_field(self):
     """
     When a DictField has no value-field, to_native should return the data it was given
     un-processed.
     """
     field = DictField()
     obj = {"a": 1, "b": 2}
     data = field.to_native(obj)
     self.assertEqual(obj, data)
예제 #4
0
 def test_to_native_with_value_field(self):
     """
     When a DictField has an value-field, to_native should return a dict of elements resulting
     from the application of the value-field's to_native method to each value of the input
     object dict.
     """
     field = DictField(DateField(format=ISO_8601))
     obj = {"a": date(2000, 1, 1), "b": date(2000, 1, 2)}
     data = field.to_native(obj)
     self.assertEqual({"a": "2000-01-01", "b": "2000-01-02"}, data)