0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

split up tests for RichText() and RichTextBlock.get_default()

This commit is contained in:
Matt Westcott 2015-06-01 14:46:24 +01:00
parent 1c510a04c8
commit 9a864ff6c9
2 changed files with 8 additions and 2 deletions

View File

@ -110,23 +110,27 @@ class TestFieldBlock(unittest.TestCase):
class TestRichTextBlock(TestCase):
fixtures = ['test.json']
def test_get_default(self):
def test_get_default_with_fallback_value(self):
default_value = blocks.RichTextBlock().get_default()
self.assertTrue(isinstance(default_value, RichText))
self.assertEqual(default_value.source, '')
def test_get_default_with_default_none(self):
default_value = blocks.RichTextBlock(default=None).get_default()
self.assertTrue(isinstance(default_value, RichText))
self.assertEqual(default_value.source, '')
def test_get_default_with_empty_string(self):
default_value = blocks.RichTextBlock(default='').get_default()
self.assertTrue(isinstance(default_value, RichText))
self.assertEqual(default_value.source, '')
def test_get_default_with_nonempty_string(self):
default_value = blocks.RichTextBlock(default='<p>foo</p>').get_default()
self.assertTrue(isinstance(default_value, RichText))
self.assertEqual(default_value.source, '<p>foo</p>')
def test_get_default_with_richtext_value(self):
default_value = blocks.RichTextBlock(default=RichText('<p>foo</p>')).get_default()
self.assertTrue(isinstance(default_value, RichText))
self.assertEqual(default_value.source, '<p>foo</p>')

View File

@ -121,13 +121,15 @@ class TestExpandDbHtml(TestCase):
class TestRichTextValue(TestCase):
fixtures = ['test.json']
def test_construct(self):
def test_construct_with_none(self):
value = RichText(None)
self.assertEqual(value.source, '')
def test_construct_with_empty_string(self):
value = RichText('')
self.assertEqual(value.source, '')
def test_construct_with_nonempty_string(self):
value = RichText('<p>hello world</p>')
self.assertEqual(value.source, '<p>hello world</p>')