Skip to content

Commit

Permalink
set up mock responses for CoL registration edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed Oct 30, 2024
1 parent 594abf4 commit 0c41884
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions postcode_lookup/mock_responses.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from response_builder.v1.builders.ballots import (
LocalBallotBuilder,
ParlBallotBuilder,
)
from response_builder.v1.builders.base import RootBuilder
from response_builder.v1.generated_responses import candidates
from response_builder.v1.generated_responses.root_responses import (
CANCELLED_BALLOT_CANDIDATE_DEATH,
CANCELLED_BALLOT_EQUAL_CANDIDATES,
Expand All @@ -11,6 +17,49 @@
SINGLE_LOCAL_FUTURE_BALLOT_WITHOUT_POLLING_STATION,
)


class CityOfLondonParlBallot(ParlBallotBuilder):
def __init__(self, poll_open_date, **kwargs):
super().__init__(**kwargs)
self.with_ballot_paper_id(
f"parl.cities-of-london-and-westminster.{poll_open_date}"
)
self.with_ballot_title(
"UK Parliamentary general election Cities of London and Westminster"
)
self.with_date(poll_open_date)
self.with_post_name("Cities of London and Westminster")
self.with_election_name("UK Parliamentary general election")
self.with_election_id(f"parl.{poll_open_date}")
self.with_candidates(candidates.all_candidates)


class CityOfLondonLocalBallot(LocalBallotBuilder):
def __init__(self, poll_open_date, **kwargs):
super().__init__(**kwargs)
self.with_ballot_paper_id(
f"local.city-of-london.aldersgate.{poll_open_date}"
)
self.with_ballot_title("City of London local election Aldersgate")
self.with_date(poll_open_date)
self.with_post_name("Aldersgate")
self.with_election_name("City of London local election")
self.with_election_id(f"local.city-of-london.{poll_open_date}")
self.with_candidates(candidates.all_candidates)


CITY_OF_LONDON_COUNCIL_AND_PARL_DIFFERENT_DAYS = (
RootBuilder()
.with_ballot(CityOfLondonLocalBallot("2025-03-20").build())
.with_ballot(CityOfLondonParlBallot("2025-05-01").build())
)
CITY_OF_LONDON_COUNCIL_AND_PARL_SAME_DAY = (
RootBuilder()
.with_ballot(CityOfLondonLocalBallot("2025-03-20").build())
.with_ballot(CityOfLondonParlBallot("2025-03-20").build())
)


__ALL__ = ("example_responses",)
example_responses = {
"AA1 1AA": {
Expand Down Expand Up @@ -69,4 +118,12 @@
# "description": "Police and Crime Commissioner ballot",
# "response": PCC_BALLOT,
# },
"AA1 1AL": {
"description": "City of London (Common Councilman) and UK Parl ballots on different upcoming dates",
"response": CITY_OF_LONDON_COUNCIL_AND_PARL_DIFFERENT_DAYS,
},
"AA1 1AM": {
"description": "City of London (Common Councilman) and UK Parl ballots on the same date",
"response": CITY_OF_LONDON_COUNCIL_AND_PARL_SAME_DAY,
},
}

0 comments on commit 0c41884

Please sign in to comment.