Skip to content

Commit

Permalink
Only write csv A if not already recounted. Always write CSV B
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismostert committed Apr 8, 2024
1 parent e6b74ac commit b8becff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/csv_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
+ [
Expand Down
20 changes: 18 additions & 2 deletions test/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:])
Expand All @@ -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

Expand Down

0 comments on commit b8becff

Please sign in to comment.