def test_find_national_team1(self): man_or_woman = u'woman' force_nation_team = False time_of_race = pywikibot.WbTime(site=site, year=2020, month=8, day=27, precision='day') year = time_of_race.year log = Log() nation_table = nation_team_table.load() result_dic = { 'rank': [-1, 0, ''], 'last name': [-1, 1, ''], 'first name': [-1, 2, ''], 'name': [-1, 3, ''], 'result': [-1, 4, 'time'], #startlist only with time 'points': [-1, 5, 'points'], 'team code': [-1, 7, ''], 'ecart': [1, 6, 'time'], #always created 'bib': [-1, 8, ''] #dossard } result_table, row_count, ecart = table_reader('National_team_tests', result_dic, 0, False) result_table = sorted(result_table, key=lambda tup: int(tup[8])) list_of_cyclists, all_riders_found, log, list_of_teams, all_teams_found = cyclists_table_reader( pywikibot, site, repo, result_table, result_dic, nosortkey=True) res_list_of_cyclists, log = find_national_team( pywikibot, site, repo, list_of_cyclists, result_table, result_dic, row_count, nation_table, force_nation_team, year, log, man_or_woman, time_of_race) #NED makes problem self.assertEqual(res_list_of_cyclists[9].national_team, True) #Fra then ITA self.assertEqual(res_list_of_cyclists[10].national_team, True) self.assertEqual(res_list_of_cyclists[11].national_team, True) self.assertEqual(res_list_of_cyclists[12].national_team, True) self.assertEqual(res_list_of_cyclists[13].national_team, True) self.assertEqual(res_list_of_cyclists[14].national_team, True) self.assertEqual(res_list_of_cyclists[15].national_team, True) self.assertEqual(res_list_of_cyclists[16].national_team, True) self.assertEqual(res_list_of_cyclists[17].national_team, True) self.assertEqual(res_list_of_cyclists[18].national_team, True) self.assertEqual(res_list_of_cyclists[19].national_team, True) self.assertEqual(res_list_of_cyclists[20].national_team, True)
def test_table_reader(self): result_dic={ 'road champ':[-1, 0,''], 'road day':[-1, 1,''], 'road month':[-1, 2,''], 'road year':[-1, 3,''], 'road winner':[-1, 4,''], 'clm champ':[-1, 5,''], 'clm day':[-1, 6,''], 'clm month':[-1, 7,''], 'clm year':[-1, 8,''], 'clm winner':[-1, 9,''], } result_table, row_count, ecart= table_reader('champ',result_dic, 0, False) self.assertTrue(row_count>0)
def test_find_national_team2(self): man_or_woman = u'woman' time_of_race = pywikibot.WbTime(site=site, year=2020, month=8, day=27, precision='day') year = time_of_race.year log = Log() nation_table = nation_team_table.load() result_dic = { 'rank': [-1, 0, ''], 'last name': [-1, 1, ''], 'first name': [-1, 2, ''], 'name': [-1, 3, ''], 'result': [-1, 4, 'time'], #startlist only with time 'points': [-1, 5, 'points'], 'team code': [-1, 7, ''], 'ecart': [1, 6, 'time'], #always created 'bib': [-1, 8, ''] #dossard } force_nation_team = True #Test force_nation_team result_table, row_count, ecart = table_reader( 'National_team_tests_orig', result_dic, 0, False) result_table = sorted(result_table, key=lambda tup: int(tup[8])) list_of_cyclists, all_riders_found, log, list_of_teams, all_teams_found = cyclists_table_reader( pywikibot, site, repo, result_table, result_dic, nosortkey=True) res_list_of_cyclists, log = find_national_team( pywikibot, site, repo, list_of_cyclists, result_table, result_dic, row_count, nation_table, force_nation_team, year, log, man_or_woman, time_of_race) self.assertEqual(res_list_of_cyclists[0].team, 'Q74847203') self.assertEqual(res_list_of_cyclists[7].team, 'Q74847203') self.assertEqual(res_list_of_cyclists[8].team, 'Q74749584') self.assertEqual(res_list_of_cyclists[9].team, 'Q74749584')
def test_put_dnf_in_startlist(self): item_parent = pywikibot.ItemPage(repo, "Q79138636") item_parent.get() startlist = item_parent.claims.get(u'P710') item = pywikibot.ItemPage(repo, "Q98293556") item.get() result = 'time' result_dic = { 'rank': [-1, 0, ''], 'last name': [-1, 1, ''], 'first name': [-1, 2, ''], 'name': [-1, 3, ''], 'result': [-1, 4, result], 'points': [-1, 5, 'points'], 'team code': [-1, 7, ''], 'ecart': [ 1, 6, '' ], #always created, not set on time otherwise makes strange things 'bib': [-1, 8, ''] #dossard } result_table, row_count, ecart = table_reader('DNF_test', result_dic, 0, False) starter, stage_nummer = put_dnf_in_startlist(pywikibot, site, repo, item, startlist, row_count, result_table, result_dic, test=True) self.assertEqual(starter.getTarget().getID(), "Q18125995") self.assertEqual(stage_nummer, '1')