-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update and simplify tests in test_template.py
- Loading branch information
1 parent
bf1361d
commit 61499c1
Showing
3 changed files
with
61 additions
and
54 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,24 @@ | ||
""" | ||
Useful utilities for testing tagging and taxonomy code. | ||
""" | ||
|
||
|
||
def pretty_format_tags(result, parent=True, external_id=False, usage_count=True) -> list[str]: | ||
""" | ||
Format the result of get_filtered_tags() to be more human readable. | ||
Also works with other wrappers around get_filtered_tags, like api.get_tags() | ||
""" | ||
pretty_results = [] | ||
for t in result: | ||
line = f"{t['depth'] * ' '}{t['value']} " | ||
if external_id: | ||
line += f"({t['external_id']}) " | ||
if parent: | ||
line += f"({t['parent_value']}) " | ||
line += "(" | ||
if usage_count: | ||
line += f"used: {t.get('usage_count', '?')}, " | ||
line += f"children: {t['child_count']})" | ||
pretty_results.append(line) | ||
return pretty_results |