-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 changed file
with
46 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from harvester.ckan_utils import munge_tag, munge_title_to_name | ||
import pytest | ||
|
||
# these tests are copied from | ||
# https://github.com/ckan/ckan/blob/master/ckan/tests/lib/test_munge.py | ||
|
||
|
||
class TestCKANUtils: | ||
@pytest.mark.parametrize( | ||
"original,expected", | ||
[ | ||
("unchanged", "unchanged"), | ||
("s", "s_"), # too short | ||
("some spaces here", "some-spaces--here"), | ||
("random:other%characters&_.here", "randomothercharactershere"), | ||
("river-water-dashes", "river-water-dashes"), | ||
], | ||
) | ||
def test_munge_tag_multiple_pass(self, original, expected): | ||
"""Munge a list of tags muliple times gives expected results.""" | ||
|
||
first_munge = munge_tag(original) | ||
assert first_munge == expected | ||
second_munge = munge_tag(first_munge) | ||
assert second_munge == expected | ||
|
||
@pytest.mark.parametrize( | ||
"original,expected", | ||
[ | ||
("unchanged", "unchanged"), | ||
("some spaces here &here", "some-spaces-here-here"), | ||
("s", "s_"), # too short | ||
("random:other%character&", "random-othercharacter"), | ||
("u with umlaut \xfc", "u-with-umlaut-u"), | ||
("reallylong" * 12, "reallylong" * 9 + "reall"), | ||
("reallylong" * 12 + " - 2012", "reallylong" * 9 + "-2012"), | ||
( | ||
"10cm - 50cm Near InfraRed (NI) Digital Aerial Photography (AfA142)", | ||
"10cm-50cm-near-infrared-ni-digital-aerial-photography-afa142", | ||
), | ||
], | ||
) | ||
def test_munge_title_to_name(self, original, expected): | ||
"""Munge a list of names gives expected results.""" | ||
munge = munge_title_to_name(original) | ||
assert munge == expected |
6977d3e
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.
Coverage Report