• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DemocracyClub / aggregator-api / e0acd76c-d066-4767-97c0-9aa66a174d21

22 Oct 2025 08:42AM UTC coverage: 75.762% (+0.4%) from 75.403%
e0acd76c-d066-4767-97c0-9aa66a174d21

push

circleci

GeoWill
add setup remote docker step to build job

1044 of 1378 relevant lines covered (75.76%)

0.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/api/endpoints/v1/voting_information/postcode.py
1
from dc_logging_client import DCWidePostcodeLoggingClient
1✔
2
from elections_api_client import WdivWcivfApiClient
1✔
3
from starlette.requests import Request
1✔
4
from starlette.responses import JSONResponse
1✔
5
from stitcher import Stitcher
1✔
6

7
from common.async_requests import UpstreamApiError
1✔
8

9

10
async def get_postcode(request: Request):
1✔
11
    postcode = request.path_params["postcode"].upper()
1✔
12
    logger: DCWidePostcodeLoggingClient = request.app.state.POSTCODE_LOGGER
1✔
13

14
    client = WdivWcivfApiClient(query_params=request.query_params)
1✔
15
    try:
1✔
16
        wdiv, wcivf = client.get_data_for_postcode(postcode)
1✔
17
    except UpstreamApiError as error:
×
18
        return JSONResponse(error.message, status_code=error.status)
×
19
    stitcher = Stitcher(wdiv, wcivf, request)
1✔
20

21
    if not wdiv["polling_station_known"] and len(wdiv["addresses"]) > 0:
1✔
22
        result = stitcher.make_address_picker_response()
1✔
23
    else:
24
        result = stitcher.make_result_known_response()
1✔
25

26
        has_ballot = any(
1✔
27
            date.get("ballots") for date in result.get("dates", [])
28
        )
29

30
        logger.log(
1✔
31
            logger.entry_class(
32
                postcode=str(postcode),
33
                dc_product=logger.dc_product.aggregator_api,
34
                api_key=request.scope["api_user"].api_key,
35
                calls_devs_dc_api=False,
36
                had_election=has_ballot,
37
                **request.scope["utm_dict"],
38
            )
39
        )
40

41
    return JSONResponse(result)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc