1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
17
from keystoneclient.tests.v2_0 import utils
18
from keystoneclient.v2_0 import services
21
class ServiceTests(utils.TestCase):
23
super(ServiceTests, self).setUp()
24
self.TEST_SERVICES = {
25
"OS-KSADM:services": {
30
"description": "Nova-compatible service.",
36
"description": "Keystone-compatible service.",
44
def test_create(self):
48
"type": "object-store",
49
"description": "Swift-compatible service.",
55
"type": "object-store",
56
"description": "Swift-compatible service.",
60
self.stub_url(httpretty.POST, ['OS-KSADM', 'services'], json=resp_body)
62
service = self.client.services.create(
63
req_body['OS-KSADM:service']['name'],
64
req_body['OS-KSADM:service']['type'],
65
req_body['OS-KSADM:service']['description'])
66
self.assertTrue(isinstance(service, services.Service))
67
self.assertEqual(service.id, 3)
68
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
69
self.assertRequestBodyIs(json=req_body)
72
def test_delete(self):
73
self.stub_url(httpretty.DELETE, ['OS-KSADM', 'services', '1'],
76
self.client.services.delete(1)
80
test_services = self.TEST_SERVICES['OS-KSADM:services']['values'][0]
82
self.stub_url(httpretty.GET, ['OS-KSADM', 'services', '1'],
83
json={'OS-KSADM:service': test_services})
85
service = self.client.services.get(1)
86
self.assertTrue(isinstance(service, services.Service))
87
self.assertEqual(service.id, 1)
88
self.assertEqual(service.name, 'nova')
89
self.assertEqual(service.type, 'compute')
93
self.stub_url(httpretty.GET, ['OS-KSADM', 'services'],
94
json=self.TEST_SERVICES)
96
service_list = self.client.services.list()
97
[self.assertTrue(isinstance(r, services.Service))
98
for r in service_list]