import polars as pl from pipeline.download.election_results import _convert_results def test_convert_results_fills_parties_that_did_not_stand_with_zero(): raw = pl.DataFrame( { "Constituency geographic code": ["E14000001", "E14000001"], "Main party name": ["Labour", "Conservative"], "Candidate result position": [1, 2], "Election valid vote count": [1000, 1000], "Electorate": [2000, 2000], "Candidate vote count": [600, 400], } ) result = _convert_results(raw) assert result.select("% Labour", "% Conservative", "% Reform UK").to_dicts() == [ {"% Labour": 60.0, "% Conservative": 40.0, "% Reform UK": 0.0} ]