From 7f0ce803cbbdec81fcc76204ee834569021f708f Mon Sep 17 00:00:00 2001 From: Eduardo Robles Elvira Date: Thu, 28 Apr 2022 16:59:56 +0200 Subject: [PATCH] adding support for implicit null votes --- tally_pipes/main.py | 30 ++++++++---- tally_pipes/pipes/results.py | 24 +++++++--- test/borda_tests/test_1 | 6 +-- test/cumulative_tests/test_1 | 6 +-- test/cumulative_tests/test_write_ins | 4 +- test/cumulative_tests/test_write_ins_null | 58 +++++++++++++++++++++++ test/output_tests/test_output_1 | 6 +-- test/output_tests/test_output_2 | 8 ++-- test/output_tests/test_output_3 | 8 ++-- 9 files changed, 116 insertions(+), 34 deletions(-) create mode 100644 test/cumulative_tests/test_write_ins_null diff --git a/tally_pipes/main.py b/tally_pipes/main.py index 3d8bb24..a2c0b8e 100755 --- a/tally_pipes/main.py +++ b/tally_pipes/main.py @@ -267,6 +267,12 @@ def create_ephemeral_tally(econfig_path): return tmp_dir def main(pargs): + from tally_methods.voting_systems.base import ( + BlankVoteException, + ExplicitInvalidVoteException, + ImplicitInvalidVoteException + ) + # load config if pargs.config is not None: with codecs.open(pargs.config, 'r', encoding="utf-8") as f: @@ -376,7 +382,8 @@ def ballots_printer(vote, question, question_num, exception): vote_json['question_num'] = question_num vote_json['ballot_flags'] = dict( blank_vote=False, - null_vote=False + null_vote=False, + implicit_null_vote=False ) if 'winners' in vote_json: del vote_json['winners'] @@ -395,13 +402,20 @@ def ballots_printer(vote, question, question_num, exception): del vote_answer['winner_position'] # detect blank and null votes and mark accordingly - if vote == "BLANK_VOTE": - vote_str += ["BLANK_VOTE"] - vote_json['ballot_flags']['blank_vote'] = True - elif vote == "NULL_VOTE": - vote_str += ["NULL_VOTE"] - vote_json['ballot_flags']['null_vote'] = True - else: + if exception is not None: + if isinstance(exception, BlankVoteException): + vote_str += ["BLANK_VOTE"] + vote_json['ballot_flags']['blank_vote'] = True + elif isinstance(exception, ImplicitInvalidVoteException): + vote_str += ["NULL_VOTE"] + vote_json['ballot_flags']['implicit_null_vote'] = True + elif isinstance(exception, ExplicitInvalidVoteException): + vote_str += ["NULL_VOTE"] + vote_json['ballot_flags']['null_vote'] = True + else: + vote_str += ["NULL_VOTE"] + vote_json['ballot_flags']['implicit_null_vote'] = True + if vote is not None: if question['tally_type'] != 'cumulative': sorted_vote = sorted( list(vote), diff --git a/tally_pipes/pipes/results.py b/tally_pipes/pipes/results.py index eb36e3a..d52f45b 100644 --- a/tally_pipes/pipes/results.py +++ b/tally_pipes/pipes/results.py @@ -18,7 +18,11 @@ import os import json import tally_methods.tally -from tally_methods.voting_systems.base import BlankVoteException +from tally_methods.voting_systems.base import ( + BlankVoteException, + ExplicitInvalidVoteException, + ImplicitInvalidVoteException +) from collections import defaultdict def do_tallies( @@ -49,12 +53,18 @@ def parse_vote_wrapper(number, question, q_withdrawals): try: vote = parse_vote(number, question, q_withdrawals) - except BlankVoteException as e: - exception = e - vote = "BLANK_VOTE" - except Exception as e: - exception = e - vote = "NULL_VOTE" + except BlankVoteException as error: + exception = error + vote = error.ballot + except ImplicitInvalidVoteException as error: + exception = error + vote = error.ballot + except ExplicitInvalidVoteException as error: + exception = error + vote = error.ballot + except Exception as error: + exception = error + vote = None ballots_printer(vote, question, tally.question_num, exception) if exception is not None: diff --git a/test/borda_tests/test_1 b/test/borda_tests/test_1 index fa6427a..502d7eb 100644 --- a/test/borda_tests/test_1 +++ b/test/borda_tests/test_1 @@ -14,6 +14,6 @@ Ballots CSV: 0,"3. C1f","0. A1f","2. D1m" Ballots JSON: -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"ballot_marks": 0, "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"ballot_marks": 0, "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} diff --git a/test/cumulative_tests/test_1 b/test/cumulative_tests/test_1 index d878736..fb78236 100644 --- a/test/cumulative_tests/test_1 +++ b/test/cumulative_tests/test_1 @@ -13,8 +13,8 @@ Ballots CSV: 0,"1. A1f" Ballots JSON: -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 3, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "extra_options": {"cumulative_number_of_checkboxes": 3}, "layout": "simple", "max": 3, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "extra_options": {"cumulative_number_of_checkboxes": 3}, "layout": "simple", "max": 3, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "extra_options": {"cumulative_number_of_checkboxes": 3}, "layout": "simple", "max": 3, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 3, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "extra_options": {"cumulative_number_of_checkboxes": 3}, "layout": "simple", "max": 3, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "extra_options": {"cumulative_number_of_checkboxes": 3}, "layout": "simple", "max": 3, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "extra_options": {"cumulative_number_of_checkboxes": 3}, "layout": "simple", "max": 3, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Desborda question"} diff --git a/test/cumulative_tests/test_write_ins b/test/cumulative_tests/test_write_ins index c010b72..b57df89 100644 --- a/test/cumulative_tests/test_write_ins +++ b/test/cumulative_tests/test_write_ins @@ -53,6 +53,6 @@ Ballots CSV: 0,"1. Candidate1" Ballots JSON: -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"category": "", "id": 0, "text": "Candidate1", "total_count": 0, "urls": []}, {"category": "", "id": 1, "text": "Candidate2", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "", "id": 2, "isWriteIn": "true", "text": "Write-in-candidate", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "", "election_index": 0, "extra_options": {"allow_writeins": true, "cumulative_number_of_checkboxes": 4}, "id": 0, "layout": "simple", "max": 4, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Cumulative with Write-Ins"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "", "id": 0, "text": "Candidate1", "total_count": 0, "urls": []}, {"category": "", "id": 1, "text": "Candidate2", "total_count": 0, "urls": []}, {"category": "", "id": 2, "isWriteIn": "true", "text": "", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "", "election_index": 0, "extra_options": {"allow_writeins": true, "cumulative_number_of_checkboxes": 4}, "id": 0, "layout": "simple", "max": 4, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Cumulative with Write-Ins"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"category": "", "id": 0, "text": "Candidate1", "total_count": 0, "urls": []}, {"category": "", "id": 1, "text": "Candidate2", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "", "id": 2, "isWriteIn": "true", "text": "Write-in-candidate", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "", "election_index": 0, "extra_options": {"allow_writeins": true, "cumulative_number_of_checkboxes": 4}, "id": 0, "layout": "simple", "max": 4, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Cumulative with Write-Ins"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"ballot_marks": 1, "category": "", "id": 0, "text": "Candidate1", "total_count": 0, "urls": []}, {"category": "", "id": 1, "text": "Candidate2", "total_count": 0, "urls": []}, {"category": "", "id": 2, "isWriteIn": "true", "text": "", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "", "election_index": 0, "extra_options": {"allow_writeins": true, "cumulative_number_of_checkboxes": 4}, "id": 0, "layout": "simple", "max": 4, "min": 0, "num_winners": 2, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Cumulative with Write-Ins"} diff --git a/test/cumulative_tests/test_write_ins_null b/test/cumulative_tests/test_write_ins_null new file mode 100644 index 0000000..f153189 --- /dev/null +++ b/test/cumulative_tests/test_write_ins_null @@ -0,0 +1,58 @@ +Votes: Cumulative with Write-Ins with invalid votes +Candidate2,2#Write-in-candidate,2#Write-in-candidate +2#Write-in-candidate + +Questions JSON: +[ + { + "answer_total_votes_percentage": "over-total-valid-votes", + "answers": [ + { + "id": 0, + "text": "Candidate1", + "urls": [], + "category": "" + }, + { + "id": 1, + "text": "Candidate2", + "urls": [], + "category": "" + }, + { + "id": 2, + "text": "", + "category": "Category1", + "urls": [ + {"title": "isWriteIn", "url": "true"} + ] + } + ], + "description": "", + "extra_options": { + "cumulative_number_of_checkboxes": 4, + "allow_writeins": true, + "enable_panachage": false + }, + "layout": "simple", + "max": 4, + "min": 0, + "num_winners": 1, + "id": 0, + "randomize_answer_order": true, + "tally_type": "cumulative", + "title": "Cumulative with Write-Ins" + } +] + +Results: +Write-in-candidate, 1 + +Ballots CSV: +0,NULL_VOTE,"1. Candidate2","2. Write-in-candidate" +0,"1. Write-in-candidate" + +Ballots JSON: +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"category": "", "id": 0, "text": "Candidate1", "total_count": 0, "urls": []}, {"ballot_marks": 1, "category": "", "id": 1, "text": "Candidate2", "total_count": 0, "urls": []}, {"ballot_marks": 2, "category": "Category1", "id": 2, "isWriteIn": "true", "text": "Write-in-candidate", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": true, "null_vote": false}, "description": "", "election_index": 0, "extra_options": {"allow_writeins": true, "cumulative_number_of_checkboxes": 4, "enable_panachage": false}, "id": 0, "layout": "simple", "max": 4, "min": 0, "num_winners": 1, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Cumulative with Write-Ins"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"category": "", "id": 0, "text": "Candidate1", "total_count": 0, "urls": []}, {"category": "", "id": 1, "text": "Candidate2", "total_count": 0, "urls": []}, {"ballot_marks": 1, "category": "Category1", "id": 2, "isWriteIn": "true", "text": "Write-in-candidate", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "", "election_index": 0, "extra_options": {"allow_writeins": true, "cumulative_number_of_checkboxes": 4, "enable_panachage": false}, "id": 0, "layout": "simple", "max": 4, "min": 0, "num_winners": 1, "question_num": 0, "randomize_answer_order": true, "tally_type": "cumulative", "title": "Cumulative with Write-Ins"} + diff --git a/test/output_tests/test_output_1 b/test/output_tests/test_output_1 index a0cf214..0394659 100644 --- a/test/output_tests/test_output_1 +++ b/test/output_tests/test_output_1 @@ -14,6 +14,6 @@ Ballots CSV: 0,"3. C1f","0. A1f","2. D1m" Ballots JSON: -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 0, "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 0, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 1, "category": "A", "details": "A1f", "id": 0, "text": "A1f", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 2, "category": "D", "details": "D1m", "id": 2, "text": "D1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 0, "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 3, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "borda", "title": "Desborda question"} diff --git a/test/output_tests/test_output_2 b/test/output_tests/test_output_2 index ef0e3e4..d202e5f 100644 --- a/test/output_tests/test_output_2 +++ b/test/output_tests/test_output_2 @@ -16,7 +16,7 @@ Ballots CSV: 0,"2. C1f" Ballots JSON: -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 1, "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} \ No newline at end of file +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 1, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 1, "category": "C", "details": "C1f", "id": 2, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 1, "min": 0, "num_winners": 3, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} diff --git a/test/output_tests/test_output_3 b/test/output_tests/test_output_3 index fe67fd4..b008206 100644 --- a/test/output_tests/test_output_3 +++ b/test/output_tests/test_output_3 @@ -17,7 +17,7 @@ Ballots CSV: 0,"3. C1f" Ballots JSON: -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} -{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 1, "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} \ No newline at end of file +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "ballot_marks": 1, "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"} +{"answer_total_votes_percentage": "over-total-valid-votes", "answers": [{"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A1m", "id": 0, "text": "A1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "A", "details": "A2m", "id": 1, "text": "A2m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/H", "category": "B", "details": "B1m", "id": 2, "text": "B1m", "total_count": 0, "urls": []}, {"Gender": "https://sequentech.io/api/gender/M", "ballot_marks": 1, "category": "C", "details": "C1f", "id": 3, "text": "C1f", "total_count": 0, "urls": []}], "ballot_flags": {"blank_vote": false, "implicit_null_vote": false, "null_vote": false}, "description": "Desborda question", "election_index": 0, "layout": "simple", "max": 2, "min": 0, "num_winners": 4, "question_num": 0, "randomize_answer_order": true, "tally_type": "plurality-at-large", "title": "Desborda question"}