You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
motief/tests/test_inspect_positions_for_...

44 lines
1.4 KiB

import pytest
from explorer_helpers import inspect_positions_for_issues
def test_inspect_positions_for_issues_basic():
# Construct synthetic positions_by_window with 3 windows
positions_by_window = {
"2021-01": {
"mp_1": (0.1, 0.2),
"mp_2 (Amsterdam)": (0.5, 0.6),
},
"2021-02": {
"mp_2 (Amsterdam)": (0.4, 0.7),
"mp_3": (0.9, 0.1),
},
"2021-03": {
"mp_1": (0.2, 0.3),
# an MP id that is not in party_map
"unknown_mp": (0.0, 0.0),
},
}
party_map = {
"mp_1": "P1",
"mp_2": "P2",
"mp_3": "P3",
}
res = inspect_positions_for_issues(positions_by_window, party_map)
assert res["windows_count"] == 3
assert res["party_map_count"] == len(party_map)
# parties_with_centroid_counts: P1 present in windows 2021-01 and 2021-03 -> 2
assert res["parties_with_centroid_counts"].get("P1") == 2
# P2 present in 2021-01 and 2021-02 -> 2
assert res["parties_with_centroid_counts"].get("P2") == 2
# P3 present in 2021-02 -> 1
assert res["parties_with_centroid_counts"].get("P3") == 1
# mismatched_mp_ids_sample should contain 'unknown_mp'
assert "unknown_mp" in res["mismatched_mp_ids_sample"]
# mp_id_set should contain all seen MPs
assert res["mp_id_set"] >= {"mp_1", "mp_2 (Amsterdam)", "mp_3", "unknown_mp"}