podpointclient 2.0.1__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {podpointclient-2.0.1 → podpointclient-2.0.2}/PKG-INFO +2 -2
- {podpointclient-2.0.1 → podpointclient-2.0.2}/README.md +1 -1
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/helpers/functions.py +6 -1
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/version.py +1 -1
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient.egg-info/PKG-INFO +2 -2
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient.egg-info/SOURCES.txt +1 -0
- podpointclient-2.0.2/tests/test_blocked_requests.py +33 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/LICENSE +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/__init__.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/charge.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/charge_mode.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/charge_override.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/client.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/connectivity_status.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/endpoints.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/errors.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/factories.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/helpers/__init__.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/helpers/api_wrapper.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/helpers/auth.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/helpers/enums.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/helpers/redact.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/helpers/session.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/pod.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/py.typed +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/schedule.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient/user.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient.egg-info/dependency_links.txt +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient.egg-info/requires.txt +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/podpointclient.egg-info/top_level.txt +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/pyproject.toml +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/setup.cfg +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/setup.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_api_wrapper.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_auth.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_charge.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_charge_factory.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_charge_override.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_client.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_connectivity_status.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_connectivity_status_factory.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_documentation.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_enums.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_firmware.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_firmware_camel_case.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_firmware_factory.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_helpers.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_pod.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_pod_factory.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_redact.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_schedule.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_session.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_user.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_user_factory.py +0 -0
- {podpointclient-2.0.1 → podpointclient-2.0.2}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: podpointclient
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: A simple API client for Pod Point (https://pod-point.com) aimed at home users
|
|
5
5
|
Home-page: https://github.com/mattrayner/podpointclient
|
|
6
6
|
Author: Matthew Rayner
|
|
@@ -118,7 +118,7 @@ Error | Meaning
|
|
|
118
118
|
`MfaInvalidCode` | *The SMS code was wrong* - Ask for the code again. A subclass of `MfaError`.
|
|
119
119
|
`MfaError` | *The SMS challenge could not be started or completed, including when the verification service could not be reached. `async_start_mfa` also raises it, with the response's `status`, for rate limiting or server errors* - A subclass of `AuthError`.
|
|
120
120
|
`ApiConnectionError` | *Pod Point could not be reached* - Retry later.
|
|
121
|
-
`ApiServerError` | *Rate limiting (429), a server error (5xx) or a sign-in throttled by Google, from any call except `async_start_mfa`* - A subclass of `ApiConnectionError`, never of `AuthError`. Retry later.
|
|
121
|
+
`ApiServerError` | *Rate limiting (429), a server error (5xx), a `403` which is not JSON (requests being blocked) or a sign-in throttled by Google, from any call except `async_start_mfa`* - A subclass of `ApiConnectionError`, never of `AuthError`. Retry later.
|
|
122
122
|
`APIError` | *Anything else, such as an unexpected response* - The base class of all of these.
|
|
123
123
|
|
|
124
124
|
### Setting charging schedules
|
|
@@ -87,7 +87,7 @@ Error | Meaning
|
|
|
87
87
|
`MfaInvalidCode` | *The SMS code was wrong* - Ask for the code again. A subclass of `MfaError`.
|
|
88
88
|
`MfaError` | *The SMS challenge could not be started or completed, including when the verification service could not be reached. `async_start_mfa` also raises it, with the response's `status`, for rate limiting or server errors* - A subclass of `AuthError`.
|
|
89
89
|
`ApiConnectionError` | *Pod Point could not be reached* - Retry later.
|
|
90
|
-
`ApiServerError` | *Rate limiting (429), a server error (5xx) or a sign-in throttled by Google, from any call except `async_start_mfa`* - A subclass of `ApiConnectionError`, never of `AuthError`. Retry later.
|
|
90
|
+
`ApiServerError` | *Rate limiting (429), a server error (5xx), a `403` which is not JSON (requests being blocked) or a sign-in throttled by Google, from any call except `async_start_mfa`* - A subclass of `ApiConnectionError`, never of `AuthError`. Retry later.
|
|
91
91
|
`APIError` | *Anything else, such as an unexpected response* - The base class of all of these.
|
|
92
92
|
|
|
93
93
|
### Setting charging schedules
|
|
@@ -68,7 +68,12 @@ def is_temporary_error(status: int, body: Any) -> bool:
|
|
|
68
68
|
|
|
69
69
|
try:
|
|
70
70
|
if isinstance(body, str):
|
|
71
|
-
|
|
71
|
+
try:
|
|
72
|
+
body = loads(body)
|
|
73
|
+
except (ValueError, RecursionError):
|
|
74
|
+
# Pod Point and Google reject credentials with JSON. A 403 page which
|
|
75
|
+
# is not JSON comes from something in front of them blocking requests
|
|
76
|
+
return status == 403
|
|
72
77
|
error = body["error"]
|
|
73
78
|
message = error.get("message")
|
|
74
79
|
error_status = error.get("status")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: podpointclient
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: A simple API client for Pod Point (https://pod-point.com) aimed at home users
|
|
5
5
|
Home-page: https://github.com/mattrayner/podpointclient
|
|
6
6
|
Author: Matthew Rayner
|
|
@@ -118,7 +118,7 @@ Error | Meaning
|
|
|
118
118
|
`MfaInvalidCode` | *The SMS code was wrong* - Ask for the code again. A subclass of `MfaError`.
|
|
119
119
|
`MfaError` | *The SMS challenge could not be started or completed, including when the verification service could not be reached. `async_start_mfa` also raises it, with the response's `status`, for rate limiting or server errors* - A subclass of `AuthError`.
|
|
120
120
|
`ApiConnectionError` | *Pod Point could not be reached* - Retry later.
|
|
121
|
-
`ApiServerError` | *Rate limiting (429), a server error (5xx) or a sign-in throttled by Google, from any call except `async_start_mfa`* - A subclass of `ApiConnectionError`, never of `AuthError`. Retry later.
|
|
121
|
+
`ApiServerError` | *Rate limiting (429), a server error (5xx), a `403` which is not JSON (requests being blocked) or a sign-in throttled by Google, from any call except `async_start_mfa`* - A subclass of `ApiConnectionError`, never of `AuthError`. Retry later.
|
|
122
122
|
`APIError` | *Anything else, such as an unexpected response* - The base class of all of these.
|
|
123
123
|
|
|
124
124
|
### Setting charging schedules
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import aiohttp
|
|
2
|
+
import pytest
|
|
3
|
+
from aioresponses import aioresponses
|
|
4
|
+
|
|
5
|
+
from podpointclient.errors import ApiServerError, SessionError
|
|
6
|
+
from podpointclient.helpers.api_wrapper import APIWrapper
|
|
7
|
+
from podpointclient.helpers.functions import is_temporary_error
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.mark.parametrize("status, body, temporary", [
|
|
11
|
+
(403, "<html>Request blocked</html>", True),
|
|
12
|
+
(403, "", True),
|
|
13
|
+
(403, '{"error": {"message": "PERMISSION_DENIED"}}', False),
|
|
14
|
+
(403, '{"message": "Forbidden"}', False),
|
|
15
|
+
(401, "<html>Unauthorized</html>", False),
|
|
16
|
+
(400, "Bad request", False),
|
|
17
|
+
])
|
|
18
|
+
def test_is_temporary_error(status, body, temporary):
|
|
19
|
+
assert is_temporary_error(status, body) is temporary
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.mark.asyncio
|
|
23
|
+
async def test_blocked_request_is_not_a_session_error():
|
|
24
|
+
with aioresponses() as m:
|
|
25
|
+
m.post("https://example.com/sessions", status=403, body="<html></html>")
|
|
26
|
+
async with aiohttp.ClientSession() as session:
|
|
27
|
+
with pytest.raises(ApiServerError) as error:
|
|
28
|
+
await APIWrapper(session).post(
|
|
29
|
+
"https://example.com/sessions", body={}, headers={},
|
|
30
|
+
exception_class=SessionError,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
assert error.value.status == 403
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|