def test_form_render(self): block = SnippetChooserBlock(AdvertWithCustomPrimaryKey, help_text="pick an advert, any advert") empty_form_html = block.render_form(None, 'advertwithcustomprimarykey') self.assertInHTML('<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" />', empty_form_html) self.assertIn('createSnippetChooser("advertwithcustomprimarykey", "tests/advertwithcustomprimarykey");', empty_form_html) test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01') test_advert_form_html = block.render_form(test_advert, 'advertwithcustomprimarykey') expected_html = '<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" value="%s" />' % test_advert.pk self.assertInHTML(expected_html, test_advert_form_html) self.assertIn("pick an advert, any advert", test_advert_form_html)
def test_form_render(self): block = SnippetChooserBlock(AdvertWithCustomPrimaryKey, help_text="pick an advert, any advert") empty_form_html = block.render_form(None, 'advertwithcustomprimarykey') self.assertInHTML('<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" />', empty_form_html) self.assertIn('createSnippetChooser("advertwithcustomprimarykey", "tests/advertwithcustomprimarykey");', empty_form_html) test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01') test_advert_form_html = block.render_form(test_advert, 'advertwithcustomprimarykey') expected_html = '<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" value="%s" />' % test_advert.pk self.assertInHTML(expected_html, test_advert_form_html) self.assertIn("pick an advert, any advert", test_advert_form_html)
def test_form_render(self): block = SnippetChooserBlock(Advert, help_text="pick an advert, any advert") empty_form_html = block.render_form(None, 'advert') self.assertInHTML('<input id="advert" name="advert" placeholder="" type="hidden" />', empty_form_html) self.assertIn('createSnippetChooser("advert", "tests/advert");', empty_form_html) test_advert = Advert.objects.get(text='test_advert') test_advert_form_html = block.render_form(test_advert, 'advert') expected_html = '<input id="advert" name="advert" placeholder="" type="hidden" value="%d" />' % test_advert.id self.assertInHTML(expected_html, test_advert_form_html) self.assertIn("pick an advert, any advert", test_advert_form_html)
def test_form_render(self): block = SnippetChooserBlock(Advert, help_text="pick an advert, any advert") empty_form_html = block.render_form(None, 'advert') self.assertInHTML('<input id="advert" name="advert" placeholder="" type="hidden" />', empty_form_html) self.assertIn('createSnippetChooser("advert", "tests/advert");', empty_form_html) test_advert = Advert.objects.get(text='test_advert') test_advert_form_html = block.render_form(test_advert, 'advert') expected_html = '<input id="advert" name="advert" placeholder="" type="hidden" value="%d" />' % test_advert.id self.assertInHTML(expected_html, test_advert_form_html) self.assertIn("pick an advert, any advert", test_advert_form_html)