def test_form_rendering_if_no_section_exists(self): self.section_data['title'] = 'Another title 1' Section.objects.create(pk=3, **self.section_data) self.section_data['title'] = 'Another title 2' Section.objects.create(pk=7, **self.section_data) form = AddNewsForm() self.assertIn('Another title 1', form.as_p()) self.assertIn('Another title 2', form.as_p()) self.assertNotIn('selected', form.as_p())
def test_form_rendering_if_6th_section_exists(self): Section.objects.create(pk=6, **self.section_data) self.section_data['title'] = 'Another title 1' Section.objects.create(pk=3, **self.section_data) self.section_data['title'] = 'Another title 2' Section.objects.create(pk=7, **self.section_data) form = AddNewsForm() self.assertIn( '<option value="6" selected="selected">some section</option>\n', form.as_p()) self.assertIn('Another title 1', form.as_p()) self.assertIn('Another title 2', form.as_p())