kopia lustrzana https://github.com/wagtail/wagtail
split up tests for RichText() and RichTextBlock.get_default()
rodzic
1c510a04c8
commit
9a864ff6c9
|
@ -110,23 +110,27 @@ class TestFieldBlock(unittest.TestCase):
|
||||||
class TestRichTextBlock(TestCase):
|
class TestRichTextBlock(TestCase):
|
||||||
fixtures = ['test.json']
|
fixtures = ['test.json']
|
||||||
|
|
||||||
def test_get_default(self):
|
def test_get_default_with_fallback_value(self):
|
||||||
default_value = blocks.RichTextBlock().get_default()
|
default_value = blocks.RichTextBlock().get_default()
|
||||||
self.assertTrue(isinstance(default_value, RichText))
|
self.assertTrue(isinstance(default_value, RichText))
|
||||||
self.assertEqual(default_value.source, '')
|
self.assertEqual(default_value.source, '')
|
||||||
|
|
||||||
|
def test_get_default_with_default_none(self):
|
||||||
default_value = blocks.RichTextBlock(default=None).get_default()
|
default_value = blocks.RichTextBlock(default=None).get_default()
|
||||||
self.assertTrue(isinstance(default_value, RichText))
|
self.assertTrue(isinstance(default_value, RichText))
|
||||||
self.assertEqual(default_value.source, '')
|
self.assertEqual(default_value.source, '')
|
||||||
|
|
||||||
|
def test_get_default_with_empty_string(self):
|
||||||
default_value = blocks.RichTextBlock(default='').get_default()
|
default_value = blocks.RichTextBlock(default='').get_default()
|
||||||
self.assertTrue(isinstance(default_value, RichText))
|
self.assertTrue(isinstance(default_value, RichText))
|
||||||
self.assertEqual(default_value.source, '')
|
self.assertEqual(default_value.source, '')
|
||||||
|
|
||||||
|
def test_get_default_with_nonempty_string(self):
|
||||||
default_value = blocks.RichTextBlock(default='<p>foo</p>').get_default()
|
default_value = blocks.RichTextBlock(default='<p>foo</p>').get_default()
|
||||||
self.assertTrue(isinstance(default_value, RichText))
|
self.assertTrue(isinstance(default_value, RichText))
|
||||||
self.assertEqual(default_value.source, '<p>foo</p>')
|
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()
|
default_value = blocks.RichTextBlock(default=RichText('<p>foo</p>')).get_default()
|
||||||
self.assertTrue(isinstance(default_value, RichText))
|
self.assertTrue(isinstance(default_value, RichText))
|
||||||
self.assertEqual(default_value.source, '<p>foo</p>')
|
self.assertEqual(default_value.source, '<p>foo</p>')
|
||||||
|
|
|
@ -121,13 +121,15 @@ class TestExpandDbHtml(TestCase):
|
||||||
class TestRichTextValue(TestCase):
|
class TestRichTextValue(TestCase):
|
||||||
fixtures = ['test.json']
|
fixtures = ['test.json']
|
||||||
|
|
||||||
def test_construct(self):
|
def test_construct_with_none(self):
|
||||||
value = RichText(None)
|
value = RichText(None)
|
||||||
self.assertEqual(value.source, '')
|
self.assertEqual(value.source, '')
|
||||||
|
|
||||||
|
def test_construct_with_empty_string(self):
|
||||||
value = RichText('')
|
value = RichText('')
|
||||||
self.assertEqual(value.source, '')
|
self.assertEqual(value.source, '')
|
||||||
|
|
||||||
|
def test_construct_with_nonempty_string(self):
|
||||||
value = RichText('<p>hello world</p>')
|
value = RichText('<p>hello world</p>')
|
||||||
self.assertEqual(value.source, '<p>hello world</p>')
|
self.assertEqual(value.source, '<p>hello world</p>')
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue