def test_type_definition_get_not_found(self, AttributeDefinitionHandler, TypeDefinitionHandler, resp_mock, request_mock): thand_get = TypeDefinitionHandler.return_value.get thand_get.return_value = None cont = type_definitions.TypeDefinitionsController() resp = cont.get_one('non_existent_type') self.assertIsNotNone(resp) self.assertEqual(404, resp_mock.status)
def test_type_definitions_get(self, AttributeDefinitionHandler, TypeDefinitionHandler, resp_mock, request_mock): thand_get_all = TypeDefinitionHandler.return_value.get_all thand_get_all.return_value = [TEST_TYPE_DEFINITION] cont = type_definitions.TypeDefinitionsController() resp = cont.get() self.assertIsNotNone(resp) self.assertEqual(200, resp_mock.status) self.assertIsNotNone(resp['result'].type_definition_links) td_links = resp['result'].type_definition_links self.assertEqual(1, len(td_links)) self.assertEqual(TEST_TYPE_DEFINITION.name, td_links[0].target_name)
class Controller(rest.RestController): """CAMP API version 1.1 controller root.""" assemblies = assemblies.AssembliesController() attribute_definitions = ( attribute_definitions.AttributeDefinitionsController()) extensions = extensions.ExtensionsController() formats = formats.FormatsController() parameter_definitions = ( parameter_definitions.ParameterDefinitionsController()) plans = plans.PlansController() platform = platform.PlatformController() services = services.ServicesController() type_definitions = type_definitions.TypeDefinitionsController()
def test_type_definitions_get_one(self, AttributeDefinitionHandler, TypeDefinitionHandler, resp_mock, request_mock): ahand_get = AttributeDefinitionHandler.return_value.get ahand_get.return_value = TEST_ATTR_DEFINITION thand_get = TypeDefinitionHandler.return_value.get thand_get.return_value = TEST_TYPE_DEFINITION cont = type_definitions.TypeDefinitionsController() resp = cont.get_one('fake_type') self.assertIsNotNone(resp) self.assertEqual(200, resp_mock.status) self.assertEqual(TEST_TYPE_DEFINITION.type, resp['result'].type) self.assertEqual(TEST_TYPE_DEFINITION.name, resp['result'].name) ad_links = resp['result'].attribute_definition_links self.assertEqual(1, len(ad_links)) self.assertEqual(TEST_ATTR_DEFINITION.name, ad_links[0].target_name)