def setUp(self): self.spider = NTCSpider()
class NTCSpiderTests(TestCase): def setUp(self): self.spider = NTCSpider() def test_html_parse(self): response = fake_response(os.path.join("testdata", "ntc.html")) actual = self.spider.parse_ntc(response).next() actual_location = actual["location"] actual_schools_list = actual["schools"] expected_schools_part = { "results": [ { "biology": None, "chemistry": None, "civics": None, "eng_lang": u"22", "fr_lang": None, "full_name": u"АБДЫКЕРИМОВ ЭЛЬНУР", "geography": None, "geometry": None, "ger_lang": None, "history": u"29", "informatics": None, "kyr_lang": None, "math": None, "notes": None, "physics": None, "rus_lang": None, "uzb_lang": None, }, { "biology": None, "chemistry": None, "civics": None, "eng_lang": u"23", "fr_lang": None, "full_name": u"АЛЕКСАНДР ЛИСОВСКИ", "geography": None, "geometry": None, "ger_lang": None, "history": u"25", "informatics": None, "kyr_lang": None, "math": None, "notes": None, "physics": None, "rus_lang": None, "uzb_lang": None, }, { "biology": None, "chemistry": None, "civics": None, "eng_lang": u"22", "fr_lang": None, "full_name": u"АЛИМОВ ЭМИР", "geography": None, "geometry": None, "ger_lang": None, "history": u"28", "informatics": None, "kyr_lang": None, "math": None, "notes": None, "physics": None, "rus_lang": None, "uzb_lang": None, }, { "biology": u"25", "chemistry": None, "civics": None, "eng_lang": None, "fr_lang": None, "full_name": u"БОГОМОЛОВ АЛЕКСЕЙ", "geography": None, "geometry": None, "ger_lang": None, "history": u"26", "informatics": None, "kyr_lang": None, "math": None, "notes": None, "physics": None, "rus_lang": None, "uzb_lang": None, }, { "biology": None, "chemistry": None, "civics": None, "eng_lang": u"20", "fr_lang": None, "full_name": u"ГАЛИЕВА ГУЛЬСАН", "geography": None, "geometry": None, "ger_lang": None, "history": u"25", "informatics": None, "kyr_lang": None, "math": None, "notes": None, "physics": None, "rus_lang": u"18", "uzb_lang": None, }, { "biology": None, "chemistry": None, "civics": None, "eng_lang": None, "fr_lang": None, "full_name": u"ПОПОВ НИКОЛАЙ", "geography": None, "geometry": None, "ger_lang": None, "history": u"28", "informatics": None, "kyr_lang": None, "math": None, "notes": None, "physics": None, "rus_lang": u"28", "uzb_lang": None, }, { "biology": None, "chemistry": None, "civics": None, "eng_lang": u"25", "fr_lang": None, "full_name": u"ЧОРМОНОВББЕКТУР", "geography": None, "geometry": None, "ger_lang": None, "history": u"27", "informatics": None, "kyr_lang": None, "math": None, "notes": None, "physics": None, "rus_lang": None, "uzb_lang": None, }, ], "title": u"Абитуриент", } expected_location = u"г. Бишкек г. БишкекНЦТ" self.assertTrue(expected_schools_part in actual_schools_list) self.assertEqual(actual_location, expected_location)
class NTCSpiderTests(TestCase): def setUp(self): self.spider = NTCSpider() def test_html_parse(self): response = fake_response(os.path.join('testdata', 'ntc.html')) actual = self.spider.parse_ntc(response).next() actual_location = actual['location'] actual_schools_list = actual['schools'] expected_schools_part = {'results': [{'biology': None, 'chemistry': None, 'civics': None, 'eng_lang': u'22', 'fr_lang': None, 'full_name': u'АБДЫКЕРИМОВ ЭЛЬНУР', 'geography': None, 'geometry': None, 'ger_lang': None, 'history': u'29', 'informatics': None, 'kyr_lang': None, 'math': None, 'notes': None, 'physics': None, 'rus_lang': None, 'uzb_lang': None}, {'biology': None, 'chemistry': None, 'civics': None, 'eng_lang': u'23', 'fr_lang': None, 'full_name': u'АЛЕКСАНДР ЛИСОВСКИ', 'geography': None, 'geometry': None, 'ger_lang': None, 'history': u'25', 'informatics': None, 'kyr_lang': None, 'math': None, 'notes': None, 'physics': None, 'rus_lang': None, 'uzb_lang': None}, {'biology': None, 'chemistry': None, 'civics': None, 'eng_lang': u'22', 'fr_lang': None, 'full_name': u'АЛИМОВ ЭМИР', 'geography': None, 'geometry': None, 'ger_lang': None, 'history': u'28', 'informatics': None, 'kyr_lang': None, 'math': None, 'notes': None, 'physics': None, 'rus_lang': None, 'uzb_lang': None}, {'biology': u'25', 'chemistry': None, 'civics': None, 'eng_lang': None, 'fr_lang': None, 'full_name': u'БОГОМОЛОВ АЛЕКСЕЙ', 'geography': None, 'geometry': None, 'ger_lang': None, 'history': u'26', 'informatics': None, 'kyr_lang': None, 'math': None, 'notes': None, 'physics': None, 'rus_lang': None, 'uzb_lang': None}, {'biology': None, 'chemistry': None, 'civics': None, 'eng_lang': u'20', 'fr_lang': None, 'full_name': u'ГАЛИЕВА ГУЛЬСАН', 'geography': None, 'geometry': None, 'ger_lang': None, 'history': u'25', 'informatics': None, 'kyr_lang': None, 'math': None, 'notes': None, 'physics': None, 'rus_lang': u'18', 'uzb_lang': None}, {'biology': None, 'chemistry': None, 'civics': None, 'eng_lang': None, 'fr_lang': None, 'full_name': u'ПОПОВ НИКОЛАЙ', 'geography': None, 'geometry': None, 'ger_lang': None, 'history': u'28', 'informatics': None, 'kyr_lang': None, 'math': None, 'notes': None, 'physics': None, 'rus_lang': u'28', 'uzb_lang': None}, {'biology': None, 'chemistry': None, 'civics': None, 'eng_lang': u'25', 'fr_lang': None, 'full_name': u'ЧОРМОНОВББЕКТУР', 'geography': None, 'geometry': None, 'ger_lang': None, 'history': u'27', 'informatics': None, 'kyr_lang': None, 'math': None, 'notes': None, 'physics': None, 'rus_lang': None, 'uzb_lang': None}], 'title': u'Абитуриент'} expected_location = u'г. Бишкек г. БишкекНЦТ' self.assertTrue(expected_schools_part in actual_schools_list) self.assertEqual(actual_location, expected_location)