31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from books.factories import ModuleFactory
|
|
from books.models import Chapter
|
|
from core.tests.base_test import SkillboxTestCase
|
|
from django.test.client import Client
|
|
|
|
|
|
class TestChapterCreation(SkillboxTestCase):
|
|
"""Test created for Issue MS-932"""
|
|
|
|
def setUp(self) -> None:
|
|
self.createDefault()
|
|
self.module = ModuleFactory(slug="my-module")
|
|
self.Client = Client()
|
|
self.client.login(username="admin", password="test")
|
|
|
|
def test_create_chapter_creates_slug_automatically(self):
|
|
new_chapter = Chapter(title="New Chapter")
|
|
self.module.add_child(instance=new_chapter)
|
|
new_chapter.save()
|
|
self.assertEqual("new-chapter", new_chapter.slug)
|
|
|
|
def test_create_chapter_creates_slug_automatically_if_existing(self):
|
|
new_chapter = Chapter(title="New Chapter")
|
|
self.module.add_child(instance=new_chapter)
|
|
new_chapter.save()
|
|
self.assertEqual("new-chapter", new_chapter.slug)
|
|
new_chapter2 = Chapter(title="New Chapter")
|
|
self.module.add_child(instance=new_chapter2)
|
|
new_chapter2.save()
|
|
self.assertEqual("new-chapter-2", new_chapter2.slug)
|