File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed
Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -361,13 +361,15 @@ def my_stats(self):
361361 soup = bs4 .BeautifulSoup (response .text , "html.parser" )
362362 stats_txt = soup .article .pre .text
363363 lines = stats_txt .splitlines ()
364- try :
365- [line ] = [x for x in lines if x .split ()[0 ] == str (self .day )]
366- except ValueError :
367- log .debug ("failed to parse stats\n %s" , stats_txt )
364+ line = [x for x in lines if x .split ()[0 ] == str (self .day )]
365+ if len (line ) != 1 :
366+ log .debug ("failed to parse stats table\n %s" , stats_txt )
368367 raise PuzzleUnsolvedError
368+ [line ] = line
369369 vals = line .split ()
370370 assert int (vals [0 ]) == self .day
371+ if vals [4 ] == "-" :
372+ raise PuzzleUnsolvedError
371373 result = {
372374 "a" : {
373375 "time" : _parse_duration (vals [1 ]),
Original file line number Diff line number Diff line change 1- __version__ = "0.8.4 "
1+ __version__ = "0.8.5 "
Original file line number Diff line number Diff line change 33
44setup (
55 name = "advent-of-code-data" ,
6- version = "0.8.4 " ,
6+ version = "0.8.5 " ,
77 description = "Get your puzzle data with a single import" ,
88 long_description = open ("README.rst" ).read (),
99 long_description_content_type = "text/x-rst" ,
Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ def test_aocr_override(monkeypatch, tmp_path):
189189Day <span class="leaderboard-daydesc-first"> Time Rank Score</span>
190190<span class="leaderboard-daydesc-both"> Time Rank Score</span>
191191 25 >24h 2708 0 >24h 1926 0
192+ 24 >24h 2708 0 - - -
192193 4 00:03:30 158 0 00:04:17 25 76
193194 3 00:24:44 729 0 00:36:00 710 0
194195 2 01:11:16 4087 0 01:23:27 3494 0
@@ -231,6 +232,15 @@ def test_get_stats_fail(requests_mock):
231232 puzzle .my_stats
232233
233234
235+ def test_get_stats_partial_fail (requests_mock ):
236+ puzzle = Puzzle (year = 2019 , day = 24 )
237+ requests_mock .get (
238+ url = "https://adventofcode.com/2019/leaderboard/self" , text = fake_stats_response ,
239+ )
240+ with pytest .raises (PuzzleUnsolvedError ):
241+ puzzle .my_stats
242+
243+
234244def test_puzzle_view (mocker ):
235245 browser_open = mocker .patch ("aocd.models.webbrowser.open" )
236246 puzzle = Puzzle (year = 2019 , day = 4 )
You can’t perform that action at this time.
0 commit comments