Skip to content

Commit

Permalink
make resource_display_name optional
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcaron committed Sep 28, 2018
1 parent c1685e1 commit da15173
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion magpie/api/management/service/service_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions tests/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit da15173

Please sign in to comment.