Skip to content

Commit 5e5904a

Browse files
committed
squash! package.UserDefinedMapping: Include source of mapping in Package objects
Expand the UserDefinedMapping unit tests in test_packages to also test the keys/descriptions in Package.mappings, not only the .import_names member.
1 parent f337dd8 commit 5e5904a

File tree

1 file changed

+62
-9
lines changed

1 file changed

+62
-9
lines changed

tests/test_packages.py

+62-9
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,21 @@ def test_package__both_mappings():
161161
"""
162162
],
163163
None,
164-
{"apache_airflow": ["airflow"], "attrs": ["attr", "attrs"]},
164+
{
165+
"apache_airflow": Package(
166+
"apache_airflow",
167+
{"User-defined mapping from {tmp_path}/mapping0.toml": {"airflow"}},
168+
),
169+
"attrs": Package(
170+
"attrs",
171+
{
172+
"User-defined mapping from {tmp_path}/mapping0.toml": {
173+
"attr",
174+
"attrs",
175+
}
176+
},
177+
),
178+
},
165179
id="well_formated_input_file__parses_correctly",
166180
),
167181
pytest.param(
@@ -177,9 +191,28 @@ def test_package__both_mappings():
177191
],
178192
None,
179193
{
180-
"apache_airflow": ["airflow", "baz"],
181-
"attrs": ["attr", "attrs"],
182-
"foo": ["bar"],
194+
"apache_airflow": Package(
195+
"apache_airflow",
196+
{
197+
"User-defined mapping from {tmp_path}/mapping0.toml": {
198+
"airflow"
199+
},
200+
"User-defined mapping from {tmp_path}/mapping1.toml": {"baz"},
201+
},
202+
),
203+
"attrs": Package(
204+
"attrs",
205+
{
206+
"User-defined mapping from {tmp_path}/mapping0.toml": {
207+
"attr",
208+
"attrs",
209+
}
210+
},
211+
),
212+
"foo": Package(
213+
"foo",
214+
{"User-defined mapping from {tmp_path}/mapping1.toml": {"bar"}},
215+
),
183216
},
184217
id="well_formated_input_2files__parses_correctly",
185218
),
@@ -196,9 +229,29 @@ def test_package__both_mappings():
196229
],
197230
{"apache-airflow": ["unicorn"]},
198231
{
199-
"apache_airflow": ["airflow", "baz", "unicorn"],
200-
"attrs": ["attr", "attrs"],
201-
"foo": ["bar"],
232+
"apache_airflow": Package(
233+
"apache_airflow",
234+
{
235+
"User-defined mapping from {tmp_path}/mapping0.toml": {
236+
"airflow"
237+
},
238+
"User-defined mapping from {tmp_path}/mapping1.toml": {"baz"},
239+
"User-defined mapping from settings": {"unicorn"},
240+
},
241+
),
242+
"attrs": Package(
243+
"attrs",
244+
{
245+
"User-defined mapping from {tmp_path}/mapping0.toml": {
246+
"attr",
247+
"attrs",
248+
}
249+
},
250+
),
251+
"foo": Package(
252+
"foo",
253+
{"User-defined mapping from {tmp_path}/mapping1.toml": {"bar"}},
254+
),
202255
},
203256
id="well_formated_input_2files_and_config__parses_correctly",
204257
),
@@ -219,8 +272,8 @@ def test_user_defined_mapping__well_formated_input_file__parses_correctly(
219272
udm = UserDefinedMapping(
220273
mapping_paths=custom_mapping_files, custom_mapping=custom_mapping
221274
)
222-
mapped_packages = {k: sorted(list(v.import_names)) for k, v in udm.packages.items()}
223-
assert mapped_packages == expect
275+
expect = expand_package_mappings_placeholders(expect, tmp_path=tmp_path)
276+
assert udm.packages == expect
224277

225278

226279
def test_user_defined_mapping__input_is_no_file__raises_unparsable_path_exeption():

0 commit comments

Comments
 (0)