edq-utils 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of edq-utils might be problematic. Click here for more details.
- edq/__init__.py +5 -0
- edq/cli/__init__.py +0 -0
- edq/cli/__main__.py +17 -0
- edq/cli/config/__init__.py +3 -0
- edq/cli/config/__main__.py +15 -0
- edq/cli/config/list.py +69 -0
- edq/cli/http/__init__.py +3 -0
- edq/cli/http/__main__.py +15 -0
- edq/cli/http/exchange-server.py +71 -0
- edq/cli/http/send-exchange.py +45 -0
- edq/cli/http/verify-exchanges.py +38 -0
- edq/cli/testing/__init__.py +3 -0
- edq/cli/testing/__main__.py +15 -0
- edq/cli/testing/cli-test.py +49 -0
- edq/cli/version.py +28 -0
- edq/core/__init__.py +0 -0
- edq/core/argparser.py +137 -0
- edq/core/argparser_test.py +124 -0
- edq/core/config.py +268 -0
- edq/core/config_test.py +1038 -0
- edq/core/log.py +101 -0
- edq/core/version.py +6 -0
- edq/procedure/__init__.py +0 -0
- edq/procedure/verify_exchanges.py +85 -0
- edq/py.typed +0 -0
- edq/testing/__init__.py +3 -0
- edq/testing/asserts.py +65 -0
- edq/testing/cli.py +360 -0
- edq/testing/cli_test.py +15 -0
- edq/testing/httpserver.py +578 -0
- edq/testing/httpserver_test.py +424 -0
- edq/testing/run.py +142 -0
- edq/testing/testdata/cli/data/configs/empty/edq-config.json +1 -0
- edq/testing/testdata/cli/data/configs/simple-1/edq-config.json +4 -0
- edq/testing/testdata/cli/data/configs/simple-2/edq-config.json +3 -0
- edq/testing/testdata/cli/data/configs/value-number/edq-config.json +3 -0
- edq/testing/testdata/cli/tests/config/list/config_list_base.txt +16 -0
- edq/testing/testdata/cli/tests/config/list/config_list_config_value_number.txt +10 -0
- edq/testing/testdata/cli/tests/config/list/config_list_ignore_config.txt +14 -0
- edq/testing/testdata/cli/tests/config/list/config_list_no_config.txt +8 -0
- edq/testing/testdata/cli/tests/config/list/config_list_show_origin.txt +13 -0
- edq/testing/testdata/cli/tests/config/list/config_list_skip_header.txt +10 -0
- edq/testing/testdata/cli/tests/help_base.txt +9 -0
- edq/testing/testdata/cli/tests/platform_skip.txt +5 -0
- edq/testing/testdata/cli/tests/version_base.txt +6 -0
- edq/testing/testdata/http/exchanges/simple.httpex.json +5 -0
- edq/testing/testdata/http/exchanges/simple_anchor.httpex.json +5 -0
- edq/testing/testdata/http/exchanges/simple_file.httpex.json +10 -0
- edq/testing/testdata/http/exchanges/simple_file_binary.httpex.json +10 -0
- edq/testing/testdata/http/exchanges/simple_file_get_params.httpex.json +14 -0
- edq/testing/testdata/http/exchanges/simple_file_multiple.httpex.json +13 -0
- edq/testing/testdata/http/exchanges/simple_file_name.httpex.json +11 -0
- edq/testing/testdata/http/exchanges/simple_file_post_multiple.httpex.json +13 -0
- edq/testing/testdata/http/exchanges/simple_file_post_params.httpex.json +14 -0
- edq/testing/testdata/http/exchanges/simple_headers.httpex.json +8 -0
- edq/testing/testdata/http/exchanges/simple_jsonresponse_dict.httpex.json +7 -0
- edq/testing/testdata/http/exchanges/simple_jsonresponse_list.httpex.json +9 -0
- edq/testing/testdata/http/exchanges/simple_params.httpex.json +9 -0
- edq/testing/testdata/http/exchanges/simple_post.httpex.json +5 -0
- edq/testing/testdata/http/exchanges/simple_post_params.httpex.json +9 -0
- edq/testing/testdata/http/exchanges/simple_post_urlparams.httpex.json +5 -0
- edq/testing/testdata/http/exchanges/simple_urlparams.httpex.json +5 -0
- edq/testing/testdata/http/exchanges/specialcase_listparams_explicit.httpex.json +8 -0
- edq/testing/testdata/http/exchanges/specialcase_listparams_url.httpex.json +5 -0
- edq/testing/testdata/http/files/a.txt +1 -0
- edq/testing/testdata/http/files/tiny.png +0 -0
- edq/testing/unittest.py +88 -0
- edq/util/__init__.py +3 -0
- edq/util/cli.py +151 -0
- edq/util/dirent.py +346 -0
- edq/util/dirent_test.py +1004 -0
- edq/util/encoding.py +18 -0
- edq/util/hash.py +41 -0
- edq/util/hash_test.py +89 -0
- edq/util/json.py +180 -0
- edq/util/json_test.py +228 -0
- edq/util/net.py +1047 -0
- edq/util/parse.py +33 -0
- edq/util/pyimport.py +94 -0
- edq/util/pyimport_test.py +119 -0
- edq/util/reflection.py +32 -0
- edq/util/time.py +75 -0
- edq/util/time_test.py +107 -0
- edq_utils-0.2.3.dist-info/METADATA +164 -0
- edq_utils-0.2.3.dist-info/RECORD +88 -0
- edq_utils-0.2.3.dist-info/WHEEL +5 -0
- edq_utils-0.2.3.dist-info/licenses/LICENSE +21 -0
- edq_utils-0.2.3.dist-info/top_level.txt +1 -0
edq/core/config_test.py
ADDED
|
@@ -0,0 +1,1038 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import edq.testing.unittest
|
|
4
|
+
import edq.core.config
|
|
5
|
+
import edq.util.dirent
|
|
6
|
+
import edq.util.json
|
|
7
|
+
|
|
8
|
+
def creat_test_dir(temp_dir_prefix: str) -> str:
|
|
9
|
+
"""
|
|
10
|
+
Creat a temp dir and populate it with dirents for testing.
|
|
11
|
+
|
|
12
|
+
This test data directory is laid out as:
|
|
13
|
+
.
|
|
14
|
+
├── custom-name
|
|
15
|
+
│ └── custom-edq-config.json
|
|
16
|
+
├── dir-config
|
|
17
|
+
│ └── edq-config.json
|
|
18
|
+
├── empty
|
|
19
|
+
│ └── edq-config.json
|
|
20
|
+
├── empty-dir
|
|
21
|
+
├── empty-key
|
|
22
|
+
│ └── edq-config.json
|
|
23
|
+
├── global
|
|
24
|
+
│ └── edq-config.json
|
|
25
|
+
├── malformed
|
|
26
|
+
│ └── edq-config.json
|
|
27
|
+
├── multiple-options
|
|
28
|
+
│ └── edq-config.json
|
|
29
|
+
├── nested
|
|
30
|
+
│ ├── config.json
|
|
31
|
+
│ ├── edq-config.json
|
|
32
|
+
│ └── nest1
|
|
33
|
+
│ ├── nest2a
|
|
34
|
+
│ └── nest2b
|
|
35
|
+
│ └── edq-config.json
|
|
36
|
+
├── old-name
|
|
37
|
+
│ ├── config.json
|
|
38
|
+
│ └── nest1
|
|
39
|
+
│ └── nest2
|
|
40
|
+
└── simple
|
|
41
|
+
└── edq-config.json
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
temp_dir = edq.util.dirent.get_temp_dir(prefix = temp_dir_prefix)
|
|
45
|
+
|
|
46
|
+
empty_config_dir_path = os.path.join(temp_dir, "empty")
|
|
47
|
+
edq.util.dirent.mkdir(empty_config_dir_path)
|
|
48
|
+
edq.util.json.dump_path({}, os.path.join(empty_config_dir_path, edq.core.config.DEFAULT_CONFIG_FILENAME))
|
|
49
|
+
|
|
50
|
+
multiple_option_config_dir_path = os.path.join(temp_dir, "multiple-options")
|
|
51
|
+
edq.util.dirent.mkdir(multiple_option_config_dir_path)
|
|
52
|
+
edq.util.json.dump_path(
|
|
53
|
+
{"user": "user@test.edulinq.org", "pass": "password1234"},
|
|
54
|
+
os.path.join(multiple_option_config_dir_path, edq.core.config.DEFAULT_CONFIG_FILENAME)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
empty_key_config_dir_path = os.path.join(temp_dir, "empty-key")
|
|
58
|
+
edq.util.dirent.mkdir(empty_key_config_dir_path)
|
|
59
|
+
edq.util.json.dump_path({"": "user@test.edulinq.org"}, os.path.join(empty_key_config_dir_path, edq.core.config.DEFAULT_CONFIG_FILENAME))
|
|
60
|
+
|
|
61
|
+
custom_name_config_dir_path = os.path.join(temp_dir, "custom-name")
|
|
62
|
+
edq.util.dirent.mkdir(custom_name_config_dir_path)
|
|
63
|
+
edq.util.json.dump_path({"user": "user@test.edulinq.org"}, os.path.join(custom_name_config_dir_path, "custom-edq-config.json"))
|
|
64
|
+
|
|
65
|
+
edq.util.dirent.mkdir(os.path.join(temp_dir, "dir-config", "edq-config.json"))
|
|
66
|
+
edq.util.dirent.mkdir(os.path.join(temp_dir, "empty-dir"))
|
|
67
|
+
|
|
68
|
+
global_config_dir_path = os.path.join(temp_dir, "global")
|
|
69
|
+
edq.util.dirent.mkdir(global_config_dir_path)
|
|
70
|
+
edq.util.json.dump_path({"user": "user@test.edulinq.org"}, os.path.join(global_config_dir_path, edq.core.config.DEFAULT_CONFIG_FILENAME))
|
|
71
|
+
|
|
72
|
+
old_name_config_dir_path = os.path.join(temp_dir, "old-name")
|
|
73
|
+
edq.util.dirent.mkdir(os.path.join(old_name_config_dir_path, "nest1", "nest2"))
|
|
74
|
+
edq.util.json.dump_path({"user": "user@test.edulinq.org"}, os.path.join(old_name_config_dir_path, "config.json"))
|
|
75
|
+
|
|
76
|
+
nested_dir_path = os.path.join(temp_dir, "nested")
|
|
77
|
+
edq.util.dirent.mkdir(os.path.join(nested_dir_path, "nest1", "nest2a"))
|
|
78
|
+
edq.util.dirent.mkdir(os.path.join(nested_dir_path, "nest1", "nest2b"))
|
|
79
|
+
|
|
80
|
+
edq.util.json.dump_path({"server": "http://test.edulinq.org"}, os.path.join(nested_dir_path, edq.core.config.DEFAULT_CONFIG_FILENAME))
|
|
81
|
+
edq.util.json.dump_path({"user": "user@test.edulinq.org"}, os.path.join(nested_dir_path, "config.json"))
|
|
82
|
+
edq.util.json.dump_path(
|
|
83
|
+
{"user": "user@test.edulinq.org"},
|
|
84
|
+
os.path.join(nested_dir_path, "nest1", "nest2b", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
simple_config_dir_path = os.path.join(temp_dir, "simple")
|
|
88
|
+
edq.util.dirent.mkdir(simple_config_dir_path)
|
|
89
|
+
edq.util.dirent.write_file(
|
|
90
|
+
os.path.join(simple_config_dir_path, edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
91
|
+
'{"user": "user@test.edulinq.org",}',
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
malformed_config_dir_path = os.path.join(temp_dir, "malformed")
|
|
95
|
+
edq.util.dirent.mkdir(malformed_config_dir_path)
|
|
96
|
+
edq.util.dirent.write_file(
|
|
97
|
+
os.path.join(malformed_config_dir_path, edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
98
|
+
"{user: user@test.edulinq.org}",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return temp_dir
|
|
102
|
+
|
|
103
|
+
class TestConfig(edq.testing.unittest.BaseTest):
|
|
104
|
+
""" Test basic operations on configs. """
|
|
105
|
+
|
|
106
|
+
def test_get_tiered_config_base(self):
|
|
107
|
+
"""
|
|
108
|
+
Test that configuration files are loaded correctly from the file system with the expected tier.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
temp_dir = creat_test_dir(temp_dir_prefix = "edq-test-config-get-tiered-config-")
|
|
112
|
+
|
|
113
|
+
# [(work directory, extra arguments, expected config, expected source, error substring), ...]
|
|
114
|
+
test_cases = [
|
|
115
|
+
# No Config
|
|
116
|
+
(
|
|
117
|
+
"empty-dir",
|
|
118
|
+
{},
|
|
119
|
+
{},
|
|
120
|
+
{},
|
|
121
|
+
None,
|
|
122
|
+
),
|
|
123
|
+
|
|
124
|
+
# Global Config
|
|
125
|
+
|
|
126
|
+
# Custom Global Config Path
|
|
127
|
+
(
|
|
128
|
+
"empty-dir",
|
|
129
|
+
{
|
|
130
|
+
"cli_arguments": {
|
|
131
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"user": "user@test.edulinq.org",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"user": edq.core.config.ConfigSource(
|
|
139
|
+
label = edq.core.config.CONFIG_SOURCE_GLOBAL,
|
|
140
|
+
path = os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
141
|
+
),
|
|
142
|
+
},
|
|
143
|
+
None,
|
|
144
|
+
),
|
|
145
|
+
|
|
146
|
+
# Empty Config JSON
|
|
147
|
+
(
|
|
148
|
+
"empty-dir",
|
|
149
|
+
{
|
|
150
|
+
"cli_arguments": {
|
|
151
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "empty", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{},
|
|
155
|
+
{},
|
|
156
|
+
None,
|
|
157
|
+
),
|
|
158
|
+
|
|
159
|
+
# Empty Key Config JSON
|
|
160
|
+
(
|
|
161
|
+
"empty-dir",
|
|
162
|
+
{
|
|
163
|
+
"cli_arguments": {
|
|
164
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "empty-key", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{},
|
|
168
|
+
{},
|
|
169
|
+
"Found an empty configuration option key associated with the value 'user@test.edulinq.org'.",
|
|
170
|
+
),
|
|
171
|
+
|
|
172
|
+
# Directory Config JSON
|
|
173
|
+
(
|
|
174
|
+
"empty-dir",
|
|
175
|
+
{
|
|
176
|
+
"cli_arguments": {
|
|
177
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "dir-config", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{},
|
|
181
|
+
{},
|
|
182
|
+
None,
|
|
183
|
+
),
|
|
184
|
+
|
|
185
|
+
# Non-Existent Config JSON
|
|
186
|
+
(
|
|
187
|
+
"empty-dir",
|
|
188
|
+
{
|
|
189
|
+
"cli_arguments": {
|
|
190
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "empty-dir", "non-existent-config.json"),
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
{},
|
|
194
|
+
{},
|
|
195
|
+
None,
|
|
196
|
+
),
|
|
197
|
+
|
|
198
|
+
# Malformed Config JSON
|
|
199
|
+
(
|
|
200
|
+
"empty-dir",
|
|
201
|
+
{
|
|
202
|
+
"cli_arguments": {
|
|
203
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "malformed", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
{},
|
|
207
|
+
{},
|
|
208
|
+
"Failed to read JSON file",
|
|
209
|
+
),
|
|
210
|
+
|
|
211
|
+
# Ignore Config Option
|
|
212
|
+
(
|
|
213
|
+
"empty-dir",
|
|
214
|
+
{
|
|
215
|
+
"cli_arguments": {
|
|
216
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "multiple-options", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
217
|
+
edq.core.config.IGNORE_CONFIGS_KEY: [
|
|
218
|
+
"pass",
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"user": "user@test.edulinq.org",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"user": edq.core.config.ConfigSource(
|
|
227
|
+
label = edq.core.config.CONFIG_SOURCE_GLOBAL,
|
|
228
|
+
path = os.path.join(temp_dir, "multiple-options", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
229
|
+
),
|
|
230
|
+
},
|
|
231
|
+
None,
|
|
232
|
+
),
|
|
233
|
+
|
|
234
|
+
# Ignore Non-Existing Config Option
|
|
235
|
+
(
|
|
236
|
+
"empty-dir",
|
|
237
|
+
{
|
|
238
|
+
"cli_arguments": {
|
|
239
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
240
|
+
edq.core.config.IGNORE_CONFIGS_KEY: [
|
|
241
|
+
"non-existing-option",
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"user": "user@test.edulinq.org",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"user": edq.core.config.ConfigSource(
|
|
250
|
+
label = edq.core.config.CONFIG_SOURCE_GLOBAL,
|
|
251
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
252
|
+
),
|
|
253
|
+
},
|
|
254
|
+
None,
|
|
255
|
+
),
|
|
256
|
+
|
|
257
|
+
# Local Config
|
|
258
|
+
|
|
259
|
+
# Default config file in current directory.
|
|
260
|
+
(
|
|
261
|
+
"simple",
|
|
262
|
+
{},
|
|
263
|
+
{
|
|
264
|
+
"user": "user@test.edulinq.org",
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"user": edq.core.config.ConfigSource(
|
|
268
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
269
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
270
|
+
),
|
|
271
|
+
},
|
|
272
|
+
None,
|
|
273
|
+
),
|
|
274
|
+
|
|
275
|
+
# Custom config file in current directory.
|
|
276
|
+
(
|
|
277
|
+
"custom-name",
|
|
278
|
+
{
|
|
279
|
+
"config_filename": "custom-edq-config.json",
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"user": "user@test.edulinq.org",
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"user": edq.core.config.ConfigSource(
|
|
286
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
287
|
+
path = os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
288
|
+
),
|
|
289
|
+
},
|
|
290
|
+
None,
|
|
291
|
+
),
|
|
292
|
+
|
|
293
|
+
# Legacy config file in current directory.
|
|
294
|
+
(
|
|
295
|
+
"old-name",
|
|
296
|
+
{
|
|
297
|
+
"legacy_config_filename": "config.json",
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"user": "user@test.edulinq.org",
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"user": edq.core.config.ConfigSource(
|
|
304
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
305
|
+
path = os.path.join(temp_dir, "old-name", "config.json"),
|
|
306
|
+
),
|
|
307
|
+
},
|
|
308
|
+
None,
|
|
309
|
+
),
|
|
310
|
+
|
|
311
|
+
# Default config file in an ancestor directory.
|
|
312
|
+
(
|
|
313
|
+
os.path.join("nested", "nest1", "nest2a"),
|
|
314
|
+
{},
|
|
315
|
+
{
|
|
316
|
+
"server": "http://test.edulinq.org",
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"server": edq.core.config.ConfigSource(
|
|
320
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
321
|
+
path = os.path.join(temp_dir, "nested", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
322
|
+
),
|
|
323
|
+
},
|
|
324
|
+
None,
|
|
325
|
+
),
|
|
326
|
+
|
|
327
|
+
# Legacy config file in an ancestor directory.
|
|
328
|
+
(
|
|
329
|
+
os.path.join("old-name", "nest1", "nest2"),
|
|
330
|
+
{
|
|
331
|
+
"legacy_config_filename": "config.json",
|
|
332
|
+
},
|
|
333
|
+
{},
|
|
334
|
+
{},
|
|
335
|
+
None,
|
|
336
|
+
),
|
|
337
|
+
|
|
338
|
+
# Empty Config JSON
|
|
339
|
+
(
|
|
340
|
+
"empty",
|
|
341
|
+
{},
|
|
342
|
+
{},
|
|
343
|
+
{},
|
|
344
|
+
None,
|
|
345
|
+
),
|
|
346
|
+
|
|
347
|
+
# Empty Key Config JSON
|
|
348
|
+
(
|
|
349
|
+
"empty-key",
|
|
350
|
+
{},
|
|
351
|
+
{},
|
|
352
|
+
{},
|
|
353
|
+
"Found an empty configuration option key associated with the value 'user@test.edulinq.org'.",
|
|
354
|
+
),
|
|
355
|
+
|
|
356
|
+
# Directory Config JSON
|
|
357
|
+
(
|
|
358
|
+
"dir-config",
|
|
359
|
+
{},
|
|
360
|
+
{},
|
|
361
|
+
{},
|
|
362
|
+
None,
|
|
363
|
+
),
|
|
364
|
+
|
|
365
|
+
# Malformed Config JSON
|
|
366
|
+
(
|
|
367
|
+
"malformed",
|
|
368
|
+
{},
|
|
369
|
+
{},
|
|
370
|
+
{},
|
|
371
|
+
"Failed to read JSON file",
|
|
372
|
+
),
|
|
373
|
+
|
|
374
|
+
# Ignore Config Option
|
|
375
|
+
(
|
|
376
|
+
"multiple-options",
|
|
377
|
+
{
|
|
378
|
+
"cli_arguments":{
|
|
379
|
+
edq.core.config.IGNORE_CONFIGS_KEY: [
|
|
380
|
+
"pass",
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"user": "user@test.edulinq.org",
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"user": edq.core.config.ConfigSource(
|
|
389
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
390
|
+
path = os.path.join(temp_dir, "multiple-options", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
391
|
+
),
|
|
392
|
+
},
|
|
393
|
+
None,
|
|
394
|
+
),
|
|
395
|
+
|
|
396
|
+
# Ignore Non-Existing Config Option
|
|
397
|
+
(
|
|
398
|
+
"simple",
|
|
399
|
+
{
|
|
400
|
+
"cli_arguments":{
|
|
401
|
+
edq.core.config.IGNORE_CONFIGS_KEY: [
|
|
402
|
+
"non-existing-option",
|
|
403
|
+
],
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"user": "user@test.edulinq.org",
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"user": edq.core.config.ConfigSource(
|
|
411
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
412
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
413
|
+
),
|
|
414
|
+
},
|
|
415
|
+
None,
|
|
416
|
+
),
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
# All 3 local config locations present at the same time.
|
|
420
|
+
(
|
|
421
|
+
os.path.join("nested", "nest1", "nest2b"),
|
|
422
|
+
{
|
|
423
|
+
"legacy_config_filename": "config.json",
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"user": "user@test.edulinq.org",
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"user": edq.core.config.ConfigSource(
|
|
430
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
431
|
+
path = os.path.join(temp_dir, "nested", "nest1", "nest2b", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
432
|
+
),
|
|
433
|
+
},
|
|
434
|
+
None,
|
|
435
|
+
),
|
|
436
|
+
|
|
437
|
+
# CLI Provided Config
|
|
438
|
+
|
|
439
|
+
# Distinct Keys
|
|
440
|
+
(
|
|
441
|
+
"empty-dir",
|
|
442
|
+
{
|
|
443
|
+
"cli_arguments": {
|
|
444
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
445
|
+
os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
446
|
+
os.path.join(temp_dir, "nested", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
447
|
+
],
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
"user": "user@test.edulinq.org",
|
|
452
|
+
"server": "http://test.edulinq.org",
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"user": edq.core.config.ConfigSource(
|
|
456
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
457
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
458
|
+
),
|
|
459
|
+
"server": edq.core.config.ConfigSource(
|
|
460
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
461
|
+
path = os.path.join(temp_dir, "nested", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
462
|
+
),
|
|
463
|
+
},
|
|
464
|
+
None,
|
|
465
|
+
),
|
|
466
|
+
|
|
467
|
+
# Overwriting Keys
|
|
468
|
+
(
|
|
469
|
+
"empty-dir",
|
|
470
|
+
{
|
|
471
|
+
"cli_arguments": {
|
|
472
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
473
|
+
os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
474
|
+
os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
475
|
+
],
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"user": "user@test.edulinq.org",
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"user": edq.core.config.ConfigSource(
|
|
483
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
484
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
485
|
+
),
|
|
486
|
+
},
|
|
487
|
+
None,
|
|
488
|
+
),
|
|
489
|
+
|
|
490
|
+
# Empty Config JSON
|
|
491
|
+
(
|
|
492
|
+
"empty-dir",
|
|
493
|
+
{
|
|
494
|
+
"cli_arguments": {
|
|
495
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
496
|
+
os.path.join(temp_dir, "empty", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
497
|
+
],
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
{},
|
|
501
|
+
{},
|
|
502
|
+
None,
|
|
503
|
+
),
|
|
504
|
+
|
|
505
|
+
# Empty Key Config JSON
|
|
506
|
+
(
|
|
507
|
+
"empty-dir",
|
|
508
|
+
{
|
|
509
|
+
"cli_arguments": {
|
|
510
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
511
|
+
os.path.join(temp_dir, "empty-key", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
512
|
+
],
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
{},
|
|
516
|
+
{},
|
|
517
|
+
"Found an empty configuration option key associated with the value 'user@test.edulinq.org'.",
|
|
518
|
+
),
|
|
519
|
+
|
|
520
|
+
# Directory Config JSON
|
|
521
|
+
(
|
|
522
|
+
"empty-dir",
|
|
523
|
+
{
|
|
524
|
+
"cli_arguments": {
|
|
525
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
526
|
+
os.path.join(temp_dir, "dir-config", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
527
|
+
],
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
{},
|
|
531
|
+
{},
|
|
532
|
+
"IsADirectoryError",
|
|
533
|
+
),
|
|
534
|
+
|
|
535
|
+
# Non-Existent Config JSON
|
|
536
|
+
(
|
|
537
|
+
"empty-dir",
|
|
538
|
+
{
|
|
539
|
+
"cli_arguments": {
|
|
540
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
541
|
+
os.path.join(temp_dir, "empty-dir", "non-existent-config.json"),
|
|
542
|
+
],
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
{},
|
|
546
|
+
{},
|
|
547
|
+
"FileNotFoundError",
|
|
548
|
+
),
|
|
549
|
+
|
|
550
|
+
# Malformed Config JSON
|
|
551
|
+
(
|
|
552
|
+
"empty-dir",
|
|
553
|
+
{
|
|
554
|
+
"cli_arguments": {
|
|
555
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
556
|
+
os.path.join(temp_dir, "malformed", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
557
|
+
],
|
|
558
|
+
},
|
|
559
|
+
},
|
|
560
|
+
{},
|
|
561
|
+
{},
|
|
562
|
+
"Failed to read JSON file",
|
|
563
|
+
),
|
|
564
|
+
|
|
565
|
+
# Ignore Config Option
|
|
566
|
+
(
|
|
567
|
+
"empty-dir",
|
|
568
|
+
{
|
|
569
|
+
"cli_arguments": {
|
|
570
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
571
|
+
os.path.join(temp_dir, "multiple-options", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
572
|
+
],
|
|
573
|
+
edq.core.config.IGNORE_CONFIGS_KEY: [
|
|
574
|
+
"pass",
|
|
575
|
+
],
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"user": "user@test.edulinq.org",
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
"user": edq.core.config.ConfigSource(
|
|
583
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
584
|
+
path = os.path.join(temp_dir, "multiple-options", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
585
|
+
),
|
|
586
|
+
},
|
|
587
|
+
None,
|
|
588
|
+
),
|
|
589
|
+
|
|
590
|
+
# Ignore Non-Existing Config Option
|
|
591
|
+
(
|
|
592
|
+
"empty-dir",
|
|
593
|
+
{
|
|
594
|
+
"cli_arguments": {
|
|
595
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
596
|
+
os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
597
|
+
],
|
|
598
|
+
edq.core.config.IGNORE_CONFIGS_KEY: [
|
|
599
|
+
"non-existing-option",
|
|
600
|
+
],
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
"user": "user@test.edulinq.org",
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
"user": edq.core.config.ConfigSource(
|
|
608
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
609
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
610
|
+
),
|
|
611
|
+
},
|
|
612
|
+
None,
|
|
613
|
+
),
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
# CLI Options:
|
|
617
|
+
|
|
618
|
+
# CLI arguments only (direct key: value).
|
|
619
|
+
(
|
|
620
|
+
"empty-dir",
|
|
621
|
+
{
|
|
622
|
+
"cli_arguments": {
|
|
623
|
+
edq.core.config.CONFIGS_KEY: [
|
|
624
|
+
"user=user@test.edulinq.org",
|
|
625
|
+
],
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
"user": "user@test.edulinq.org",
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
633
|
+
},
|
|
634
|
+
None,
|
|
635
|
+
),
|
|
636
|
+
|
|
637
|
+
# Empty Config Key
|
|
638
|
+
(
|
|
639
|
+
"empty-dir",
|
|
640
|
+
{
|
|
641
|
+
"cli_arguments": {
|
|
642
|
+
edq.core.config.CONFIGS_KEY: [
|
|
643
|
+
"=user@test.edulinq.org",
|
|
644
|
+
],
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
{},
|
|
648
|
+
{},
|
|
649
|
+
"Found an empty configuration option key associated with the value 'user@test.edulinq.org'.",
|
|
650
|
+
),
|
|
651
|
+
|
|
652
|
+
# Empty Config Value
|
|
653
|
+
(
|
|
654
|
+
"empty-dir",
|
|
655
|
+
{
|
|
656
|
+
"cli_arguments": {
|
|
657
|
+
edq.core.config.CONFIGS_KEY: [
|
|
658
|
+
"user=",
|
|
659
|
+
],
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"user": "",
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
667
|
+
},
|
|
668
|
+
None,
|
|
669
|
+
),
|
|
670
|
+
|
|
671
|
+
# Separator In Config Value
|
|
672
|
+
(
|
|
673
|
+
"empty-dir",
|
|
674
|
+
{
|
|
675
|
+
"cli_arguments": {
|
|
676
|
+
edq.core.config.CONFIGS_KEY: [
|
|
677
|
+
"pass=password=1234",
|
|
678
|
+
],
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
"pass": "password=1234",
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
"pass": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
686
|
+
},
|
|
687
|
+
None,
|
|
688
|
+
),
|
|
689
|
+
|
|
690
|
+
# Invalid Config Option Format
|
|
691
|
+
(
|
|
692
|
+
"empty-dir",
|
|
693
|
+
{
|
|
694
|
+
"cli_arguments": {
|
|
695
|
+
edq.core.config.CONFIGS_KEY: [
|
|
696
|
+
"useruser@test.edulinq.org",
|
|
697
|
+
],
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
{},
|
|
701
|
+
{},
|
|
702
|
+
"Invalid configuration option 'useruser@test.edulinq.org'.",
|
|
703
|
+
),
|
|
704
|
+
|
|
705
|
+
# Ignore Config Option
|
|
706
|
+
(
|
|
707
|
+
"empty-dir",
|
|
708
|
+
{
|
|
709
|
+
"cli_arguments": {
|
|
710
|
+
edq.core.config.CONFIGS_KEY: [
|
|
711
|
+
"user=user@test.edulinq.org",
|
|
712
|
+
"pass=password1234",
|
|
713
|
+
],
|
|
714
|
+
edq.core.config.IGNORE_CONFIGS_KEY:[
|
|
715
|
+
"pass",
|
|
716
|
+
],
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"user": "user@test.edulinq.org",
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
724
|
+
},
|
|
725
|
+
None,
|
|
726
|
+
),
|
|
727
|
+
|
|
728
|
+
# Ignore Non-Existing Config Option
|
|
729
|
+
(
|
|
730
|
+
"empty-dir",
|
|
731
|
+
{
|
|
732
|
+
"cli_arguments": {
|
|
733
|
+
edq.core.config.CONFIGS_KEY: [
|
|
734
|
+
"user=user@test.edulinq.org",
|
|
735
|
+
],
|
|
736
|
+
edq.core.config.IGNORE_CONFIGS_KEY:[
|
|
737
|
+
"non-existing-option",
|
|
738
|
+
],
|
|
739
|
+
},
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"user": "user@test.edulinq.org",
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
746
|
+
},
|
|
747
|
+
None,
|
|
748
|
+
),
|
|
749
|
+
|
|
750
|
+
# Combinations
|
|
751
|
+
|
|
752
|
+
# Global Config + Local Config
|
|
753
|
+
(
|
|
754
|
+
"simple",
|
|
755
|
+
{
|
|
756
|
+
"cli_arguments": {
|
|
757
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"user": "user@test.edulinq.org",
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
"user": edq.core.config.ConfigSource(
|
|
765
|
+
label = edq.core.config.CONFIG_SOURCE_LOCAL,
|
|
766
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
767
|
+
),
|
|
768
|
+
},
|
|
769
|
+
None,
|
|
770
|
+
),
|
|
771
|
+
|
|
772
|
+
# Global Config + CLI Provided Config
|
|
773
|
+
(
|
|
774
|
+
"empty-dir",
|
|
775
|
+
{
|
|
776
|
+
"cli_arguments": {
|
|
777
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
778
|
+
os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
779
|
+
],
|
|
780
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
"user": "user@test.edulinq.org",
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"user": edq.core.config.ConfigSource(
|
|
788
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
789
|
+
path = os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
790
|
+
),
|
|
791
|
+
},
|
|
792
|
+
None,
|
|
793
|
+
),
|
|
794
|
+
|
|
795
|
+
# Global + CLI Bare Options
|
|
796
|
+
(
|
|
797
|
+
"empty-dir",
|
|
798
|
+
{
|
|
799
|
+
"cli_arguments": {
|
|
800
|
+
edq.core.config.CONFIGS_KEY: [
|
|
801
|
+
"user=user@test.edulinq.org",
|
|
802
|
+
],
|
|
803
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
804
|
+
},
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
"user": "user@test.edulinq.org",
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
811
|
+
},
|
|
812
|
+
None,
|
|
813
|
+
),
|
|
814
|
+
|
|
815
|
+
# Local Config + CLI Provided Config
|
|
816
|
+
(
|
|
817
|
+
"simple",
|
|
818
|
+
{
|
|
819
|
+
"cli_arguments": {
|
|
820
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
821
|
+
os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
822
|
+
],
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"user": "user@test.edulinq.org",
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
"user": edq.core.config.ConfigSource(
|
|
830
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
831
|
+
path = os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
832
|
+
),
|
|
833
|
+
},
|
|
834
|
+
None,
|
|
835
|
+
),
|
|
836
|
+
|
|
837
|
+
# Local Config + CLI Bare Options
|
|
838
|
+
(
|
|
839
|
+
"simple",
|
|
840
|
+
{
|
|
841
|
+
"cli_arguments": {
|
|
842
|
+
edq.core.config.CONFIGS_KEY: [
|
|
843
|
+
"user=user@test.edulinq.org",
|
|
844
|
+
],
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
"user": "user@test.edulinq.org",
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
852
|
+
},
|
|
853
|
+
None,
|
|
854
|
+
),
|
|
855
|
+
|
|
856
|
+
# CLI Provided Config + CLI Bare Options
|
|
857
|
+
(
|
|
858
|
+
"empty-dir",
|
|
859
|
+
{
|
|
860
|
+
"cli_arguments": {
|
|
861
|
+
edq.core.config.CONFIGS_KEY: [
|
|
862
|
+
"user=user@test.edulinq.org",
|
|
863
|
+
],
|
|
864
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
865
|
+
os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
866
|
+
],
|
|
867
|
+
},
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
"user": "user@test.edulinq.org",
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
874
|
+
},
|
|
875
|
+
None,
|
|
876
|
+
),
|
|
877
|
+
|
|
878
|
+
# Global Config + CLI Provided Config + CLI Bare Options
|
|
879
|
+
(
|
|
880
|
+
"empty-dir",
|
|
881
|
+
{
|
|
882
|
+
"cli_arguments": {
|
|
883
|
+
edq.core.config.CONFIGS_KEY: [
|
|
884
|
+
"user=user@test.edulinq.org",
|
|
885
|
+
],
|
|
886
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
887
|
+
os.path.join(temp_dir, "simple", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
888
|
+
],
|
|
889
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
890
|
+
},
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
"user": "user@test.edulinq.org",
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
897
|
+
},
|
|
898
|
+
None,
|
|
899
|
+
),
|
|
900
|
+
|
|
901
|
+
# Global Config + Local Config + CLI Bare Options
|
|
902
|
+
(
|
|
903
|
+
"simple",
|
|
904
|
+
{
|
|
905
|
+
"cli_arguments": {
|
|
906
|
+
edq.core.config.CONFIGS_KEY: [
|
|
907
|
+
"user=user@test.edulinq.org",
|
|
908
|
+
],
|
|
909
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
910
|
+
},
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
"user": "user@test.edulinq.org",
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
917
|
+
},
|
|
918
|
+
None,
|
|
919
|
+
),
|
|
920
|
+
|
|
921
|
+
# Global Config + Local Config + CLI Provided Config
|
|
922
|
+
(
|
|
923
|
+
"simple",
|
|
924
|
+
{
|
|
925
|
+
"cli_arguments": {
|
|
926
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
927
|
+
os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
928
|
+
],
|
|
929
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
"user": "user@test.edulinq.org",
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
"user": edq.core.config.ConfigSource(
|
|
937
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
938
|
+
path = os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
939
|
+
),
|
|
940
|
+
},
|
|
941
|
+
None,
|
|
942
|
+
),
|
|
943
|
+
|
|
944
|
+
# Local Config + CLI Provided Config + CLI Bare Options
|
|
945
|
+
(
|
|
946
|
+
"simple",
|
|
947
|
+
{
|
|
948
|
+
"cli_arguments": {
|
|
949
|
+
edq.core.config.CONFIGS_KEY: [
|
|
950
|
+
"user=user@test.edulinq.org",
|
|
951
|
+
],
|
|
952
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
953
|
+
os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
954
|
+
],
|
|
955
|
+
},
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
"user": "user@test.edulinq.org",
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
"user": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
962
|
+
},
|
|
963
|
+
None,
|
|
964
|
+
),
|
|
965
|
+
|
|
966
|
+
# Global Config + Local Config + CLI Provided Config + CLI Bare Options
|
|
967
|
+
(
|
|
968
|
+
"simple",
|
|
969
|
+
{
|
|
970
|
+
"cli_arguments": {
|
|
971
|
+
edq.core.config.CONFIG_PATHS_KEY: [
|
|
972
|
+
os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
973
|
+
],
|
|
974
|
+
edq.core.config.CONFIGS_KEY: [
|
|
975
|
+
"pass=password1234",
|
|
976
|
+
],
|
|
977
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "global", edq.core.config.DEFAULT_CONFIG_FILENAME),
|
|
978
|
+
},
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
"user": "user@test.edulinq.org",
|
|
982
|
+
"pass": "password1234",
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
"user": edq.core.config.ConfigSource(
|
|
986
|
+
label = edq.core.config.CONFIG_SOURCE_CLI_FILE,
|
|
987
|
+
path = os.path.join(temp_dir, "custom-name", "custom-edq-config.json"),
|
|
988
|
+
),
|
|
989
|
+
"pass": edq.core.config.ConfigSource(label = edq.core.config.CONFIG_SOURCE_CLI),
|
|
990
|
+
},
|
|
991
|
+
None,
|
|
992
|
+
),
|
|
993
|
+
]
|
|
994
|
+
|
|
995
|
+
for (i, test_case) in enumerate(test_cases):
|
|
996
|
+
(test_work_dir, extra_args, expected_config, expected_source, error_substring) = test_case
|
|
997
|
+
|
|
998
|
+
with self.subTest(msg = f"Case {i} ('{test_work_dir}'):"):
|
|
999
|
+
cli_args = extra_args.get("cli_arguments", None)
|
|
1000
|
+
if cli_args is None:
|
|
1001
|
+
extra_args["cli_arguments"] = {
|
|
1002
|
+
edq.core.config.GLOBAL_CONFIG_KEY: os.path.join(temp_dir, "empty", edq.core.config.DEFAULT_CONFIG_FILENAME)
|
|
1003
|
+
}
|
|
1004
|
+
else:
|
|
1005
|
+
cli_global_config_path = cli_args.get(edq.core.config.GLOBAL_CONFIG_KEY, None)
|
|
1006
|
+
if cli_global_config_path is None:
|
|
1007
|
+
extra_args["cli_arguments"][edq.core.config.GLOBAL_CONFIG_KEY] = os.path.join(
|
|
1008
|
+
temp_dir, "empty", edq.core.config.DEFAULT_CONFIG_FILENAME
|
|
1009
|
+
)
|
|
1010
|
+
|
|
1011
|
+
cutoff = extra_args.get("local_config_root_cutoff", None)
|
|
1012
|
+
if (cutoff is None):
|
|
1013
|
+
extra_args["local_config_root_cutoff"] = temp_dir
|
|
1014
|
+
|
|
1015
|
+
previous_work_directory = os.getcwd()
|
|
1016
|
+
initial_work_directory = os.path.join(temp_dir, test_work_dir)
|
|
1017
|
+
os.chdir(initial_work_directory)
|
|
1018
|
+
|
|
1019
|
+
try:
|
|
1020
|
+
(actual_config, actual_sources) = edq.core.config.get_tiered_config(**extra_args)
|
|
1021
|
+
except Exception as ex:
|
|
1022
|
+
error_string = self.format_error_string(ex)
|
|
1023
|
+
|
|
1024
|
+
if (error_substring is None):
|
|
1025
|
+
self.fail(f"Unexpected error: '{error_string}'.")
|
|
1026
|
+
|
|
1027
|
+
self.assertIn(error_substring, error_string, 'Error is not as expected.')
|
|
1028
|
+
|
|
1029
|
+
continue
|
|
1030
|
+
|
|
1031
|
+
finally:
|
|
1032
|
+
os.chdir(previous_work_directory)
|
|
1033
|
+
|
|
1034
|
+
if (error_substring is not None):
|
|
1035
|
+
self.fail(f"Did not get expected error: '{error_substring}'.")
|
|
1036
|
+
|
|
1037
|
+
self.assertJSONDictEqual(expected_config, actual_config)
|
|
1038
|
+
self.assertJSONDictEqual(expected_source, actual_sources)
|