Exemplo n.º 1
0
 def test_any_of_json_codec(self):
     for value in [123.45, False]:
         schema = s.any_of([s.float(), s.bool()])
         self.assertEqual(schema.json_decode(schema.json_encode(value)),
                          value)
Exemplo n.º 2
0
 def test_any_of_none_match(self):
     self._error(s.any_of([s.str(), s.int()]).validate, 123.45)
Exemplo n.º 3
0
 def test_any_of_either_match(self):
     s.any_of([s.str(), s.int()]).validate("one")
     s.any_of([s.str(), s.int()]).validate(1)
Exemplo n.º 4
0
def test_any_of_json_codec():
    for value in [123.45, False]:
        schema = s.any_of([s.float(), s.bool()])
        assert schema.json_decode(schema.json_encode(value)) == value
Exemplo n.º 5
0
def test_any_of_match_str():
    assert isinstance(s.any_of((s.int(), s.str())).match("one"), s.str)
Exemplo n.º 6
0
def test_any_of_match_int():
    assert isinstance(s.any_of((s.int(), s.str())).match(1), s.int)
Exemplo n.º 7
0
def test_any_of_nullable_inner():
    s.any_of((s.int(nullable=True), s.str())).validate(None)
Exemplo n.º 8
0
def test_any_of_nullable_outer():
    s.any_of((s.int(), s.str()), nullable=True).validate(None)