getrak-python-sdk 1.1.0__tar.gz → 1.2.0__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.
- {getrak_python_sdk-1.1.0/src/getrak_python_sdk.egg-info → getrak_python_sdk-1.2.0}/PKG-INFO +1 -1
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/pyproject.toml +1 -1
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/apis/recebidos.py +5 -1
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/errors.py +4 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0/src/getrak_python_sdk.egg-info}/PKG-INFO +1 -1
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/tests/test_client.py +23 -1
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/LICENSE +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/README.md +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/setup.cfg +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/__init__.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/api.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/apis/__init__.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/apis/localizacoes.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/__init__.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/models/__init__.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/models/dataexplained.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/models/vehicle.py +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/SOURCES.txt +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/dependency_links.txt +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/requires.txt +0 -0
- {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/top_level.txt +0 -0
|
@@ -6,7 +6,7 @@ import jsonpickle
|
|
|
6
6
|
from http import HTTPMethod
|
|
7
7
|
from fmconsult.utils.url import UrlUtil
|
|
8
8
|
from getrak.api import GetrakApi
|
|
9
|
-
from getrak.errors import GetrakError, InvalidVehicleId
|
|
9
|
+
from getrak.errors import GetrakError, InvalidVehicleId, VehicleNotFound
|
|
10
10
|
|
|
11
11
|
VEHICLE_ID_RE = re.compile(r"^[A-Za-z0-9_-]+$")
|
|
12
12
|
|
|
@@ -34,6 +34,10 @@ class Recebidos(GetrakApi):
|
|
|
34
34
|
body = json.loads(raw)
|
|
35
35
|
except ValueError:
|
|
36
36
|
raise GetrakError("resposta de recebidos não é JSON") from None
|
|
37
|
+
if isinstance(body, dict):
|
|
38
|
+
message = body.get("error") if isinstance(body.get("error"), str) else ""
|
|
39
|
+
if "não encontrado" in message.casefold():
|
|
40
|
+
raise VehicleNotFound(message)
|
|
37
41
|
if not isinstance(body, list):
|
|
38
42
|
raise GetrakError("resposta de recebidos não é uma lista")
|
|
39
43
|
if not all(isinstance(item, dict) for item in body):
|
|
@@ -6,5 +6,9 @@ class InvalidVehicleId(GetrakError):
|
|
|
6
6
|
pass
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
class VehicleNotFound(GetrakError):
|
|
10
|
+
"""A conta não tem esse veículo. Não há lista de posições para gravar."""
|
|
11
|
+
|
|
12
|
+
|
|
9
13
|
class AuthenticationFailed(GetrakError):
|
|
10
14
|
"""A Getrak recusou as credenciais. Vale para as chamadas seguintes desta instância."""
|
|
@@ -6,7 +6,7 @@ import responses
|
|
|
6
6
|
from responses import registries
|
|
7
7
|
|
|
8
8
|
from getrak.apis.recebidos import Recebidos
|
|
9
|
-
from getrak.errors import AuthenticationFailed, GetrakError, InvalidVehicleId
|
|
9
|
+
from getrak.errors import AuthenticationFailed, GetrakError, InvalidVehicleId, VehicleNotFound
|
|
10
10
|
|
|
11
11
|
BASE = "https://api.getrak.com"
|
|
12
12
|
AUTH = f"{BASE}/newkoauth/oauth/token"
|
|
@@ -114,3 +114,25 @@ def test_non_list_is_an_error():
|
|
|
114
114
|
)
|
|
115
115
|
with pytest.raises(GetrakError):
|
|
116
116
|
client.fetch("12345", "2026-10-04T03:00:00", "2026-10-05T02:59:59")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_unknown_vehicle_is_a_specific_error():
|
|
120
|
+
with responses.RequestsMock() as http:
|
|
121
|
+
http.add(responses.POST, AUTH, json={"access_token": "tok"}, status=200)
|
|
122
|
+
http.add(
|
|
123
|
+
responses.GET,
|
|
124
|
+
POS,
|
|
125
|
+
json={"error": "Veículo não encontrado para o cliente informado", "status": 404},
|
|
126
|
+
status=200,
|
|
127
|
+
)
|
|
128
|
+
client = Recebidos(
|
|
129
|
+
auth_code=AUTH_CODE,
|
|
130
|
+
login="usuario",
|
|
131
|
+
password=PASSWORD,
|
|
132
|
+
grant_type="password",
|
|
133
|
+
authenticate_on_init=False,
|
|
134
|
+
verbose=False,
|
|
135
|
+
log_requests=False,
|
|
136
|
+
)
|
|
137
|
+
with pytest.raises(VehicleNotFound):
|
|
138
|
+
client.fetch("12345", "2026-10-04T03:00:00", "2026-10-05T02:59:59")
|
|
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
|
{getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/models/dataexplained.py
RENAMED
|
File without changes
|
|
File without changes
|
{getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/requires.txt
RENAMED
|
File without changes
|
{getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|