-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support lists in 'resolve_keyed_by'
- Loading branch information
Showing
4 changed files
with
87 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
from pprint import pprint | ||
|
||
import pytest | ||
|
||
from taskgraph.util.keyed_by import iter_dot_path | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"container,subfield,expected", | ||
( | ||
pytest.param( | ||
{"a": {"b": {"c": 1}}, "d": 2}, "a.b.c", [({"c": 1}, "c")], id="simple case" | ||
), | ||
pytest.param( | ||
{"a": [{"b": 1}, {"b": 2}, {"b": 3}], "d": 2}, | ||
"a.b", | ||
[({"b": 1}, "b"), ({"b": 2}, "b"), ({"b": 3}, "b")], | ||
id="list case", | ||
), | ||
), | ||
) | ||
def test_iter_dot_paths(container, subfield, expected): | ||
result = list(iter_dot_path(container, subfield)) | ||
pprint(result, indent=2) | ||
assert result == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters