diff options
author | Alessio Ababilov <aababilov@griddynamics.com> | 2013-06-10 10:49:59 +0300 |
---|---|---|
committer | Alessio Ababilov <ilovegnulinux@gmail.com> | 2013-06-11 20:05:49 +0300 |
commit | 472d8ed162ffc0b1083b761627a8ed86e7d71ae7 (patch) | |
tree | e7c23277b4d5d44dcb4d799c6af815a9214d0345 /tests | |
parent | faddbbe318cf62791624469c4304ae4fdcc2e639 (diff) | |
download | oslo-472d8ed162ffc0b1083b761627a8ed86e7d71ae7.tar.gz oslo-472d8ed162ffc0b1083b761627a8ed86e7d71ae7.tar.xz oslo-472d8ed162ffc0b1083b761627a8ed86e7d71ae7.zip |
Add slugify to strutils
This function will be used in apiclient library.
Change-Id: I19f976eda896e7bede07510aafebe4931e512351
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_strutils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unit/test_strutils.py b/tests/unit/test_strutils.py index 42160a6..a8d8462 100644 --- a/tests/unit/test_strutils.py +++ b/tests/unit/test_strutils.py @@ -198,3 +198,18 @@ class StrUtilsTest(utils.BaseTestCase): ] for v in breaking_examples: self.assertRaises(TypeError, strutils.to_bytes, v) + + def test_slugify(self): + to_slug = strutils.to_slug + self.assertRaises(TypeError, to_slug, True) + self.assertEqual(six.u("hello"), to_slug("hello")) + self.assertEqual(six.u("two-words"), to_slug("Two Words")) + self.assertEqual(six.u("ma-any-spa-ce-es"), + to_slug("Ma-any\t spa--ce- es")) + self.assertEqual(six.u("excamation"), to_slug("exc!amation!")) + self.assertEqual(six.u("ampserand"), to_slug("&ser$and")) + self.assertEqual(six.u("ju5tnum8er"), to_slug("ju5tnum8er")) + self.assertEqual(six.u("strip-"), to_slug(" strip - ")) + self.assertEqual(six.u("perche"), to_slug("perch\xc3\xa9")) + self.assertEqual(six.u("strange"), + to_slug("\x80strange", errors="ignore")) |