Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for utils.slugifier #165

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/test_utils_slugifier.py
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()