diff --git a/wagtail/wagtailadmin/tests/test_blocks.py b/wagtail/wagtailadmin/tests/test_blocks.py index 2de2aeb5d..c4a430321 100644 --- a/wagtail/wagtailadmin/tests/test_blocks.py +++ b/wagtail/wagtailadmin/tests/test_blocks.py @@ -201,6 +201,20 @@ class TestStructBlock(unittest.TestCase): self.assertIn('
', html) self.assertIn('', html) + def test_render_form_uses_default_value(self): + class LinkBlock(blocks.StructBlock): + title = blocks.FieldBlock(forms.CharField(), default="Torchbox") + link = blocks.FieldBlock(forms.URLField(), default="http://www.torchbox.com") + + block = LinkBlock() + html = block.render_form({}, prefix='mylink') + + self.assertIn('
', html) + self.assertIn('
', html) + self.assertIn('', html) + self.assertIn('
', html) + self.assertIn('', html) + class TestListBlock(unittest.TestCase): def test_initialise_with_class(self): @@ -261,7 +275,7 @@ class TestListBlock(unittest.TestCase): html = self.render_form() self.assertIn('', html) - self.assertIn('', html) + self.assertIn('', html) def test_render_form_values(self): html = self.render_form() @@ -271,6 +285,28 @@ class TestListBlock(unittest.TestCase): self.assertIn('', html) self.assertIn('', html) + def test_html_declarations(self): + class LinkBlock(blocks.StructBlock): + title = blocks.FieldBlock(forms.CharField()) + link = blocks.FieldBlock(forms.URLField()) + + block = blocks.ListBlock(LinkBlock) + html = block.html_declarations() + + self.assertIn('', html) + self.assertIn('', html) + + def test_html_declarations_uses_default(self): + class LinkBlock(blocks.StructBlock): + title = blocks.FieldBlock(forms.CharField(), default="Github") + link = blocks.FieldBlock(forms.URLField(), default="http://www.github.com") + + block = blocks.ListBlock(LinkBlock) + html = block.html_declarations() + + self.assertIn('', html) + self.assertIn('', html) + class TestStreamBlock(unittest.TestCase): def test_initialisation(self): @@ -426,3 +462,25 @@ class TestStreamBlock(unittest.TestCase): self.assertIn('', html) self.assertIn('', html) self.assertIn('', html) + + def test_html_declarations(self): + class LinkBlock(blocks.StructBlock): + title = blocks.FieldBlock(forms.CharField()) + link = blocks.FieldBlock(forms.URLField()) + + block = blocks.ListBlock(LinkBlock) + html = block.html_declarations() + + self.assertIn('', html) + self.assertIn('', html) + + def test_html_declarations_uses_default(self): + class LinkBlock(blocks.StructBlock): + title = blocks.FieldBlock(forms.CharField(), default="Github") + link = blocks.FieldBlock(forms.URLField(), default="http://www.github.com") + + block = blocks.ListBlock(LinkBlock) + html = block.html_declarations() + + self.assertIn('', html) + self.assertIn('', html)