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

DemocracyClub / aggregator-api / ccc812dd-b54f-4b48-9bcc-0687504f376d

11 Dec 2025 01:08PM UTC coverage: 75.986% (+0.2%) from 75.762%
ccc812dd-b54f-4b48-9bcc-0687504f376d

push

circleci

GeoWill
add string type, parse api_token and utm_params

4 of 4 new or added lines in 1 file covered. (100.0%)

19 existing lines in 4 files now uncovered.

1060 of 1395 relevant lines covered (75.99%)

0.76 hits per line

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

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

8
from common.async_requests import UpstreamApiError
1✔
9
from common.query_string import clean_query_params
1✔
10

11

12
async def get_postcode(request: Request):
1✔
13
    postcode = request.path_params["postcode"].upper()
1✔
14
    logger: DCWidePostcodeLoggingClient = request.app.state.POSTCODE_LOGGER
1✔
15
    params: QueryParams = clean_query_params(request, QueryParams)
1✔
16

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

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

29
        has_ballot = any(
1✔
30
            date.get("ballots") for date in result.get("dates", [])
31
        )
32

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

44
    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