Debian Codegraph @

keystoneclient/tests/unit/v3/test_domain_configs.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12
13 import uuid
14
15 from keystoneclient import exceptions
16 from keystoneclient.tests.unit.v3 import utils
17 from keystoneclient.v3 import domain_configs
18
19
20 class DomainConfigsTests(utils.ClientTestCase, utils.CrudTests):
21 """Test domain config database management."""
22
23 def setUp(self):
24 super(DomainConfigsTests, self).setUp()
25 self.key = 'config'
26 self.model = domain_configs.DomainConfig
27 self.manager = self.client.domain_configs
28
29 def new_ref(self, **kwargs):
30 config_groups = {'identity': {uuid.uuid4().hex: uuid.uuid4().hex},
31 'ldap': {uuid.uuid4().hex: uuid.uuid4().hex}}
32 kwargs.setdefault('config', config_groups)
33 return kwargs
34
35 def _assert_resource_attributes(self, resource, req_ref):
36 for attr in req_ref:
37 self.assertEqual(
38 getattr(resource, attr),
39 req_ref[attr],
40 'Expected different %s' % attr)
41
42 def test_create(self):
43 domain_id = uuid.uuid4().hex
44 config = self.new_ref()
45
46 self.stub_url('PUT',
47 parts=['domains', domain_id, 'config'],
48 json=config, status_code=201)
49 res = self.manager.create(domain_id, config)
50 self._assert_resource_attributes(res, config['config'])
51 self.assertEntityRequestBodyIs(config)
52
53 def test_update(self):
54 domain_id = uuid.uuid4().hex
55 config = self.new_ref()
56
57 self.stub_url('PATCH',
58 parts=['domains', domain_id, 'config'],
59 json=config, status_code=200)
60 res = self.manager.update(domain_id, config)
61 self._assert_resource_attributes(res, config['config'])
62 self.assertEntityRequestBodyIs(config)
63
64 def test_get(self):
65 domain_id = uuid.uuid4().hex
66 config = self.new_ref()
67 config = config['config']
68
69 self.stub_entity('GET',
70 parts=['domains', domain_id, 'config'],
71 entity=config)
72 res = self.manager.get(domain_id)
73 self._assert_resource_attributes(res, config)
74
75 def test_delete(self):
76 domain_id = uuid.uuid4().hex
77 self.stub_url('DELETE',
78 parts=['domains', domain_id, 'config'],
79 status_code=204)
80 self.manager.delete(domain_id)
81
82 def test_list(self):
83 # List not supported for domain config
84 self.assertRaises(exceptions.MethodNotImplemented, self.manager.list)
85
86 def test_list_by_id(self):
87 # List not supported for domain config
88 self.assertRaises(exceptions.MethodNotImplemented, self.manager.list)
89
90 def test_list_params(self):
91 # List not supported for domain config
92 self.assertRaises(exceptions.MethodNotImplemented, self.manager.list)
93
94 def test_find(self):
95 # Find not supported for domain config
96 self.assertRaises(exceptions.MethodNotImplemented, self.manager.find)