def test_get_schema(self): obj = TestValidatableObject() obj.id = 'ffded5c4-e4f6-4e02-a175-48e13c5c12a0' obj.validate() self.assertTrue(hasattr(obj, '_obj_validator')) expected = { 'description': 'Designate TestValidatableObject Object', 'title': 'TestValidatableObject', 'required': ['id'], 'additionalProperties': False, '$schema': 'http://json-schema.org/draft-04/hyper-schema', 'type': 'object', 'properties': { 'id': { 'type': 'string', 'format': 'uuid' } } } schema = obj._obj_validator.schema self.assertEqual(schema, expected) with raises(AttributeError): # bug schema = obj.obj_get_schema()
def test_validate_handle_exception(self): rs = create_test_recordset() with mock.patch('designate.objects.DesignateObject.obj_cls_from_name') \ as patched: patched.side_effect = KeyError with raises(exceptions.InvalidObject): # TODO(Federico): check the attributes of the exception rs.validate()
def test_get_schema(self): obj = TestValidatableObject() obj.id = "ffded5c4-e4f6-4e02-a175-48e13c5c12a0" obj.validate() self.assertTrue(hasattr(obj, "_obj_validator")) expected = { "description": "Designate TestValidatableObject Object", "title": "TestValidatableObject", "required": ["id"], "additionalProperties": False, "$schema": "http://json-schema.org/draft-04/hyper-schema", "type": "object", "properties": {"id": {"type": "string", "format": "uuid"}}, } schema = obj._obj_validator.schema self.assertEqual(schema, expected) with raises(AttributeError): # bug schema = obj.obj_get_schema()
def test_get_missing(self): obj = TestObjectDict(name=1) self.assertFalse(obj.obj_attr_is_set('foo')) with raises(AttributeError): obj.get('foo')
def test_update_unexpected_attribute(self): obj = TestObject(id='MyID', name='test') with raises(AttributeError): obj.update({'id': 'new_id', 'new_key': 3})
def test_from_list(self): with raises(NotImplementedError): TestObject.from_list([])
def test_validate_invalid_secondary(self): domain = objects.Domain( type='SECONDARY', ) with raises(exceptions.InvalidObject): domain.validate()
def test_update_unexpected_attribute(self): obj = TestObject(id="MyID", name="test") with raises(AttributeError): obj.update({"id": "new_id", "new_key": 3})
def test_masters_none(self): domain = objects.Domain() with raises(exceptions.RelationNotLoaded): self.assertEqual(domain.masters, None)