def testHtmlPageForm(self): from djpcms.apps.contentedit import HtmlPageForm from djpcms.html.layout import grid l = HtmlPageForm['layout'] self.assertTrue(l) # the columns are the second child (first is the message holder) columns = l.children[1] self.assertEqual(len(columns.children), 2) self.assertEqual(columns.grid, grid('grid 50-50')) w = HtmlPageForm() text = w.render() self.assertTrue(text)
def testInitialPageForm(self): '''Test the Page Form''' from djpcms.apps.contentedit import HtmlPageForm d = dict(HtmlPageForm.form_class.initials()) self.assertTrue(d) ph = HtmlPageForm() p = ph.form self.assertFalse(p.is_bound) initial = p.initial self.assertEqual(initial['in_navigation'], 0) self.assertEqual(d, initial)
def testPageFormBound(self): from djpcms.apps.contentedit import HtmlPageForm from stdcms.cms.models import Page from stdnet import odm d = self.page_data() p = HtmlPageForm(data=d) form = p.form self.assertFalse(p.is_valid()) p = HtmlPageForm(data=d, model=Page) self.assertTrue(p.is_valid()) page = p.form.save() page = Page.objects.get(id=page.id) for k, v in d.items(): self.assertEqual(getattr(page, k), v) p = HtmlPageForm(instance=page) dp = p.form.initial for k, v in d.items(): self.assertEqual(dp[k], v) # Now we test the rendered form w = p.addAttr('action', '/test/') html = w.render() self.assertTrue('value="0"' in html)
def testPageFormBound(self): from djpcms.apps.contentedit import HtmlPageForm from stdcms.cms.models import Page from stdnet import odm d = self.page_data() p = HtmlPageForm(data=d) form = p.form self.assertFalse(p.is_valid()) p = HtmlPageForm(data=d, model=Page) self.assertTrue(p.is_valid()) page = p.form.save() page = Page.objects.get(id = page.id) for k,v in d.items(): self.assertEqual(getattr(page,k),v) p = HtmlPageForm(instance = page) dp = p.form.initial for k,v in d.items(): self.assertEqual(dp[k],v) # Now we test the rendered form w = p.addAttr('action','/test/') html = w.render() self.assertTrue('value="0"' in html)