aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_slugify.py
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2015-08-26 07:57:23 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2015-08-26 07:57:23 -0300
commit70ceb871117ca811d63cb02671dc0fefc2700883 (patch)
tree846133ea39797d2cd1101cff2ac0818167353490 /tests/test_slugify.py
parent8559119e2f45b7f6508282962c0430423bfab051 (diff)
parent787b97a4cb24330b36f11297c6d3a7a473a907d0 (diff)
Merge tag 'upstream/7.6.4'
Upstream version 7.6.4
Diffstat (limited to 'tests/test_slugify.py')
-rw-r--r--tests/test_slugify.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/test_slugify.py b/tests/test_slugify.py
new file mode 100644
index 0000000..9dec5a6
--- /dev/null
+++ b/tests/test_slugify.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+
+u"""Test slugify."""
+
+from __future__ import unicode_literals
+import nikola.utils
+
+
+def test_ascii():
+ """Test an ASCII-only string."""
+ o = nikola.utils.slugify(u'hello')
+ assert o == u'hello'
+ assert isinstance(o, nikola.utils.unicode_str)
+
+
+def test_ascii_dash():
+ """Test an ASCII string, with dashes."""
+ o = nikola.utils.slugify(u'hello-world')
+ assert o == u'hello-world'
+ assert isinstance(o, nikola.utils.unicode_str)
+
+
+def test_ascii_fancy():
+ """Test an ASCII string, with fancy characters."""
+ o = nikola.utils.slugify(u'The quick brown fox jumps over the lazy dog!-123.456')
+ assert o == u'the-quick-brown-fox-jumps-over-the-lazy-dog-123456'
+ assert isinstance(o, nikola.utils.unicode_str)
+
+
+def test_pl():
+ """Test a string with Polish diacritical characters."""
+ o = nikola.utils.slugify(u'zażółćgęśląjaźń')
+ assert o == u'zazolcgeslajazn'
+ assert isinstance(o, nikola.utils.unicode_str)
+
+
+def test_pl_dash():
+ """Test a string with Polish diacritical characters and dashes."""
+ o = nikola.utils.slugify(u'zażółć-gęślą-jaźń')
+ assert o == u'zazolc-gesla-jazn'
+
+
+def test_pl_fancy():
+ """Test a string with Polish diacritical characters and fancy characters."""
+ o = nikola.utils.slugify(u'Zażółć gęślą jaźń!-123.456')
+ assert o == u'zazolc-gesla-jazn-123456'
+ assert isinstance(o, nikola.utils.unicode_str)
+
+
+def test_disarmed():
+ """Test disarmed slugify."""
+ nikola.utils.USE_SLUGIFY = False
+ o = nikola.utils.slugify(u'Zażółć gęślą jaźń!-123.456')
+ assert o == u'Zażółć gęślą jaźń!-123.456'
+ assert isinstance(o, nikola.utils.unicode_str)
+ nikola.utils.USE_SLUGIFY = True
+
+
+def test_disarmed_weird():
+ """Test disarmed slugify with banned characters."""
+ nikola.utils.USE_SLUGIFY = False
+ o = nikola.utils.slugify(u'Zażółć gęślą jaźń!-123.456 "Hello World"?#H<e>l/l\\o:W\'o\rr*l\td|!\n')
+ assert o == u'Zażółć gęślą jaźń!-123.456 -Hello World---H-e-l-l-o-W-o-r-l-d-!-'
+ assert isinstance(o, nikola.utils.unicode_str)
+ nikola.utils.USE_SLUGIFY = True