def setUp(self): self.page = factories.PageFactory(display_index=0) factories.ElementFactory(page=self.page) self.generator = PageGenerator(self.page) self.page_etree_element = self.generator.generate(ElementTree.Element("test"))
class PageGeneratorTest(TestCase): def setUp(self): self.page = factories.PageFactory(display_index=0) factories.ElementFactory(page=self.page) self.generator = PageGenerator(self.page) self.page_etree_element = self.generator.generate(ElementTree.Element("test")) @raises(ValueError) def test_error_if_no_elements(self): self.page.elements.all().delete() PageGenerator(self.page).generate(ElementTree.Element("test")) def test_element_has_correct_name(self): assert_equals(self.page_etree_element.tag, self.generator.name) def test_element_has_no_display_index(self): assert_equals(len(self.page_etree_element.attrib), 0)