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:
Jude Job 2015-12-30 16:17:30 +05:30 committed by David Stanek
parent b30722df40
commit 677ef6d44f
2 changed files with 33 additions and 2 deletions

View File

@ -42,7 +42,7 @@ class ServiceTests(utils.ClientTestCase):
},
}
def test_create(self):
def test_create_with_description(self):
req_body = {
"OS-KSADM:service": {
"name": "swift",
@ -68,6 +68,37 @@ class ServiceTests(utils.ClientTestCase):
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,
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)
def test_delete(self):

View File

@ -35,7 +35,7 @@ class ServiceManager(base.ManagerWithFind):
"""Retrieve a service by id."""
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."""
body = {"OS-KSADM:service": {'name': name,
'type': service_type,