Пример #1
0
 def test_key_dict_multiple_items(self):
     schema = KeyDict({"one": Int(), "two": List(Float())})
     input = {"one": 32, "two": [1.5, 2.3]}
     self.assertEquals(schema.coerce(input, PATH), {
         "one": 32,
         "two": [1.5, 2.3]
     })
Пример #2
0
 def test_key_dict_unknown_key(self):
     """
     Unknown key/value pairs processed by a KeyDict are left untouched.
     This is an attempt at not eating values by mistake due to something
     like different application versions operating on the same data.
     """
     schema = KeyDict({"foo": Int()})
     self.assertEquals(schema.coerce({"foo": 1, "bar": "hi"}, PATH),
                       {"foo": 1, "bar": "hi"})
Пример #3
0
 def test_key_dict_unknown_key(self):
     """
     Unknown key/value pairs processed by a KeyDict are left untouched.
     This is an attempt at not eating values by mistake due to something
     like different application versions operating on the same data.
     """
     schema = KeyDict({"foo": Int()})
     self.assertEquals(schema.coerce({
         "foo": 1,
         "bar": "hi"
     }, PATH), {
         "foo": 1,
         "bar": "hi"
     })
Пример #4
0
 def test_key_dict_pass_optional_key(self):
     """Regression test. It should be possible to pass an optional key.
     """
     schema = KeyDict({"foo": Int()}, optional=["foo"])
     self.assertEquals(schema.coerce({"foo": 32}, PATH), {"foo": 32})
Пример #5
0
 def test_key_dict_optional_keys(self):
     """KeyDict allows certain keys to be optional.
     """
     schema = KeyDict({"foo": Int(), "bar": Int()}, optional=["bar"])
     self.assertEquals(schema.coerce({"foo": 32}, PATH), {"foo": 32})
Пример #6
0
 def test_key_dict_multiple_items(self):
     schema = KeyDict({"one": Int(), "two": List(Float())})
     input = {"one": 32, "two": [1.5, 2.3]}
     self.assertEquals(schema.coerce(input, PATH),
                       {"one": 32, "two": [1.5, 2.3]})
Пример #7
0
 def test_key_dict_pass_optional_key(self):
     """Regression test. It should be possible to pass an optional key.
     """
     schema = KeyDict({"foo": Int()}, optional=["foo"])
     self.assertEquals(schema.coerce({"foo": 32}, PATH), {"foo": 32})
Пример #8
0
 def test_key_dict_optional_keys(self):
     """KeyDict allows certain keys to be optional.
     """
     schema = KeyDict({"foo": Int(), "bar": Int()}, optional=["bar"])
     self.assertEquals(schema.coerce({"foo": 32}, PATH), {"foo": 32})