-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metadata filtering config is a dictionary #110
- Loading branch information
Showing
6 changed files
with
88 additions
and
40 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
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 |
---|---|---|
@@ -1,28 +1,41 @@ | ||
from jupytext.metadata_filter import filter_metadata | ||
import pytest | ||
from jupytext.metadata_filter import filter_metadata, metadata_filter_as_dict | ||
|
||
|
||
def to_dict(keys): | ||
return {key: None for key in keys} | ||
|
||
|
||
@pytest.mark.parametrize('metadata_filter_string,metadata_filter_dict', | ||
[('all, -widgets,-varInspector', | ||
{'additional': 'all', 'excluded': ['widgets', 'varInspector']}), | ||
('toc', {'additional': ['toc']}), | ||
('+ toc', {'additional': ['toc']}), | ||
('preserve,-all', {'additional': ['preserve'], 'excluded': 'all'}), | ||
('ExecuteTime, autoscroll, -hide_output', | ||
{'additional': ['ExecuteTime', 'autoscroll'], 'excluded': ['hide_output']})]) | ||
def test_string_to_dict_conversion(metadata_filter_string, metadata_filter_dict): | ||
assert metadata_filter_as_dict(metadata_filter_string) == metadata_filter_dict | ||
|
||
|
||
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' | ||
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' | ||
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' | ||
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' | ||
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' | ||
assert filter_metadata(to_dict(['technical', 'user', 'preserve']), 'user,-all', 'preserve' | ||
) == to_dict(['user']) |
d110433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#105