def test_tables_of_different_len( invalid_opened_data_one_table_longer: AuditTables, invalid_commitment_data_one_table_longer: TallyTables, ): assert (audit_tables( invalid_opened_data_one_table_longer, invalid_commitment_data_one_table_longer, ) is False)
def audit_elections( data_opened: str, data_pre_election: str, data_tally: str, bb: str, tally_all: str, group_id: Optional[str] = typer.Argument(None), ): data_pre_election = _load_pre_election(data_pre_election) data_tally = _load_tally_data(data_tally) print("Auditing pre_election - data_tally...") with click_spinner.spinner(): valid = audit_pre_election_tables(data_pre_election, data_tally) print("valid" if valid else "not valid!") del data_pre_election data_opened = _load_opened_data(data_opened) print("Auditing data_tally - data_opened...") with click_spinner.spinner(): valid = audit_tables(data_opened, data_tally) print("valid" if valid else "not valid") del data_tally bb = _load_bb(bb) if group_id is not None: print( f"Filtering bulletin board is enabled, only votes for group {group_id} will be taken into account" ) bb_filtered = {} for vote_id, bb_entry in bb.items(): if bb_entry.group_id == group_id: bb_filtered[vote_id] = bb_entry bb = bb_filtered print("Auditing data_opened - bb...") with click_spinner.spinner(): valid = audit_bb(bb, data_opened) print("valid" if valid else "not valid") del bb tally_all = _load_tally(tally_all) print("Auditing data_opened - tally with all votes...") with click_spinner.spinner(): valid = audit_tables_tally(tally_all, data_opened) print("valid" if valid else "not valid")
def test_successful_audit(opened_data: AuditTables, commitment_data: TallyTables): assert audit_tables(opened_data, commitment_data) is True
def test_empty_data(): assert audit_tables(dict(), dict()) is False
def test_invalid_commitment_audit(opened_data: AuditTables, invalid_commitment_data: TallyTables): assert audit_tables(opened_data, invalid_commitment_data) is False