diff --git a/magpie/api/management/service/service_views.py b/magpie/api/management/service/service_views.py index da0960e08..d110f57aa 100644 --- a/magpie/api/management/service/service_views.py +++ b/magpie/api/management/service/service_views.py @@ -195,7 +195,7 @@ def create_service_direct_resource(request): """Register a new resource directly under a service.""" service = get_service_matchdict_checked(request) resource_name = get_multiformat_post(request, 'resource_name') - resource_display_name = get_multiformat_post(request, 'resource_display_name') + resource_display_name = get_multiformat_post(request, 'resource_display_name', default=resource_name) resource_type = get_multiformat_post(request, 'resource_type') parent_id = get_multiformat_post(request, 'parent_id') # no check because None/empty is allowed if not parent_id: diff --git a/tests/interfaces.py b/tests/interfaces.py index 0c9f3f757..9e42d29f8 100644 --- a/tests/interfaces.py +++ b/tests/interfaces.py @@ -537,6 +537,24 @@ def test_PostResources_DirectServiceResource(self): utils.check_post_resource_structure(json_body, self.test_resource_name, self.test_resource_type, self.test_resource_name, self.version) + @pytest.mark.resources + @unittest.skipUnless(runner.MAGPIE_TEST_RESOURCES, reason=runner.MAGPIE_TEST_DISABLED_MESSAGE('resources')) + def test_PostResources_DirectServiceResource(self): + service_info = utils.TestSetup.get_ExistingTestServiceInfo(self) + service_resource_id = service_info['resource_id'] + + data = { + "resource_name": self.test_resource_name, + # resource_display_name should default to self.test_resource_name, + "resource_type": self.test_resource_type, + "parent_id": service_resource_id + } + resp = utils.test_request(self.url, 'POST', '/resources', + headers=self.json_headers, cookies=self.cookies, data=data) + json_body = utils.check_response_basic_info(resp, 201) + utils.check_post_resource_structure(json_body, self.test_resource_name, self.test_resource_type, + self.test_resource_name, self.version) + @pytest.mark.resources @unittest.skipUnless(runner.MAGPIE_TEST_RESOURCES, reason=runner.MAGPIE_TEST_DISABLED_MESSAGE('resources')) def test_PostResources_ChildrenResource(self):