From b8becff93ca86254b4a5743a3c807e2972d2d359 Mon Sep 17 00:00:00 2001 From: Chris Mostert <15890652+chrismostert@users.noreply.github.com> Date: Mon, 8 Apr 2024 13:41:14 +0200 Subject: [PATCH] Only write csv A if not already recounted. Always write CSV B --- src/csv_write.py | 4 +++- test/test_e2e.py | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/csv_write.py b/src/csv_write.py index 4af6c16..7df02a8 100644 --- a/src/csv_write.py +++ b/src/csv_write.py @@ -103,7 +103,9 @@ def write_csv_a( explanation_sum_difference = results.explanation_sum_difference or None already_recounted = "ja" if results.already_recounted else None - if inexplicable_difference or explanation_sum_difference: + if ( + inexplicable_difference or explanation_sum_difference + ) and not results.already_recounted: writer.writerow( _id_cols(eml_metadata, id) + [ diff --git a/test/test_e2e.py b/test/test_e2e.py index 5a715f2..e967898 100644 --- a/test/test_e2e.py +++ b/test/test_e2e.py @@ -3,7 +3,7 @@ from main import create_csv_files -def test_create_csv_files_a(): +def test_create_csv_files_a_b(): """Tests the controlprotocol from front to back, including reading all files from disk and writing result files. This test case only includes one polling station with two inexplicable differences, which does show up in the .odt @@ -25,6 +25,7 @@ def test_create_csv_files_a(): path_to_odt, ) + # No result since it has been recounted with open(temp_out_a) as file: # We skip the first few lines since the version can and will change content = "".join(file.readlines()[3:]) @@ -36,7 +37,22 @@ def test_create_csv_files_a(): "Gemeentenummer;0505\n" "\n" "Verkiezingnummer;Kieskringnummer;Gemeentenummer;Gemeentenaam;Stembureaunummer;Stembureaunaam;Aantal geen verklaring voor verschil;Aantal ontbrekende verklaringen voor verschil;Al herteld;Samenvatting\n" - "TK2023;14;0505;Dordrecht;1;Stembureau Binnenstad (postcode: 3331 DA);2;;ja;In dit stembureau is er een onverklaard verschil van 2. Er is wel herteld.\n" + ) + assert content == expected + + # Result since we show this even if there has been a recount + with open(temp_out_b) as file: + # We skip the first few lines since the version can and will change + content = "".join(file.readlines()[3:]) + expected = ( + "EML datum/tijd;2023-08-28T13:53:27.193\n" + "Verkiezing;Tweede Kamer der Staten-Generaal 2023\n" + "Datum;2023-11-22\n" + "Kieskringnummer;14\n" + "Gemeentenummer;0505\n" + "\n" + "Verkiezingnummer;Kieskringnummer;Gemeentenummer;Gemeentenaam;Stembureaunummer;Stembureaunaam;Stembureau met nul stemmen;Stembureau >=3% ongeldig;Stembureau >=3% blanco;Stembureau >=15 of >=2% verschil tussen toegelaten kiezers en uitgebrachte stemmen;Stembureau met lijst >=50% afwijking;Mogelijk verwisselde kandidaten;Al herteld;Samenvatting\n" + "TK2023;14;0505;Dordrecht;1;Stembureau Binnenstad (postcode: 3331 DA);;;;ja (28);;;ja;In dit stembureau is er een groot verschil tussen het aantal toegelaten kiezers en het aantal uitgebrachte stemmen (28). Er is wel herteld.\n" ) assert content == expected