|
4 | 4 | from unittest.mock import patch |
5 | 5 |
|
6 | 6 | import pytest |
| 7 | +from requests.structures import CaseInsensitiveDict |
7 | 8 |
|
8 | 9 | from sortition_algorithms.errors import InfeasibleQuotasError, SelectionError, SelectionMultilineError |
9 | 10 | from sortition_algorithms.features import FeatureValueMinMax |
@@ -509,21 +510,20 @@ def test_run_report_with_multiline_error_deserialisation(self): |
509 | 510 |
|
510 | 511 | def test_run_report_with_infeasible_quotas_error_serialisation(self): |
511 | 512 | report = RunReport() |
512 | | - report.add_error( |
513 | | - InfeasibleQuotasError( |
514 | | - features={"feat1": {"value1": FeatureValueMinMax(min=2, max=4)}}, output=["line1", "line2"] |
515 | | - ) |
516 | | - ) |
| 513 | + features = CaseInsensitiveDict() |
| 514 | + features["feat1"] = CaseInsensitiveDict() |
| 515 | + features["feat1"]["value1"] = FeatureValueMinMax(min=2, max=4) |
| 516 | + report.add_error(InfeasibleQuotasError(features=features, output=["line1", "line2"])) |
517 | 517 | serialised_form = report.serialize() |
518 | 518 | assert "_data" in serialised_form |
519 | 519 | assert len(serialised_form["_data"]) == 1 |
520 | 520 |
|
521 | 521 | def test_run_report_with_infeasible_quotas_error_deserialisation(self): |
522 | 522 | report = RunReport() |
523 | | - error = InfeasibleQuotasError( |
524 | | - features={"feat1": {"value1": FeatureValueMinMax(min=2, max=4)}}, output=["line1", "line2"] |
525 | | - ) |
526 | | - report.add_error(error) |
| 523 | + features = CaseInsensitiveDict() |
| 524 | + features["feat1"] = CaseInsensitiveDict() |
| 525 | + features["feat1"]["value1"] = FeatureValueMinMax(min=2, max=4) |
| 526 | + report.add_error(InfeasibleQuotasError(features=features, output=["line1", "line2"])) |
527 | 527 | serialised_form = report.serialize() |
528 | 528 | deserialised_report = RunReport.deserialize(serialised_form) |
529 | 529 |
|
|
0 commit comments