def test_index(self): """Test index property.""" # Page with Index. page = ProofreadPage(self.site, self.valid['title']) index_page = IndexPage(self.site, self.valid['index']) # Test property. self.assertEqual(page.index, index_page) # Test deleter del page.index self.assertFalse(hasattr(page, '_index')) # Test setter with wrong type. with self.assertRaises(TypeError): page.index = 'invalid index' # Test setter with correct type. page.index = index_page self.assertEqual(page.index, index_page) # Page without Index. page = ProofreadPage(self.site, self.existing_multilinked['title']) index_page_1 = IndexPage(self.site, self.existing_multilinked['index_1']) index_page_2 = IndexPage(self.site, self.existing_multilinked['index_2']) self.assertEqual(page.index, index_page_1) self.assertNotEqual(page.index, index_page_2) self.assertEqual(page._index, (index_page_1, [index_page_2])) # Page without Index. page = ProofreadPage(self.site, self.existing_unlinked['title']) self.assertIsNone(page.index) self.assertEqual(page._index, (None, []))
def test_index(self): """Test index property.""" # Page with Index. page = ProofreadPage(self.site, self.valid['title']) index_page = IndexPage(self.site, self.valid['index']) # Test propery. self.assertEqual(page.index, index_page) # Test deleter del page.index self.assertFalse(hasattr(page, '_index')) # Test setter page.index = index_page self.assertEqual(page.index, index_page) # Page without Index. page = ProofreadPage(self.site, self.existing_multilinked['title']) index_page_1 = IndexPage(self.site, self.existing_multilinked['index_1']) index_page_2 = IndexPage(self.site, self.existing_multilinked['index_2']) self.assertEqual(page.index, index_page_1) self.assertNotEqual(page.index, index_page_2) self.assertEqual(page._index, (index_page_1, [index_page_2])) # Page without Index. page = ProofreadPage(self.site, self.existing_unlinked['title']) self.assertIs(page.index, None) self.assertEqual(page._index, (None, []))