2023-03-21 13:21:03 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2016-11-23 23:49:53 +00:00
|
|
|
from django.core.management import call_command
|
|
|
|
|
from django.test import TestCase
|
|
|
|
|
|
|
|
|
|
from model_utils.fields import get_excerpt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MigrationsTests(TestCase):
|
2023-03-22 17:50:18 +00:00
|
|
|
def test_makemigrations(self) -> None:
|
2016-11-23 23:49:53 +00:00
|
|
|
call_command('makemigrations', dry_run=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GetExcerptTests(TestCase):
|
2023-03-22 17:50:18 +00:00
|
|
|
def test_split(self) -> None:
|
2016-11-23 23:49:53 +00:00
|
|
|
e = get_excerpt("some content\n\n<!-- split -->\n\nsome more")
|
|
|
|
|
self.assertEqual(e, 'some content\n')
|
|
|
|
|
|
2023-03-22 17:50:18 +00:00
|
|
|
def test_auto_split(self) -> None:
|
2016-11-23 23:49:53 +00:00
|
|
|
e = get_excerpt("para one\n\npara two\n\npara three")
|
|
|
|
|
self.assertEqual(e, 'para one\n\npara two')
|
|
|
|
|
|
2023-03-22 17:50:18 +00:00
|
|
|
def test_middle_of_para(self) -> None:
|
2016-11-23 23:49:53 +00:00
|
|
|
e = get_excerpt("some text\n<!-- split -->\nmore text")
|
|
|
|
|
self.assertEqual(e, 'some text')
|
|
|
|
|
|
2023-03-22 17:50:18 +00:00
|
|
|
def test_middle_of_line(self) -> None:
|
2016-11-23 23:49:53 +00:00
|
|
|
e = get_excerpt("some text <!-- split --> more text")
|
|
|
|
|
self.assertEqual(e, "some text <!-- split --> more text")
|