Debian Codegraph @

keystoneclient/tests/unit/auth/test_loading.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
16 from keystoneclient.tests.unit.auth import utils
17
18
19 class TestOtherLoading(utils.TestCase):
20
21 def test_loading_getter(self):
22
23 called_opts = []
24
25 vals = {'a-int': 44,
26 'a-bool': False,
27 'a-float': 99.99,
28 'a-str': 'value'}
29
30 val = uuid.uuid4().hex
31
32 def _getter(opt):
33 called_opts.append(opt.name)
34 # return str because oslo.config should convert them back
35 return str(vals[opt.name])
36
37 p = utils.MockPlugin.load_from_options_getter(_getter, other=val)
38
39 self.assertEqual(set(vals), set(called_opts))
40
41 for k, v in vals.items():
42 # replace - to _ because it's the dest used to create kwargs
43 self.assertEqual(v, p[k.replace('-', '_')])
44
45 # check that additional kwargs get passed through
46 self.assertEqual(val, p['other'])