controlid-sdk 0.3.2__tar.gz → 0.3.3__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.
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/PKG-INFO +14 -1
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/README.md +10 -0
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/pyproject.toml +11 -1
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid/__init__.py +20 -2
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid/client.py +37 -9
- controlid_sdk-0.3.3/src/controlid/exceptions.py +47 -0
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid_sdk.egg-info/PKG-INFO +14 -1
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid_sdk.egg-info/SOURCES.txt +3 -1
- controlid_sdk-0.3.3/src/controlid_sdk.egg-info/requires.txt +6 -0
- controlid_sdk-0.3.3/tests/test_client.py +98 -0
- controlid_sdk-0.3.3/tests/test_models.py +30 -0
- controlid_sdk-0.3.2/src/controlid/exceptions.py +0 -22
- controlid_sdk-0.3.2/src/controlid_sdk.egg-info/requires.txt +0 -2
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/setup.cfg +0 -0
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid/constants.py +0 -0
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid/models.py +0 -0
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid_sdk.egg-info/dependency_links.txt +0 -0
- {controlid_sdk-0.3.2 → controlid_sdk-0.3.3}/src/controlid_sdk.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: controlid-sdk
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: A production-ready asynchronous Python SDK for ControlID access control devices, supporting biometrics, networking, and complex time schedules.
|
|
5
5
|
Author-email: Tulio Amancio <root@tsuriu.com.br>
|
|
6
6
|
License: MIT
|
|
@@ -20,6 +20,9 @@ Requires-Python: >=3.9
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: httpx>=0.24.0
|
|
22
22
|
Requires-Dist: pydantic>=2.0.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
23
26
|
|
|
24
27
|
# ControlID Python SDK (Async)
|
|
25
28
|
|
|
@@ -192,6 +195,16 @@ await client.add_time_spans([
|
|
|
192
195
|
|
|
193
196
|
### 🧩 Generic Object API
|
|
194
197
|
|
|
198
|
+
## Firmware Compatibility Matrix
|
|
199
|
+
|
|
200
|
+
Since ControlID access control terminals run varying firmware versions, some API fields and tables may not be supported on all devices:
|
|
201
|
+
|
|
202
|
+
| Feature / Model | iDFace | iDAccess / iDFlex | iDBlock / Turnstiles | Notes |
|
|
203
|
+
| --- | --- | --- | --- | --- |
|
|
204
|
+
| **Card.type** | ⚠️ Supported only on newer firmware | ⚠️ Supported only on newer firmware | N/A | Older firmwares lack the `type` column in the `cards` table. Exclude it by leaving `Card.type = None`. |
|
|
205
|
+
| **Custom Database Fields** | ✅ Fully Supported | ⚠️ Depends on firmware version | N/A | Add custom fields (e.g. `cpf` to `c_users`) via `client.add_custom_field()`. |
|
|
206
|
+
| **Facial Templates** | ✅ Fully Supported | N/A | N/A | Enrollment and image upload functions require a device camera sensor. |
|
|
207
|
+
|
|
195
208
|
## Directory Structure
|
|
196
209
|
- `src/controlid/client.py`: Core asynchronous logic and endpoints.
|
|
197
210
|
- `src/controlid/models.py`: Pydantic V2 definitions.
|
|
@@ -169,6 +169,16 @@ await client.add_time_spans([
|
|
|
169
169
|
|
|
170
170
|
### 🧩 Generic Object API
|
|
171
171
|
|
|
172
|
+
## Firmware Compatibility Matrix
|
|
173
|
+
|
|
174
|
+
Since ControlID access control terminals run varying firmware versions, some API fields and tables may not be supported on all devices:
|
|
175
|
+
|
|
176
|
+
| Feature / Model | iDFace | iDAccess / iDFlex | iDBlock / Turnstiles | Notes |
|
|
177
|
+
| --- | --- | --- | --- | --- |
|
|
178
|
+
| **Card.type** | ⚠️ Supported only on newer firmware | ⚠️ Supported only on newer firmware | N/A | Older firmwares lack the `type` column in the `cards` table. Exclude it by leaving `Card.type = None`. |
|
|
179
|
+
| **Custom Database Fields** | ✅ Fully Supported | ⚠️ Depends on firmware version | N/A | Add custom fields (e.g. `cpf` to `c_users`) via `client.add_custom_field()`. |
|
|
180
|
+
| **Facial Templates** | ✅ Fully Supported | N/A | N/A | Enrollment and image upload functions require a device camera sensor. |
|
|
181
|
+
|
|
172
182
|
## Directory Structure
|
|
173
183
|
- `src/controlid/client.py`: Core asynchronous logic and endpoints.
|
|
174
184
|
- `src/controlid/models.py`: Pydantic V2 definitions.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "controlid-sdk"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.3"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Tulio Amancio", email="root@tsuriu.com.br" },
|
|
10
10
|
]
|
|
@@ -30,5 +30,15 @@ dependencies = [
|
|
|
30
30
|
"pydantic>=2.0.0",
|
|
31
31
|
]
|
|
32
32
|
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=7.0.0",
|
|
36
|
+
"pytest-asyncio>=0.21.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
33
39
|
[project.urls]
|
|
34
40
|
"Homepage" = "https://github.com/tulioamancio/controlid-python-sdk"
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.packages.find]
|
|
43
|
+
where = ["src"]
|
|
44
|
+
|
|
@@ -18,10 +18,21 @@ from .models import (
|
|
|
18
18
|
GPIOStatus,
|
|
19
19
|
CustomField,
|
|
20
20
|
)
|
|
21
|
-
from .exceptions import
|
|
21
|
+
from .exceptions import (
|
|
22
|
+
ControlIDError,
|
|
23
|
+
AuthenticationError,
|
|
24
|
+
SessionError,
|
|
25
|
+
APIError,
|
|
26
|
+
BadRequestError,
|
|
27
|
+
UnauthorizedError,
|
|
28
|
+
ForbiddenError,
|
|
29
|
+
NotFoundError,
|
|
30
|
+
RateLimitError,
|
|
31
|
+
DeviceUnreachableError,
|
|
32
|
+
)
|
|
22
33
|
from . import constants
|
|
23
34
|
|
|
24
|
-
__version__ = "0.3.
|
|
35
|
+
__version__ = "0.3.3"
|
|
25
36
|
|
|
26
37
|
__all__ = [
|
|
27
38
|
"ControlIDClient",
|
|
@@ -46,6 +57,13 @@ __all__ = [
|
|
|
46
57
|
"AuthenticationError",
|
|
47
58
|
"SessionError",
|
|
48
59
|
"APIError",
|
|
60
|
+
"BadRequestError",
|
|
61
|
+
"UnauthorizedError",
|
|
62
|
+
"ForbiddenError",
|
|
63
|
+
"NotFoundError",
|
|
64
|
+
"RateLimitError",
|
|
65
|
+
"DeviceUnreachableError",
|
|
49
66
|
# Constants module (handy for card type enums, table names, etc.)
|
|
50
67
|
"constants",
|
|
51
68
|
]
|
|
69
|
+
|
|
@@ -191,16 +191,44 @@ class ControlIDClient:
|
|
|
191
191
|
# Session expired — re-login and retry once
|
|
192
192
|
await self.login()
|
|
193
193
|
url = self._get_url(endpoint)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
194
|
+
try:
|
|
195
|
+
response = await self._client.post(url, json=payload or {}, timeout=timeout)
|
|
196
|
+
response.raise_for_status()
|
|
197
|
+
return response.json()
|
|
198
|
+
except httpx.HTTPStatusError as retry_e:
|
|
199
|
+
status_code = retry_e.response.status_code
|
|
200
|
+
msg = f"API Error: {retry_e.response.text}"
|
|
201
|
+
if status_code == 400:
|
|
202
|
+
raise ex.BadRequestError(msg, status_code=status_code, response=retry_e.response.text)
|
|
203
|
+
elif status_code == 401:
|
|
204
|
+
raise ex.UnauthorizedError(msg, status_code=status_code, response=retry_e.response.text)
|
|
205
|
+
elif status_code == 403:
|
|
206
|
+
raise ex.ForbiddenError(msg, status_code=status_code, response=retry_e.response.text)
|
|
207
|
+
elif status_code == 404:
|
|
208
|
+
raise ex.NotFoundError(msg, status_code=status_code, response=retry_e.response.text)
|
|
209
|
+
elif status_code == 429:
|
|
210
|
+
raise ex.RateLimitError(msg, status_code=status_code, response=retry_e.response.text)
|
|
211
|
+
else:
|
|
212
|
+
raise ex.APIError(msg, status_code=status_code, response=retry_e.response.text)
|
|
213
|
+
|
|
214
|
+
status_code = e.response.status_code
|
|
215
|
+
msg = f"API Error: {e.response.text}"
|
|
216
|
+
if status_code == 400:
|
|
217
|
+
raise ex.BadRequestError(msg, status_code=status_code, response=e.response.text)
|
|
218
|
+
elif status_code == 401:
|
|
219
|
+
raise ex.UnauthorizedError(msg, status_code=status_code, response=e.response.text)
|
|
220
|
+
elif status_code == 403:
|
|
221
|
+
raise ex.ForbiddenError(msg, status_code=status_code, response=e.response.text)
|
|
222
|
+
elif status_code == 404:
|
|
223
|
+
raise ex.NotFoundError(msg, status_code=status_code, response=e.response.text)
|
|
224
|
+
elif status_code == 429:
|
|
225
|
+
raise ex.RateLimitError(msg, status_code=status_code, response=e.response.text)
|
|
226
|
+
else:
|
|
227
|
+
raise ex.APIError(msg, status_code=status_code, response=e.response.text)
|
|
228
|
+
except (httpx.ConnectError, httpx.ConnectTimeout, httpx.ReadTimeout, httpx.WriteTimeout, httpx.PoolTimeout) as e:
|
|
229
|
+
raise ex.DeviceUnreachableError(f"Device unreachable: {type(e).__name__} {e}")
|
|
202
230
|
except Exception as e:
|
|
203
|
-
if isinstance(e, (ex.APIError, ex.AuthenticationError)): raise
|
|
231
|
+
if isinstance(e, (ex.APIError, ex.AuthenticationError, ex.DeviceUnreachableError)): raise
|
|
204
232
|
raise ex.ControlIDError(f"Request failed: {type(e).__name__} {e}")
|
|
205
233
|
|
|
206
234
|
async def get_system_information(self) -> Dict[str, Any]:
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class ControlIDError(Exception):
|
|
2
|
+
"""Base exception for ControlID SDK."""
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
class AuthenticationError(ControlIDError):
|
|
6
|
+
"""Raised when authentication fails."""
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
class SessionError(ControlIDError):
|
|
10
|
+
"""Raised when there is an issue with the session."""
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
class APIError(ControlIDError):
|
|
14
|
+
"""Raised when the API returns an error response."""
|
|
15
|
+
def __init__(self, message, status_code=None, response=None):
|
|
16
|
+
super().__init__(message)
|
|
17
|
+
self.status_code = status_code
|
|
18
|
+
self.response = response
|
|
19
|
+
|
|
20
|
+
class BadRequestError(APIError):
|
|
21
|
+
"""Raised when the API returns a 400 Bad Request error."""
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
class UnauthorizedError(APIError):
|
|
25
|
+
"""Raised when the API returns a 401 Unauthorized error."""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
class ForbiddenError(APIError):
|
|
29
|
+
"""Raised when the API returns a 403 Forbidden error."""
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
class NotFoundError(APIError):
|
|
33
|
+
"""Raised when the API returns a 404 Not Found error."""
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
class RateLimitError(APIError):
|
|
37
|
+
"""Raised when the API returns a 429 Too Many Requests error."""
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
class DeviceUnreachableError(ControlIDError):
|
|
41
|
+
"""Raised when the device is unreachable (e.g. connection timeout or dns failure)."""
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
class ObjectError(ControlIDError):
|
|
45
|
+
"""Raised when an object operation fails."""
|
|
46
|
+
pass
|
|
47
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: controlid-sdk
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: A production-ready asynchronous Python SDK for ControlID access control devices, supporting biometrics, networking, and complex time schedules.
|
|
5
5
|
Author-email: Tulio Amancio <root@tsuriu.com.br>
|
|
6
6
|
License: MIT
|
|
@@ -20,6 +20,9 @@ Requires-Python: >=3.9
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: httpx>=0.24.0
|
|
22
22
|
Requires-Dist: pydantic>=2.0.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
23
26
|
|
|
24
27
|
# ControlID Python SDK (Async)
|
|
25
28
|
|
|
@@ -192,6 +195,16 @@ await client.add_time_spans([
|
|
|
192
195
|
|
|
193
196
|
### 🧩 Generic Object API
|
|
194
197
|
|
|
198
|
+
## Firmware Compatibility Matrix
|
|
199
|
+
|
|
200
|
+
Since ControlID access control terminals run varying firmware versions, some API fields and tables may not be supported on all devices:
|
|
201
|
+
|
|
202
|
+
| Feature / Model | iDFace | iDAccess / iDFlex | iDBlock / Turnstiles | Notes |
|
|
203
|
+
| --- | --- | --- | --- | --- |
|
|
204
|
+
| **Card.type** | ⚠️ Supported only on newer firmware | ⚠️ Supported only on newer firmware | N/A | Older firmwares lack the `type` column in the `cards` table. Exclude it by leaving `Card.type = None`. |
|
|
205
|
+
| **Custom Database Fields** | ✅ Fully Supported | ⚠️ Depends on firmware version | N/A | Add custom fields (e.g. `cpf` to `c_users`) via `client.add_custom_field()`. |
|
|
206
|
+
| **Facial Templates** | ✅ Fully Supported | N/A | N/A | Enrollment and image upload functions require a device camera sensor. |
|
|
207
|
+
|
|
195
208
|
## Directory Structure
|
|
196
209
|
- `src/controlid/client.py`: Core asynchronous logic and endpoints.
|
|
197
210
|
- `src/controlid/models.py`: Pydantic V2 definitions.
|
|
@@ -9,4 +9,6 @@ src/controlid_sdk.egg-info/PKG-INFO
|
|
|
9
9
|
src/controlid_sdk.egg-info/SOURCES.txt
|
|
10
10
|
src/controlid_sdk.egg-info/dependency_links.txt
|
|
11
11
|
src/controlid_sdk.egg-info/requires.txt
|
|
12
|
-
src/controlid_sdk.egg-info/top_level.txt
|
|
12
|
+
src/controlid_sdk.egg-info/top_level.txt
|
|
13
|
+
tests/test_client.py
|
|
14
|
+
tests/test_models.py
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from unittest.mock import MagicMock, AsyncMock, patch
|
|
3
|
+
import httpx
|
|
4
|
+
from controlid import ControlIDClient
|
|
5
|
+
from controlid.exceptions import (
|
|
6
|
+
AuthenticationError,
|
|
7
|
+
BadRequestError,
|
|
8
|
+
UnauthorizedError,
|
|
9
|
+
ForbiddenError,
|
|
10
|
+
NotFoundError,
|
|
11
|
+
RateLimitError,
|
|
12
|
+
DeviceUnreachableError,
|
|
13
|
+
APIError,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_client_login_success():
|
|
18
|
+
client = ControlIDClient(host="https://192.168.0.100", user="admin", password="password")
|
|
19
|
+
|
|
20
|
+
mock_response = MagicMock(spec=httpx.Response)
|
|
21
|
+
mock_response.status_code = 200
|
|
22
|
+
mock_response.json = MagicMock(return_value={"session": "test-session-token"})
|
|
23
|
+
mock_response.raise_for_status = MagicMock()
|
|
24
|
+
|
|
25
|
+
with patch("httpx.AsyncClient.post", new_callable=AsyncMock, return_value=mock_response) as mock_post:
|
|
26
|
+
session = await client.login()
|
|
27
|
+
assert session == "test-session-token"
|
|
28
|
+
assert client.session == "test-session-token"
|
|
29
|
+
mock_post.assert_called_once()
|
|
30
|
+
|
|
31
|
+
@pytest.mark.asyncio
|
|
32
|
+
async def test_client_login_failure():
|
|
33
|
+
client = ControlIDClient(host="https://192.168.0.100", user="admin", password="password")
|
|
34
|
+
|
|
35
|
+
mock_response = MagicMock(spec=httpx.Response)
|
|
36
|
+
mock_response.status_code = 401
|
|
37
|
+
mock_response.json = MagicMock(return_value={"error": "Invalid credentials"})
|
|
38
|
+
mock_response.raise_for_status = MagicMock()
|
|
39
|
+
|
|
40
|
+
with patch("httpx.AsyncClient.post", new_callable=AsyncMock, return_value=mock_response):
|
|
41
|
+
with pytest.raises(AuthenticationError):
|
|
42
|
+
await client.login()
|
|
43
|
+
|
|
44
|
+
@pytest.mark.asyncio
|
|
45
|
+
async def test_client_request_injects_session():
|
|
46
|
+
client = ControlIDClient(host="https://192.168.0.100", user="admin", password="password")
|
|
47
|
+
client.session = "active-session"
|
|
48
|
+
|
|
49
|
+
mock_response = MagicMock(spec=httpx.Response)
|
|
50
|
+
mock_response.status_code = 200
|
|
51
|
+
mock_response.json = MagicMock(return_value={"status": "success"})
|
|
52
|
+
mock_response.raise_for_status = MagicMock()
|
|
53
|
+
|
|
54
|
+
await client._ensure_client()
|
|
55
|
+
|
|
56
|
+
with patch.object(client._client, "post", new_callable=AsyncMock, return_value=mock_response) as mock_post:
|
|
57
|
+
res = await client.request("/some-endpoint", {"param": "val"})
|
|
58
|
+
assert res == {"status": "success"}
|
|
59
|
+
called_url = mock_post.call_args[0][0]
|
|
60
|
+
assert "session=active-session" in called_url
|
|
61
|
+
|
|
62
|
+
@pytest.mark.asyncio
|
|
63
|
+
async def test_client_request_handles_status_errors():
|
|
64
|
+
client = ControlIDClient(host="https://192.168.0.100")
|
|
65
|
+
client.session = "active-session"
|
|
66
|
+
await client._ensure_client()
|
|
67
|
+
|
|
68
|
+
error_cases = [
|
|
69
|
+
(400, BadRequestError),
|
|
70
|
+
(401, UnauthorizedError),
|
|
71
|
+
(403, ForbiddenError),
|
|
72
|
+
(404, NotFoundError),
|
|
73
|
+
(429, RateLimitError),
|
|
74
|
+
(500, APIError),
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
for code, exc_class in error_cases:
|
|
78
|
+
mock_response = httpx.Response(status_code=code, text=f"Error {code}")
|
|
79
|
+
|
|
80
|
+
if code == 401:
|
|
81
|
+
with patch.object(client, "login", new_callable=AsyncMock, return_value="new-token"):
|
|
82
|
+
with patch.object(client._client, "post", new_callable=AsyncMock, side_effect=httpx.HTTPStatusError("Err", request=None, response=mock_response)):
|
|
83
|
+
with pytest.raises(exc_class):
|
|
84
|
+
await client.request("/some-endpoint")
|
|
85
|
+
else:
|
|
86
|
+
with patch.object(client._client, "post", new_callable=AsyncMock, side_effect=httpx.HTTPStatusError("Err", request=None, response=mock_response)):
|
|
87
|
+
with pytest.raises(exc_class):
|
|
88
|
+
await client.request("/some-endpoint")
|
|
89
|
+
|
|
90
|
+
@pytest.mark.asyncio
|
|
91
|
+
async def test_client_request_device_unreachable():
|
|
92
|
+
client = ControlIDClient(host="https://192.168.0.100")
|
|
93
|
+
client.session = "active-session"
|
|
94
|
+
await client._ensure_client()
|
|
95
|
+
|
|
96
|
+
with patch.object(client._client, "post", new_callable=AsyncMock, side_effect=httpx.ConnectError("Connection refused")):
|
|
97
|
+
with pytest.raises(DeviceUnreachableError):
|
|
98
|
+
await client.request("/some-endpoint")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from controlid.models import User, Card, TimeZone, TimeSpan
|
|
2
|
+
|
|
3
|
+
def test_user_model():
|
|
4
|
+
user = User(id=1, name="John Doe", registration="12345")
|
|
5
|
+
assert user.id == 1
|
|
6
|
+
assert user.name == "John Doe"
|
|
7
|
+
assert user.registration == "12345"
|
|
8
|
+
assert user.password == ""
|
|
9
|
+
|
|
10
|
+
def test_card_model():
|
|
11
|
+
card1 = Card(id=10, value=123456, user_id=1, type=0)
|
|
12
|
+
assert card1.id == 10
|
|
13
|
+
assert card1.value == 123456
|
|
14
|
+
assert card1.user_id == 1
|
|
15
|
+
assert card1.type == 0
|
|
16
|
+
|
|
17
|
+
# Exclude_none test
|
|
18
|
+
card2 = Card(value=654321, user_id=2)
|
|
19
|
+
assert card2.type is None
|
|
20
|
+
dumped = card2.model_dump(exclude_none=True)
|
|
21
|
+
assert "type" not in dumped
|
|
22
|
+
|
|
23
|
+
def test_timezone_and_timespan():
|
|
24
|
+
tz = TimeZone(id=1, name="Standard")
|
|
25
|
+
assert tz.name == "Standard"
|
|
26
|
+
|
|
27
|
+
span = TimeSpan(time_zone_id=1, start=28800, end=64800, mon=1, tue=1)
|
|
28
|
+
assert span.start == 28800
|
|
29
|
+
assert span.mon == 1
|
|
30
|
+
assert span.sun == 0
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
class ControlIDError(Exception):
|
|
2
|
-
"""Base exception for ControlID SDK."""
|
|
3
|
-
pass
|
|
4
|
-
|
|
5
|
-
class AuthenticationError(ControlIDError):
|
|
6
|
-
"""Raised when authentication fails."""
|
|
7
|
-
pass
|
|
8
|
-
|
|
9
|
-
class SessionError(ControlIDError):
|
|
10
|
-
"""Raised when there is an issue with the session."""
|
|
11
|
-
pass
|
|
12
|
-
|
|
13
|
-
class APIError(ControlIDError):
|
|
14
|
-
"""Raised when the API returns an error response."""
|
|
15
|
-
def __init__(self, message, status_code=None, response=None):
|
|
16
|
-
super().__init__(message)
|
|
17
|
-
self.status_code = status_code
|
|
18
|
-
self.response = response
|
|
19
|
-
|
|
20
|
-
class ObjectError(ControlIDError):
|
|
21
|
-
"""Raised when an object operation fails."""
|
|
22
|
-
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|