-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from jupytext.metadata_filter import filter_metadata | ||
|
||
|
||
def to_dict(keys): | ||
return {key: None for key in keys} | ||
|
||
|
||
def test_metadata_filter_default(): | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), None, '-technical' | ||
) == to_dict(['user', 'preserve']) | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), None, 'preserve-all' | ||
) == to_dict(['preserve']) | ||
|
||
|
||
def test_metadata_filter_user_plus_default(): | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), '-user', '-technical' | ||
) == to_dict(['preserve']) | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), 'all-user', '-technical' | ||
) == to_dict(['preserve', 'technical']) | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), 'user', 'preserve-all' | ||
) == to_dict(['user', 'preserve']) | ||
|
||
|
||
def test_metadata_filter_user_overrides_default(): | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), 'all-user', '-technical' | ||
) == to_dict(['technical', 'preserve']) | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), 'user-all', 'preserve' | ||
) == to_dict(['user']) |