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

DemocracyClub / aggregator-api / 4378480f-d814-445d-9764-64d1d09f71e0

15 Mar 2024 11:18AM UTC coverage: 80.431% (+0.3%) from 80.14%
4378480f-d814-445d-9764-64d1d09f71e0

Pull #493

circleci

symroe
Set data path for Blackpool
Pull Request #493: Refactor Recall petitions to work with parquet files

48 of 77 new or added lines in 7 files covered. (62.34%)

2 existing lines in 2 files now uncovered.

1044 of 1298 relevant lines covered (80.43%)

0.8 hits per line

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

86.21
/api/common/conf.py
1
import os
1✔
2

3
import boto3
1✔
4
from common.auth_models import ApiPlan
1✔
5

6
_s3_client_cache = None
1✔
7

8

9
def get_s3_client():
1✔
10
    global _s3_client_cache
11
    if _s3_client_cache is None:
×
12
        _s3_client_cache = boto3.client("s3")
×
13
    return _s3_client_cache
×
14

15

16
class BaseSettings:
1✔
17
    def __init__(self):
1✔
18
        self.DC_ENVIRONMENT = os.environ.get("DC_ENVIRONMENT", None)
1✔
19

20
        self.USER_AGENT = os.environ.get("API_USER_AGENT", "devs.DC API")
1✔
21
        self.WDIV_BASE_URL = "https://wheredoivote.co.uk/api/beta/"
1✔
22
        self.WDIV_API_KEY = os.environ.get("WDIV_API_KEY", None)
1✔
23
        self.EE_BASE_URL = "https://elections.democracyclub.org.uk/api/"
1✔
24

25
        self.WCIVF_BASE_URL = "https://whocanivotefor.co.uk/api/"
1✔
26
        self.WCIVF_BALLOT_CACHE_URL = (
1✔
27
            "https://wcivf-ballot-cache.s3.eu-west-2.amazonaws.com/ballot_data/"
28
        )
29

30
        # Only try to use the S3 Client if we think we're deployed
31
        self.S3_CLIENT_ENABLED = os.environ.get(
1✔
32
            "S3_CLIENT_ENABLED", bool(self.DC_ENVIRONMENT)
33
        )
34

35
        if self.S3_CLIENT_ENABLED:
1✔
UNCOV
36
            self.S3_CLIENT = get_s3_client()
×
37

38
        self.LOCAL_DATA_PATH = os.environ.get("LOCAL_STATIC_DATA_PATH", None)
1✔
39

40
        self.RECALL_PETITION_ENABLED = True
1✔
41

42
        self.PARL_BOUNDARY_CHANGES_ENABLED = True
1✔
43
        self.PARL_BOUNDARY_DATA_KEY_PREFIX = (
1✔
44
            "parl-2023-boundary-review/20230913"
45
        )
46
        self.PARL_BOUNDARY_DATA_BUCKET_NAME = (
1✔
47
            f"addressbase-lookups.{self.DC_ENVIRONMENT}"
48
        )
49
        self.RECALL_DATA_KEY_PREFIX = os.environ.get(
1✔
50
            "RECALL_DATA_KEY_PREFIX", "blackpool-south.2024-03/"
51
        )
52

53
        self.DEBUG = bool(int(os.environ.get("DEBUG", "0")))
1✔
54

55
        self.API_PLANS = {
1✔
56
            "hobbyists": ApiPlan(
57
                value="hobbyists", label="Hobbyists", request_per_day=1_000
58
            ),
59
            "standard": ApiPlan(
60
                value="standard", label="Standard", request_per_day=10_000
61
            ),
62
            "enterprise": ApiPlan(
63
                value="enterprise", label="Enterprise", request_per_day=0
64
            ),
65
        }
66

67

68
settings = BaseSettings()
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