Handle incomplete historical jury lists

This commit is contained in:
2026-08-09 12:42:16 +02:00
parent bbf0f1bf0a
commit 5db0e1816b
8 changed files with 244 additions and 15 deletions
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html><head><meta property="og:title" content="Aditya Sharma"></head><body>
<table>
<tr><td>1. The Sundays: Here's Where The Story Ends</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>2. The Beatles: Something</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>3. The Pogues &amp; Kirsty MacColl: Fairytale of New York</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>4. China Crisis: Wishful Thinking</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>5&nbsp;&nbsp;Nick Drake: Northern Sky</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>6. Elton John: Your Song</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>7. Sam Cooke: Cupid</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>8. Carole King: You've Got&nbsp;A Friend</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>9. Turbonegro: I&nbsp;Got Erection</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>10. Dead Kennedys: Too Drunk To Fuck</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table></body></html>
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html><head><meta property="og:title" content="Christiane Falk"></head><body>
<table>
<tr><td>1. Pearl Jam: Black</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>2. Element of Crime: Weißes Papier</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>3. R.E.M.: Country Feedback</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>4. Jeff Buckley. Hallelujah</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>5. Gisbert zu Knyphausen: Dreh dich nicht um</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>6. John Grant feat. Midlake: I Wanna Go To Marz</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>7. James Blake: Limit To Your Love</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>8. The National: I Need My Girl</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>9. Blur: No Distance Left To Run</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>10. Keane: Bend and Break</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table></body></html>
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html><head><meta property="og:title" content="Dagobert"></head><body>
<table>
<tr><td>1. Doris Day: The Way I Dreamed It</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>2. Telly Savalas: If</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>3. Lou Reed: Crazy Feeling</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>4. Roy Rogers: Cleanin' My Rifle (And Dreamin' Of You)</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>5. Carpenters: I Need To Be In Love</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>6. Hank Williams: Cold Cold Heart</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>7. Chris Isaak: Wicked Game</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>8. Astrud Gilberto: Never My Love</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>9. Tiny Tim: Earth Angel</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table></body></html>
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html><head><meta property="og:title" content="Sven-Erik Stephan"></head><body>
<table>
<tr><td>1. The Cure: Lovesong</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>2. Joy Division: Love Will Tear Us Apart</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>3. Roxy Music: More Than This</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>4. Prince: Raspberry Beret</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>5. Mazzy Star: Fade Into You</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>6. Rufus &amp; Chaka Khan: Ain’t Nobody</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>7. Cyndi Lauper. Time After Time</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>8. Arthur Russell: That’s Us/ Wild Cimbination</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>9. The Pharcyde: Passin’ Me By</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>10. Frankie Goes To Hollywood: The Power Of Love</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table></body></html>
+77 -1
View File
@@ -1,7 +1,16 @@
import unittest
from contextlib import redirect_stdout
from io import StringIO
from pathlib import Path
from radioeins_top100 import POINTS, derive_output_dir, parse_jury_page
from radioeins_top100 import (
POINTS,
IncompleteJuryListError,
build_argument_parser,
decide_incomplete_list,
derive_output_dir,
parse_jury_page,
)
class RadioeinsTop100Tests(unittest.TestCase):
@@ -67,6 +76,73 @@ class RadioeinsTop100Tests(unittest.TestCase):
self.assertEqual(votes[7].artist, "Boxhmasters")
self.assertEqual(votes[7].title, "Mogli")
def test_historical_rank_without_dot(self):
votes = self.parse_fixture("love-aditya-sharma.html")
self.assertEqual((votes[4].rank, votes[4].artist, votes[4].title),
(5, "Nick Drake", "Northern Sky"))
def test_historical_period_separator(self):
christiane = self.parse_fixture("love-christiane-falk.html")
sven = self.parse_fixture("love-sven-erik-stephan.html")
self.assertEqual((christiane[3].artist, christiane[3].title),
("Jeff Buckley", "Hallelujah"))
self.assertEqual((sven[6].artist, sven[6].title),
("Cyndi Lauper", "Time After Time"))
self.assertEqual(christiane[2].artist, "R.E.M.")
def test_incomplete_historical_list_is_rejected(self):
with self.assertRaises(IncompleteJuryListError) as caught:
self.parse_fixture("love-dagobert.html")
output = StringIO()
with redirect_stdout(output):
accepted = decide_incomplete_list(
caught.exception,
accept_incomplete=False,
interactive=False,
decision_helper=lambda _: self.fail("must not prompt"),
)
self.assertFalse(accepted)
self.assertIn("Dagobert", output.getvalue())
self.assertEqual(caught.exception.missing_ranks, [10])
def test_incomplete_historical_list_is_accepted_interactively(self):
with self.assertRaises(IncompleteJuryListError) as caught:
self.parse_fixture("love-dagobert.html")
with redirect_stdout(StringIO()):
accepted = decide_incomplete_list(
caught.exception,
accept_incomplete=False,
interactive=True,
decision_helper=lambda prompt: "yes",
)
self.assertTrue(accepted)
self.assertEqual(
[(vote.rank, vote.points) for vote in caught.exception.votes],
[(1, 12), (2, 10), (3, 8), (4, 7), (5, 6),
(6, 5), (7, 4), (8, 3), (9, 2)],
)
def test_accept_incomplete_option(self):
args = build_argument_parser().parse_args(["--accept-incomplete"])
self.assertTrue(args.accept_incomplete)
with self.assertRaises(IncompleteJuryListError) as caught:
self.parse_fixture("love-dagobert.html")
with redirect_stdout(StringIO()):
accepted = decide_incomplete_list(
caught.exception,
accept_incomplete=args.accept_incomplete,
interactive=False,
decision_helper=lambda _: self.fail("must not prompt"),
)
self.assertTrue(accepted)
if __name__ == "__main__":
unittest.main()