def test_document_required_fields(self): st = document.documents(required_fields={'test': json.nulls()}) self.assertEqual(hypothesis.find(st, lambda _: True), {'test': None})
def test_document_optional_fields(self): st = document.documents(optional_fields={'test': json.nulls()}) self.assertEqual(hypothesis.find(st, lambda v: 'test' not in v), {}) self.assertEqual(hypothesis.find(st, lambda v: 'test' in v), {'test': None})
def test_objects_always_contains_required_fields(self): st = json.objects(required_fields={'test': json.nulls()}) with self.assertRaises(NoSuchExample): hypothesis.find(st, lambda v: 'test' not in v)
def test_objects_may_contains_optional_fields(self): st = json.objects(optional_fields={'test': json.nulls()}) self.assertEqual(hypothesis.find(st, lambda v: 'test' not in v), {}) self.assertEqual(hypothesis.find(st, lambda v: 'test' in v), {'test': None})
def test_nulls(self): st = json.nulls() value = hypothesis.find(st, lambda _: True) self.assertIsNone(value)