def testViewBigtuto(self): response = tutos._view(None, '223267') self.assertIsInstance(response, tuple) self.assertEqual(len(response), 2) mode, response = response self.assertEqual(mode, 'big') self.assertIsInstance(response, dict) for name, value in { 'title': 'Apprendre Python !', 'license': 'Creative Commons BY-NC-SA' }.items(): self.assertIn(name, response) self.assertEqual(response[name], value) for name, type in { 'authors': common.Member, 'subparts': common.Empty }.items(): self.assertIn(name, response) self.assertIsInstance(response[name], list) for item in response[name]: self.assertIsInstance(item, type) for name in 'intro'.split(): self.assertIn(name, response) self.assertIsInstance(response[name], str) self.assertIsInstance(response['authors'], list) self.assertTrue(response['intro'].startswith( 'Ce tutoriel a pour but de vous initier au langage de programmation Python.' )) self.assertTrue(response['intro'].strip().endswith('<hr />')) self.assertEqual(response['subparts'][0].name, 'Introduction \xc3\xa0 Python')
def testViewMinituto(self): response = tutos._view(None, '33509') self.assertIsInstance(response, tuple) self.assertEqual(len(response), 2) mode, response = response self.assertEqual(mode, 'mini') self.assertIsInstance(response, dict) for name, value in {'title': 'Pratiques avanc\xc3\xa9es et m\xc3\xa9connues en Python', 'license': 'Creative Commons BY-SA'}.items(): self.assertIn(name, response) self.assertEqual(response[name], value) for name, type in {'authors': common.Member, 'subparts': common.Empty}.items(): self.assertIn(name, response) self.assertIsInstance(response[name], list) for item in response[name]: self.assertIsInstance(item, type) for name in 'intro content'.split(): self.assertIn(name, response) self.assertIsInstance(response[name], str) self.assertIsInstance(response['authors'], list) self.assertTrue(response['intro'].startswith('Beaucoup de gens pensent maîtriser correctement le langage Python')) self.assertTrue(response['intro'].strip().endswith('Bonne lecture \xc3\xa0 vous.</div>')) content = response['content'].strip() self.assertTrue(content.startswith('<h2>')) self.assertTrue(content.endswith('<img src="http://img373.imageshack.us/img373/8651/pythonircio1.png" alt="Image utilisateur"/></a></div></div>')) self.assertEqual(response['subparts'][0].name, 'La fonction enumerate')
def testViewMinituto(self): response = tutos._view(None, '33509') self.assertIsInstance(response, tuple) self.assertEqual(len(response), 2) mode, response = response self.assertEqual(mode, 'mini') self.assertIsInstance(response, dict) for name, value in { 'title': 'Pratiques avanc\xc3\xa9es et m\xc3\xa9connues en Python', 'license': 'Creative Commons BY-SA' }.items(): self.assertIn(name, response) self.assertEqual(response[name], value) for name, type in { 'authors': common.Member, 'subparts': common.Empty }.items(): self.assertIn(name, response) self.assertIsInstance(response[name], list) for item in response[name]: self.assertIsInstance(item, type) for name in 'intro content'.split(): self.assertIn(name, response) self.assertIsInstance(response[name], str) self.assertIsInstance(response['authors'], list) self.assertTrue(response['intro'].startswith( 'Beaucoup de gens pensent maîtriser correctement le langage Python' )) self.assertTrue(response['intro'].strip().endswith( 'Bonne lecture \xc3\xa0 vous.</div>')) content = response['content'].strip() self.assertTrue(content.startswith('<h2>')) self.assertTrue( content.endswith( '<img src="http://img373.imageshack.us/img373/8651/pythonircio1.png" alt="Image utilisateur"/></a></div></div>' )) self.assertEqual(response['subparts'][0].name, 'La fonction enumerate')
def testViewBigtuto(self): response = tutos._view(None, '223267') self.assertIsInstance(response, tuple) self.assertEqual(len(response), 2) mode, response = response self.assertEqual(mode, 'big') self.assertIsInstance(response, dict) for name, value in {'title': 'Apprendre Python !', 'license': 'Creative Commons BY-NC-SA'}.items(): self.assertIn(name, response) self.assertEqual(response[name], value) for name, type in {'authors': common.Member, 'subparts': common.Empty}.items(): self.assertIn(name, response) self.assertIsInstance(response[name], list) for item in response[name]: self.assertIsInstance(item, type) for name in 'intro'.split(): self.assertIn(name, response) self.assertIsInstance(response[name], str) self.assertIsInstance(response['authors'], list) self.assertTrue(response['intro'].startswith('Ce tutoriel a pour but de vous initier au langage de programmation Python.')) self.assertTrue(response['intro'].strip().endswith('<hr />')) self.assertEqual(response['subparts'][0].name, 'Introduction \xc3\xa0 Python')