Missing defaults in the create() method in the v2 ServiceManager
This patch include a new method for testing, without description value. Change-Id: Icd04e4479a341e7691fc562b3e09d5aa41a354e7 Closes-Bug: #1318438
This commit is contained in:
@@ -42,7 +42,7 @@ class ServiceTests(utils.ClientTestCase):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_create(self):
|
def test_create_with_description(self):
|
||||||
req_body = {
|
req_body = {
|
||||||
"OS-KSADM:service": {
|
"OS-KSADM:service": {
|
||||||
"name": "swift",
|
"name": "swift",
|
||||||
@@ -68,6 +68,37 @@ class ServiceTests(utils.ClientTestCase):
|
|||||||
self.assertIsInstance(service, services.Service)
|
self.assertIsInstance(service, services.Service)
|
||||||
self.assertEqual(service.id, service_id)
|
self.assertEqual(service.id, service_id)
|
||||||
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
|
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
|
||||||
|
self.assertEqual(service.description,
|
||||||
|
req_body['OS-KSADM:service']['description'])
|
||||||
|
self.assertRequestBodyIs(json=req_body)
|
||||||
|
|
||||||
|
def test_create_without_description(self):
|
||||||
|
req_body = {
|
||||||
|
"OS-KSADM:service": {
|
||||||
|
"name": "swift",
|
||||||
|
"type": "object-store",
|
||||||
|
"description": None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
service_id = uuid.uuid4().hex
|
||||||
|
resp_body = {
|
||||||
|
"OS-KSADM:service": {
|
||||||
|
"name": "swift",
|
||||||
|
"type": "object-store",
|
||||||
|
"id": service_id,
|
||||||
|
"description": None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.stub_url('POST', ['OS-KSADM', 'services'], json=resp_body)
|
||||||
|
|
||||||
|
service = self.client.services.create(
|
||||||
|
req_body['OS-KSADM:service']['name'],
|
||||||
|
req_body['OS-KSADM:service']['type'],
|
||||||
|
req_body['OS-KSADM:service']['description'])
|
||||||
|
self.assertIsInstance(service, services.Service)
|
||||||
|
self.assertEqual(service.id, service_id)
|
||||||
|
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
|
||||||
|
self.assertEqual(service.description, None)
|
||||||
self.assertRequestBodyIs(json=req_body)
|
self.assertRequestBodyIs(json=req_body)
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
|
@@ -35,7 +35,7 @@ class ServiceManager(base.ManagerWithFind):
|
|||||||
"""Retrieve a service by id."""
|
"""Retrieve a service by id."""
|
||||||
return self._get("/OS-KSADM/services/%s" % id, "OS-KSADM:service")
|
return self._get("/OS-KSADM/services/%s" % id, "OS-KSADM:service")
|
||||||
|
|
||||||
def create(self, name, service_type, description):
|
def create(self, name, service_type, description=None):
|
||||||
"""Create a new service."""
|
"""Create a new service."""
|
||||||
body = {"OS-KSADM:service": {'name': name,
|
body = {"OS-KSADM:service": {'name': name,
|
||||||
'type': service_type,
|
'type': service_type,
|
||||||
|
Reference in New Issue
Block a user