def test_drop_property_with_missing_property(self): schema = JSONSchema() schema.drop_property('doesnt-exist') expected = { '$schema': 'http://json-schema.org/draft-04/schema#', 'type': 'object', } serialized = schema.serialize() self.assertEqual(expected, serialized)
def test_dropping_last_property_removes_properties_key(self): schema = JSONSchema() schema.add_property('foo', {'type': 'string'}) schema.drop_property('foo') expected = { '$schema': 'http://json-schema.org/draft-04/schema#', 'type': 'object', } serialized = schema.serialize() self.assertEqual(expected, serialized)
def test_drop_required_property(self): schema = JSONSchema() schema.add_property('foo', {'type': 'string'}, required=True) schema.add_property('bar', {'type': 'string'}, required=True) schema.drop_property('foo') expected = { '$schema': 'http://json-schema.org/draft-04/schema#', 'type': 'object', 'properties': { 'bar': {'type': 'string'}, }, 'required': ['bar'], } serialized = schema.serialize() self.assertEqual(expected, serialized)