Merge "Check that region ID is not an empty string"
This commit is contained in:
commit
76f3c55e71
@ -193,7 +193,7 @@ class RegionV3(controller.V3Controller):
|
|||||||
def create_region(self, context, region):
|
def create_region(self, context, region):
|
||||||
ref = self._normalize_dict(region)
|
ref = self._normalize_dict(region)
|
||||||
|
|
||||||
if 'id' not in ref:
|
if not ref.get('id'):
|
||||||
ref = self._assign_unique_id(ref)
|
ref = self._assign_unique_id(ref)
|
||||||
|
|
||||||
ref = self.catalog_api.create_region(ref)
|
ref = self.catalog_api.create_region(ref)
|
||||||
|
@ -115,6 +115,17 @@ class CatalogTestCase(test_v3.RestfulTestCase):
|
|||||||
'region_id': ref['id']})
|
'region_id': ref['id']})
|
||||||
self.assertValidRegionResponse(r, ref)
|
self.assertValidRegionResponse(r, ref)
|
||||||
|
|
||||||
|
def test_create_region_with_empty_id(self):
|
||||||
|
"""Call ``POST /regions`` with an empty ID in the request body."""
|
||||||
|
ref = self.new_region_ref()
|
||||||
|
ref['id'] = ''
|
||||||
|
|
||||||
|
r = self.post(
|
||||||
|
'/regions',
|
||||||
|
body={'region': ref}, expected_status=201)
|
||||||
|
self.assertValidRegionResponse(r, ref)
|
||||||
|
self.assertNotEmpty(r.result['region'].get('id'))
|
||||||
|
|
||||||
def test_create_region_without_id(self):
|
def test_create_region_without_id(self):
|
||||||
"""Call ``POST /regions`` without an ID in the request body."""
|
"""Call ``POST /regions`` without an ID in the request body."""
|
||||||
ref = self.new_region_ref()
|
ref = self.new_region_ref()
|
||||||
|
Loading…
Reference in New Issue
Block a user