diff --git a/Tests/test_pvlive_api.py b/Tests/test_pvlive_api.py index 70eec2d..9ab6c08 100644 --- a/Tests/test_pvlive_api.py +++ b/Tests/test_pvlive_api.py @@ -18,7 +18,14 @@ def setUp(self): """ Setup the instance of class. """ - self.api = PVLive() + self.api = PVLive( + retries=3, + proxies=None, + ssl_verify=True, + # domain_url="api0.solar.sheffield.ac.uk", + domain_url="api.solar.sheffield.ac.uk", + # domain_url="api.pvlive.uk" + ) self.expected_dtypes = { "pes_id": ptypes.is_integer_dtype, "gsp_id": ptypes.is_integer_dtype, diff --git a/pvlive_api/pvlive.py b/pvlive_api/pvlive.py index 5faf69a..1302432 100644 --- a/pvlive_api/pvlive.py +++ b/pvlive_api/pvlive.py @@ -48,8 +48,27 @@ class PVLive: Optionally specify a Dict of proxies for http and https requests in the format: {"http": "
", "https": ""} """ - def __init__(self, retries: int = 3, proxies: Optional[Dict] = None, ssl_verify: bool = True): - self.domain_url = "https://api.solar.sheffield.ac.uk" + def __init__( + self, + retries: int = 3, + proxies: Optional[Dict] = None, + ssl_verify: bool = True, + domain_url: Literal[ + "api0.solar.sheffield.ac.uk", + "api.solar.sheffield.ac.uk", + "api.pvlive.uk" + ] = "api.solar.sheffield.ac.uk" + ): + valid_domain_urls = [ + "api0.solar.sheffield.ac.uk", + "api.solar.sheffield.ac.uk", + "api.pvlive.uk" + ] + if domain_url not in valid_domain_urls: + raise ValueError( + f"`domain_url` of '{domain_url}' is invalid, must be one of: {valid_domain_urls}" + ) + self.domain_url = f"https://{domain_url}" self.base_url = f"{self.domain_url}/pvlive/api/v4" self.max_range = {"national": timedelta(days=365), "regional": timedelta(days=30)} self.retries = retries