Skip to content

Commit cc4ecba

Browse files
committed
handle test_rating_graph for Atcoder
1 parent f638a6d commit cc4ecba

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

modules/sites/atcoder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ def rating_graph_data(handle):
132132
return response
133133

134134
soup = bs4.BeautifulSoup(response.text, "lxml")
135-
trs = soup.find("table", id="history").find("tbody").find_all("tr")
135+
try:
136+
trs = soup.find("table", id="history").find("tbody").find_all("tr")
137+
except AttributeError:
138+
return []
136139

137140
contest_data = {}
138141

tests/crawling/test_retrieval_extras.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,27 +252,23 @@ def test_rating_graph(self):
252252
"CodeChef": "tryingtocode",
253253
"CodeForces": "raj454raj",
254254
"HackerRank": "tryingtocode",
255-
"HackerEarth": "karanaggarwal"
255+
"HackerEarth": "karanaggarwal",
256+
"AtCoder": "imanudeep111"
256257
}
257258
expected_list = [['2014-01-13 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/JAN14', 'rating': '1462', 'name': 'January Challenge 2014', 'rank': '3548'}], ['2014-02-17 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/FEB14', 'rating': '1509', 'name': 'February Challenge 2014', 'rank': '2007'}], ['2014-06-16 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/JUNE14', 'rating': '1455', 'name': 'June Challenge 2014', 'rank': '4382'}], ['2014-07-14 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/JULY14', 'rating': '1518', 'name': 'July Challenge 2014', 'rank': '2769'}], ['2014-07-21 21:30:00', u'HackerRank - Algorithms', {'url': u'https://www.hackerrank.com/w7', 'rating': '1554.46', 'name': u'Weekly Challenges - Week 7', 'rank': 499}], ['2014-08-08 21:00:00', 'Codeforces', {'rating': '1403', 'name': u'Codeforces Round #260 (Div. 2)', 'solvedCount': 0, 'url': 'http://www.codeforces.com/contest/456', 'rank': 2152, 'ratingChange': -97}], ['2014-08-11 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/AUG14', 'rating': '1633', 'name': 'August Challenge 2014', 'rank': '1293'}], ['2014-08-11 21:30:00', u'HackerRank - Algorithms', {'url': u'https://www.hackerrank.com/w8', 'rating': '1276.88', 'name': u'Weekly Challenges - Week 8', 'rank': 1204}], ['2014-09-28 21:05:00', 'Codeforces', {'rating': '1279', 'name': u'Codeforces Round #270', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/472', 'rank': 3520, 'ratingChange': -124}], ['2014-10-06 21:00:00', 'Codeforces', {'rating': '1227', 'name': u'Codeforces Round #271 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/474', 'rank': 1654, 'ratingChange': -52}], ['2014-10-13 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/OCT14', 'rating': '1730', 'name': 'October Challenge 2014', 'rank': '900'}], ['2014-11-17 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/NOV14', 'rating': '1717', 'name': 'November Challenge 2014', 'rank': '1751'}], ['2014-12-15 17:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/DEC14', 'rating': '1609', 'name': 'December Challenge 2014', 'rank': '2218'}], ['2015-01-12 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/JAN15', 'rating': '1617', 'name': 'January Challenge 2015', 'rank': '3105'}], ['2015-03-16 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/MARCH15', 'rating': '1553', 'name': 'March Challenge 2015', 'rank': '2489'}], ['2015-05-18 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/MAY15', 'rating': '1519', 'name': 'May Challenge 2015', 'rank': '2946'}], ['2015-06-15 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/JUNE15', 'rating': '1605', 'name': 'June Challenge 2015', 'rank': '1913'}], ['2015-07-13 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/JULY15', 'rating': '1635', 'name': 'July Challenge 2015', 'rank': '1554'}], ['2015-08-02 21:30:00', u'HackerRank - Algorithms', {'url': u'https://www.hackerrank.com/countercode', 'rating': '1287.0', 'name': u'CounterCode 2015', 'rank': 3605}], ['2015-08-17 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/AUG15', 'rating': '1704', 'name': 'August Challenge 2015', 'rank': '1244'}], ['2015-08-22 22:00:00', 'Codeforces', {'rating': '1358', 'name': u'Codeforces Round #317 [AimFund Thanks-Round] (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/572', 'rank': 1114, 'ratingChange': 131}], ['2015-08-24 00:50:00', 'CodeChef Cook-off', {'url': 'https://www.codechef.com/COOK61', 'rating': '1881', 'name': 'August Cook-Off 2015', 'rank': '221'}], ['2015-08-29 22:00:00', 'Codeforces', {'rating': '1288', 'name': u'Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/574', 'rank': 2009, 'ratingChange': -70}], ['2015-09-10 22:00:00', 'Codeforces', {'rating': '1422', 'name': u'Codeforces Round #319 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/577', 'rank': 940, 'ratingChange': 134}], ['2015-09-14 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/SEPT15', 'rating': '1829', 'name': 'September Challenge 2015', 'rank': '1417'}], ['2015-09-21 00:00:00', 'CodeChef Cook-off', {'url': 'https://www.codechef.com/COOK62', 'rating': '1807', 'name': 'September Mega Cook-Off 2015', 'rank': '751'}], ['2015-09-22 22:00:00', 'Codeforces', {'rating': '1379', 'name': u'Codeforces Round #321 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/580', 'rank': 2018, 'ratingChange': -43}], ['2015-09-28 14:30:00', 'Codeforces', {'rating': '1295', 'name': u'Codeforces Round #322 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/581', 'rank': 1836, 'ratingChange': -84}], ['2015-10-03 22:15:00', 'Codeforces', {'rating': '1285', 'name': u'Codeforces Round #323 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/583', 'rank': 2912, 'ratingChange': -10}], ['2015-10-06 22:00:00', 'Codeforces', {'rating': '1298', 'name': u'Codeforces Round #324 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/584', 'rank': 2062, 'ratingChange': 13}], ['2015-10-25 14:30:00', 'Codeforces', {'rating': '1273', 'name': u'Codeforces Round #327 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/591', 'rank': 2259, 'ratingChange': -25}], ['2015-10-30 21:30:00', u'HackerRank - Algorithms', {'url': u'https://www.hackerrank.com/codestorm', 'rating': '1276.05', 'name': u'CodeStorm 2015', 'rank': 3743}], ['2015-10-31 22:00:00', 'Codeforces', {'rating': '1284', 'name': u'Codeforces Round #328 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/592', 'rank': 2075, 'ratingChange': 11}], ['2015-12-01 21:05:00', 'Codeforces', {'rating': '1351', 'name': u'Codeforces Round #334 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/604', 'rank': 1079, 'ratingChange': 67}], ['2015-12-09 21:35:00', 'Codeforces', {'rating': '1309', 'name': u'Codeforces Round #335 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/606', 'rank': 2249, 'ratingChange': -42}], ['2016-01-14 22:05:00', 'Codeforces', {'rating': '1228', 'name': u'Codeforces Round #339 (Div. 2)', 'solvedCount': 0, 'url': 'http://www.codeforces.com/contest/614', 'rank': 1929, 'ratingChange': -81}], ['2016-05-21 10:30:00', 'HackerEarth', {'url': 'https://www.hackerearth.com/challenges/competitive/may-circuits/', 'rating': 1493, 'name': 'May Circuits', 'rank': 714}], ['2016-06-15 15:00:00', 'CodeChef Long', {'url': 'https://www.codechef.com/JUNE16', 'rating': '1641', 'name': 'June Challenge 2016', 'rank': '5083'}], ['2016-08-11 22:05:00', 'Codeforces', {'rating': '1216', 'name': u'Codeforces Round #367 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/706', 'rank': 2989, 'ratingChange': -12}], ['2016-08-20 18:35:00', 'Codeforces', {'rating': '1298', 'name': u'Codeforces Round #368 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/707', 'rank': 1919, 'ratingChange': 82}], ['2016-08-29 17:35:00', 'Codeforces', {'rating': '1309', 'name': u'Codeforces Round #369 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/711', 'rank': 2332, 'ratingChange': 11}], ['2016-09-23 18:35:00', 'Codeforces', {'rating': '1377', 'name': u'Codeforces Round #373 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/719', 'rank': 1593, 'ratingChange': 68}], ['2017-07-28 10:30:00', 'HackerEarth', {'url': 'https://www.hackerearth.com/challenges/competitive/july-circuits-17/', 'rating': 1462, 'name': "July Circuits '17", 'rank': 1326}], ['2017-09-22 10:30:00', 'HackerEarth', {'url': 'https://www.hackerearth.com/challenges/competitive/september-circuits-17/', 'rating': 1569, 'name': "September Circuits '17", 'rank': 291}], ['2017-10-21 10:30:00', 'HackerEarth', {'url': 'https://www.hackerearth.com/challenges/competitive/october-circuits-17/', 'rating': 1491, 'name': "October Circuits '17", 'rank': 1225}], ['2018-03-17 10:30:00', 'HackerEarth', {'url': 'https://www.hackerearth.com/challenges/competitive/march-circuits-18/', 'rating': 1461, 'name': "March Circuits '18", 'rank': 523}], ['2019-01-18 09:30:00', 'HackerEarth', {'url': 'https://www.hackerearth.com/challenges/competitive/january-circuits-19/', 'rating': 1337, 'name': "January Circuits '19", 'rank': 3420}]]
259+
expected_list = {
260+
"CodeChef": [{'data': {'2015-06-15 15:00:00': {'url': 'https://www.codechef.com/JUNE15', 'rating': '1605', 'name': 'June Challenge 2015', 'rank': '1913'}, '2016-06-15 15:00:00': {'url': 'https://www.codechef.com/JUNE16', 'rating': '1641', 'name': 'June Challenge 2016', 'rank': '5083'}, '2014-07-14 15:00:00': {'url': 'https://www.codechef.com/JULY14', 'rating': '1518', 'name': 'July Challenge 2014', 'rank': '2769'}, '2015-08-17 15:00:00': {'url': 'https://www.codechef.com/AUG15', 'rating': '1704', 'name': 'August Challenge 2015', 'rank': '1244'}, '2014-01-13 15:00:00': {'url': 'https://www.codechef.com/JAN14', 'rating': '1462', 'name': 'January Challenge 2014', 'rank': '3548'}, '2014-12-15 17:00:00': {'url': 'https://www.codechef.com/DEC14', 'rating': '1609', 'name': 'December Challenge 2014', 'rank': '2218'}, '2015-01-12 15:00:00': {'url': 'https://www.codechef.com/JAN15', 'rating': '1617', 'name': 'January Challenge 2015', 'rank': '3105'}, '2015-09-14 15:00:00': {'url': 'https://www.codechef.com/SEPT15', 'rating': '1829', 'name': 'September Challenge 2015', 'rank': '1417'}, '2014-11-17 15:00:00': {'url': 'https://www.codechef.com/NOV14', 'rating': '1717', 'name': 'November Challenge 2014', 'rank': '1751'}, '2015-03-16 15:00:00': {'url': 'https://www.codechef.com/MARCH15', 'rating': '1553', 'name': 'March Challenge 2015', 'rank': '2489'}, '2014-06-16 15:00:00': {'url': 'https://www.codechef.com/JUNE14', 'rating': '1455', 'name': 'June Challenge 2014', 'rank': '4382'}, '2014-02-17 15:00:00': {'url': 'https://www.codechef.com/FEB14', 'rating': '1509', 'name': 'February Challenge 2014', 'rank': '2007'}, '2015-05-18 15:00:00': {'url': 'https://www.codechef.com/MAY15', 'rating': '1519', 'name': 'May Challenge 2015', 'rank': '2946'}, '2015-07-13 15:00:00': {'url': 'https://www.codechef.com/JULY15', 'rating': '1635', 'name': 'July Challenge 2015', 'rank': '1554'}, '2014-08-11 15:00:00': {'url': 'https://www.codechef.com/AUG14', 'rating': '1633', 'name': 'August Challenge 2014', 'rank': '1293'}, '2014-10-13 15:00:00': {'url': 'https://www.codechef.com/OCT14', 'rating': '1730', 'name': 'October Challenge 2014', 'rank': '900'}}, 'title': 'CodeChef Long'}, {'data': {'2015-09-21 00:00:00': {'url': 'https://www.codechef.com/COOK62', 'rating': '1807', 'name': 'September Mega Cook-Off 2015', 'rank': '751'}, '2015-08-24 00:50:00': {'url': 'https://www.codechef.com/COOK61', 'rating': '1881', 'name': 'August Cook-Off 2015', 'rank': '221'}}, 'title': 'CodeChef Cook-off'}, {'data': {}, 'title': 'CodeChef Lunchtime'}],
261+
"CodeForces": [{'data': {'2015-09-28 14:30:00': {'rating': '1295', 'name': u'Codeforces Round #322 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/581', 'rank': 1836, 'ratingChange': -84}, '2014-09-28 21:05:00': {'rating': '1279', 'name': u'Codeforces Round #270', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/472', 'rank': 3520, 'ratingChange': -124}, '2015-09-10 22:00:00': {'rating': '1422', 'name': u'Codeforces Round #319 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/577', 'rank': 940, 'ratingChange': 134}, '2016-01-14 22:05:00': {'rating': '1228', 'name': u'Codeforces Round #339 (Div. 2)', 'solvedCount': 0, 'url': 'http://www.codeforces.com/contest/614', 'rank': 1929, 'ratingChange': -81}, '2016-08-20 18:35:00': {'rating': '1298', 'name': u'Codeforces Round #368 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/707', 'rank': 1919, 'ratingChange': 82}, '2015-10-31 22:00:00': {'rating': '1284', 'name': u'Codeforces Round #328 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/592', 'rank': 2075, 'ratingChange': 11}, '2015-10-25 14:30:00': {'rating': '1273', 'name': u'Codeforces Round #327 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/591', 'rank': 2259, 'ratingChange': -25}, '2015-09-22 22:00:00': {'rating': '1379', 'name': u'Codeforces Round #321 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/580', 'rank': 2018, 'ratingChange': -43}, '2014-08-08 21:00:00': {'rating': '1403', 'name': u'Codeforces Round #260 (Div. 2)', 'solvedCount': 0, 'url': 'http://www.codeforces.com/contest/456', 'rank': 2152, 'ratingChange': -97}, '2015-12-01 21:05:00': {'rating': '1351', 'name': u'Codeforces Round #334 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/604', 'rank': 1079, 'ratingChange': 67}, '2016-08-29 17:35:00': {'rating': '1309', 'name': u'Codeforces Round #369 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/711', 'rank': 2332, 'ratingChange': 11}, '2015-12-09 21:35:00': {'rating': '1309', 'name': u'Codeforces Round #335 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/606', 'rank': 2249, 'ratingChange': -42}, '2016-08-11 22:05:00': {'rating': '1216', 'name': u'Codeforces Round #367 (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/706', 'rank': 2989, 'ratingChange': -12}, '2015-08-29 22:00:00': {'rating': '1288', 'name': u'Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)', 'solvedCount': 1, 'url': 'http://www.codeforces.com/contest/574', 'rank': 2009, 'ratingChange': -70}, '2015-10-03 22:15:00': {'rating': '1285', 'name': u'Codeforces Round #323 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/583', 'rank': 2912, 'ratingChange': -10}, '2015-10-06 22:00:00': {'rating': '1298', 'name': u'Codeforces Round #324 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/584', 'rank': 2062, 'ratingChange': 13}, '2014-10-06 21:00:00': {'rating': '1227', 'name': u'Codeforces Round #271 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/474', 'rank': 1654, 'ratingChange': -52}, '2015-08-22 22:00:00': {'rating': '1358', 'name': u'Codeforces Round #317 [AimFund Thanks-Round] (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/572', 'rank': 1114, 'ratingChange': 131}, '2016-09-23 18:35:00': {'rating': '1377', 'name': u'Codeforces Round #373 (Div. 2)', 'solvedCount': 2, 'url': 'http://www.codeforces.com/contest/719', 'rank': 1593, 'ratingChange': 68}}, 'title': 'Codeforces'}],
262+
"HackerRank": [{'data': {'2014-07-21 21:30:00': {'url': u'https://www.hackerrank.com/w7', 'rating': '1554.46', 'name': u'Weekly Challenges - Week 7', 'rank': 499}, '2015-10-30 21:30:00': {'url': u'https://www.hackerrank.com/codestorm', 'rating': '1276.05', 'name': u'CodeStorm 2015', 'rank': 3743}, '2015-08-02 21:30:00': {'url': u'https://www.hackerrank.com/countercode', 'rating': '1287.0', 'name': u'CounterCode 2015', 'rank': 3605}, '2014-08-11 21:30:00': {'url': u'https://www.hackerrank.com/w8', 'rating': '1276.88', 'name': u'Weekly Challenges - Week 8', 'rank': 1204}}, 'title': u'HackerRank - Algorithms'}],
263+
"HackerEarth": [{'data': {'2016-05-21 10:30:00': {'url': 'https://www.hackerearth.com/challenges/competitive/may-circuits/', 'rating': 1493, 'name': 'May Circuits', 'rank': 714}, '2017-10-21 10:30:00': {'url': 'https://www.hackerearth.com/challenges/competitive/october-circuits-17/', 'rating': 1491, 'name': "October Circuits '17", 'rank': 1225}, '2017-09-22 10:30:00': {'url': 'https://www.hackerearth.com/challenges/competitive/september-circuits-17/', 'rating': 1569, 'name': "September Circuits '17", 'rank': 291}, '2018-03-17 10:30:00': {'url': 'https://www.hackerearth.com/challenges/competitive/march-circuits-18/', 'rating': 1461, 'name': "March Circuits '18", 'rank': 523}, '2019-01-18 09:30:00': {'url': 'https://www.hackerearth.com/challenges/competitive/january-circuits-19/', 'rating': 1337, 'name': "January Circuits '19", 'rank': 3420}, '2017-07-28 10:30:00': {'url': 'https://www.hackerearth.com/challenges/competitive/july-circuits-17/', 'rating': 1462, 'name': "July Circuits '17", 'rank': 1326}}, 'title': 'HackerEarth'}],
264+
"AtCoder": [{'data': {'2020-01-10 19:10:00': {'url': 'https://atcoder.jp/contests/abc150', 'rating': '-', 'ratingChange': '-', 'name': u'AtCoder Beginner Contest 150', 'rank': u'2640'}, '2020-03-14 19:10:00': {'url': 'https://atcoder.jp/contests/panasonic2020', 'rating': '33', 'ratingChange': '+31', 'name': u'Panasonic Programming Contest 2020', 'rank': u'3897'}, '2020-05-02 19:20:00': {'url': 'https://atcoder.jp/contests/abc165', 'rating': '192', 'ratingChange': '+51', 'name': u'AtCoder Beginner Contest 165', 'rank': u'6343'}, '2020-03-01 19:10:00': {'url': 'https://atcoder.jp/contests/abc157', 'rating': '2', 'ratingChange': '-', 'name': u'AtCoder Beginner Contest 157', 'rank': u'6327'}, '2020-04-26 19:10:00': {'url': 'https://atcoder.jp/contests/abc164', 'rating': '141', 'ratingChange': '+108', 'name': u'AtCoder Beginner Contest 164', 'rank': u'3184'}, '2020-04-19 19:10:00': {'url': 'https://atcoder.jp/contests/abc163', 'rating': '-', 'ratingChange': '-', 'name': u'AtCoder Beginner Contest 163', 'rank': u'4042'}}, 'title': 'AtCoder'}]
265+
}
258266
result = {}
259267
for site in sites_with_rating_graph_functionality:
260268
get_rating_func = getattr(sites, site.lower()).Profile.rating_graph_data
261269
res = get_rating_func(handles[site])
262-
result[site.lower() + "_data"] = res
263-
264-
all_contest_points = []
265-
for site_data in result:
266-
for contest_data in result[site_data]:
267-
for data_point in contest_data["data"]:
268-
all_contest_points.append([
269-
data_point,
270-
contest_data["title"],
271-
contest_data["data"][data_point]
272-
])
273-
274-
if sorted(all_contest_points, key=lambda x: x[0]) != expected_list:
275-
raise RuntimeError("Rating graph dict does not match")
270+
if expected_list[site] != res:
271+
raise RuntimeError("Rating graph dict does not match for " + site)
276272

277273
# --------------------------------------------------------------------------
278274
def test_submissions(self):

0 commit comments

Comments
 (0)