-
Notifications
You must be signed in to change notification settings - Fork 3
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 @@ | ||
#! python3 # noqa E265 | ||
|
||
""" | ||
Usage from the repo root folder: | ||
.. code-block:: bash | ||
# for whole tests | ||
python -m unittest tests.test_utils_slugifier | ||
# for specific test | ||
python -m unittest tests.test_utils.TestUtilsSlugify.test_slugger | ||
""" | ||
|
||
# standard library | ||
import unittest | ||
|
||
# project | ||
from qgis_deployment_toolbelt.utils.slugger import sluggy | ||
|
||
# ############################################################################ | ||
# ########## Classes ############# | ||
# ################################ | ||
|
||
|
||
class TestUtilsSlugify(unittest.TestCase): | ||
"""Test package utilities.""" | ||
|
||
def test_slugger(self): | ||
"""Test minimalist slugify function.""" | ||
# hyphen by default | ||
self.assertEqual( | ||
sluggy("Oyé oyé brâves gens de 1973 ! Hé oh ! Sentons-nous l'ail %$*§ ?!"), | ||
"oye-oye-braves-gens-de-1973-he-oh-sentons-nous-lail", | ||
) | ||
|
||
# with underscore | ||
self.assertEqual( | ||
sluggy("Nín hǎo. Wǒ shì zhōng guó rén", "_"), | ||
"nin_hao_wo_shi_zhong_guo_ren", | ||
) | ||
|
||
|
||
# ############################################################################ | ||
# ####### Stand-alone run ######## | ||
# ################################ | ||
if __name__ == "__main__": | ||
unittest.main() |