refactor: added utility to convert title into slug

This commit is contained in:
Anand Chitipothu
2021-04-06 15:18:34 +05:30
parent 253c25bf1f
commit 6620ecf0c8
2 changed files with 47 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import unittest
from .utils import slugify
class TestSlugify(unittest.TestCase):
def test_simple(self):
self.assertEquals(slugify("hello-world"), "hello-world")
self.assertEquals(slugify("Hello World"), "hello-world")
self.assertEquals(slugify("Hello, World!"), "hello-world")
def test_duplicates(self):
self.assertEquals(
slugify("Hello World", ['hello-world']),
"hello-world-2")
self.assertEquals(
slugify("Hello World", ['hello-world', 'hello-world-2']),
"hello-world-3")