Debian Codegraph @

osc_lib/tests/fakes.py

raw
1 # Copyright 2013 Nebula Inc.
2 #
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
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
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
13 # under the License.
14
15 import warnings
16
17 from osc_lib.test.base import TestCase, TestCommand
18 from osc_lib.test.fakes import (
19 AUTH_URL,
20 INTERFACE,
21 IDENTITY_API_VERSION as VERSION,
22 PASSWORD,
23 PROJECT_ID,
24 PROJECT_NAME,
25 REGION_NAME,
26 TOKEN as AUTH_TOKEN,
27 USERNAME,
28 USER_ID,
29 FakeApp,
30 FakeClientManager,
31 FakeLog,
32 FakeModule,
33 FakeOptions,
34 FakeResource,
35 FakeStdout,
36 )
37 from osc_lib.tests.test_clientmanager import (
38 SERVICE_PROVIDER_ID,
39 TEST_RESPONSE_DICT,
40 TEST_RESPONSE_DICT_V3,
41 TEST_VERSIONS,
42 )
43
44 __all__ = [
45 'AUTH_TOKEN',
46 'AUTH_URL',
47 'FakeApp',
48 'FakeClientManager',
49 'FakeLog',
50 'FakeModule',
51 'FakeOptions',
52 'FakeResource',
53 'FakeStdout',
54 'INTERFACE',
55 'PASSWORD',
56 'PROJECT_ID',
57 'PROJECT_NAME',
58 'REGION_NAME',
59 'SERVICE_PROVIDER_ID',
60 'TEST_RESPONSE_DICT',
61 'TEST_RESPONSE_DICT_V3',
62 'TEST_VERSIONS',
63 'TestCase',
64 'TestCommand',
65 'to_unicode_dict',
66 'USER_ID',
67 'USERNAME',
68 'VERSION',
69 ]
70
71
72 warnings.warn(
73 "The osc_lib.tests.fakes module is deprecated for removal and should not "
74 "be used externally. Use the osc_lib.test module instead, which provides "
75 "a public API.",
76 DeprecationWarning,
77 )
78
79
80 # NOTE(stephenfin): This isn't moved since it's unused now. We can delete it in
81 # the future.
82 def to_unicode_dict(catalog_dict):
83 """Converts dict to unicode dict"""
84 if isinstance(catalog_dict, dict):
85 return {
86 to_unicode_dict(key): to_unicode_dict(value)
87 for key, value in catalog_dict.items()
88 }
89 elif isinstance(catalog_dict, list):
90 return [to_unicode_dict(element) for element in catalog_dict]
91 elif isinstance(catalog_dict, str):
92 return catalog_dict + ""
93 else:
94 return catalog_dict