csu 2.6.5__tar.gz → 2.6.7__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.
- {csu-2.6.5 → csu-2.6.7}/.bumpversion.cfg +1 -1
- {csu-2.6.5 → csu-2.6.7}/.cookiecutterrc +1 -1
- {csu-2.6.5 → csu-2.6.7}/PKG-INFO +3 -3
- {csu-2.6.5 → csu-2.6.7}/README.rst +2 -2
- {csu-2.6.5 → csu-2.6.7}/pyproject.toml +1 -1
- {csu-2.6.5 → csu-2.6.7}/src/csu/__init__.py +1 -1
- {csu-2.6.5 → csu-2.6.7}/src/csu/exceptions.py +37 -3
- {csu-2.6.5 → csu-2.6.7}/src/csu/service.py +3 -6
- {csu-2.6.5 → csu-2.6.7}/src/csu/test_service.py +0 -9
- {csu-2.6.5 → csu-2.6.7}/src/csu.egg-info/PKG-INFO +3 -3
- {csu-2.6.5 → csu-2.6.7}/src/csu.egg-info/SOURCES.txt +1 -1
- {csu-2.6.5/src/csu → csu-2.6.7/tests}/test_exceptions.py +44 -20
- {csu-2.6.5 → csu-2.6.7}/tests/test_service.py +64 -52
- {csu-2.6.5 → csu-2.6.7}/tests/test_service_auth.py +12 -12
- csu-2.6.7/tests/test_views.py +107 -0
- csu-2.6.5/tests/test_views.py +0 -90
- {csu-2.6.5 → csu-2.6.7}/.coveragerc +0 -0
- {csu-2.6.5 → csu-2.6.7}/.editorconfig +0 -0
- {csu-2.6.5 → csu-2.6.7}/.github/workflows/github-actions.yml +0 -0
- {csu-2.6.5 → csu-2.6.7}/.pre-commit-config.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/.tombi.toml +0 -0
- {csu-2.6.5 → csu-2.6.7}/AUTHORS.rst +0 -0
- {csu-2.6.5 → csu-2.6.7}/CHANGELOG.rst +0 -0
- {csu-2.6.5 → csu-2.6.7}/CONTRIBUTING.rst +0 -0
- {csu-2.6.5 → csu-2.6.7}/LICENSE +0 -0
- {csu-2.6.5 → csu-2.6.7}/MANIFEST.in +0 -0
- {csu-2.6.5 → csu-2.6.7}/ci/bootstrap.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/ci/requirements.txt +0 -0
- {csu-2.6.5 → csu-2.6.7}/ci/templates/.github/workflows/github-actions.yml +0 -0
- {csu-2.6.5 → csu-2.6.7}/pytest.ini +0 -0
- {csu-2.6.5 → csu-2.6.7}/setup.cfg +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/admin.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/conf.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/consts.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/__init__.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/auth.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/fields.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/forms.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/perms.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/phonenumber.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/serializers.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/test_auth.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/test_fields.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/test_forms.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/test_phonenumber.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/test_serializers.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/drf/views.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/enums.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/env.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/export.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/fixups.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/forms/__init__.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/forms/crispy.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/forms/fields.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/gettext.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/gettext_lazy.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/locale/ro/LC_MESSAGES/django.mo +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/locale/ro/LC_MESSAGES/django.po +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/logging.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/management.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/models.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/query.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/routers.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/templates/api_exception.html +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/templates/forms/widgets/opaquewidget.html +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/test_consts.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/test_env.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/test_management.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/test_timezones.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/test_utils.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/test_xml.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/timezones.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/utils.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/views.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/__init__.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/admin.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/asgi.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/engine.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/enums.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/job.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/models.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/worker/registry.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/wsgi.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu/xml.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu.egg-info/dependency_links.txt +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu.egg-info/requires.txt +0 -0
- {csu-2.6.5 → csu-2.6.7}/src/csu.egg-info/top_level.txt +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service/test_custom_context.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service/test_custom_context_0_retries.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service/test_decoding.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service/test_error.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service/test_logging.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service/test_redirects.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service_auth/test_async.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service_auth/test_async_auth.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service_auth/test_sync.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/cassettes/test_service_auth/test_sync_auth.yaml +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/conftest.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/exampleworker.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/test_exampleworker.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/test_logging.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/test_models.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/test_worker.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/testproject/__init__.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/testproject/fixtures/testuser.json +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/testproject/models.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/testproject/settings.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tests/testproject/urls.py +0 -0
- {csu-2.6.5 → csu-2.6.7}/tox.ini +0 -0
{csu-2.6.5 → csu-2.6.7}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: csu
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.7
|
|
4
4
|
Summary: Clean Slate Utils - bunch of utility code, mostly Django/DRF specific.
|
|
5
5
|
Author-email: Ionel Cristian Mărieș <contact@ionelmc.ro>
|
|
6
6
|
License-Expression: BSD-2-Clause
|
|
@@ -69,9 +69,9 @@ Overview
|
|
|
69
69
|
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/csu.svg
|
|
70
70
|
:alt: Supported implementations
|
|
71
71
|
:target: https://pypi.org/project/csu
|
|
72
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.
|
|
72
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.7.svg
|
|
73
73
|
:alt: Commits since latest release
|
|
74
|
-
:target: https://github.com/ionelmc/python-csu/compare/v2.6.
|
|
74
|
+
:target: https://github.com/ionelmc/python-csu/compare/v2.6.7...main
|
|
75
75
|
.. |scrutinizer| image:: https://img.shields.io/scrutinizer/quality/g/ionelmc/python-csu/main.svg
|
|
76
76
|
:alt: Scrutinizer Status
|
|
77
77
|
:target: https://scrutinizer-ci.com/g/ionelmc/python-csu/
|
|
@@ -34,9 +34,9 @@ Overview
|
|
|
34
34
|
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/csu.svg
|
|
35
35
|
:alt: Supported implementations
|
|
36
36
|
:target: https://pypi.org/project/csu
|
|
37
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.
|
|
37
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.7.svg
|
|
38
38
|
:alt: Commits since latest release
|
|
39
|
-
:target: https://github.com/ionelmc/python-csu/compare/v2.6.
|
|
39
|
+
:target: https://github.com/ionelmc/python-csu/compare/v2.6.7...main
|
|
40
40
|
.. |scrutinizer| image:: https://img.shields.io/scrutinizer/quality/g/ionelmc/python-csu/main.svg
|
|
41
41
|
:alt: Scrutinizer Status
|
|
42
42
|
:target: https://scrutinizer-ci.com/g/ionelmc/python-csu/
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import math
|
|
1
2
|
from collections import Counter
|
|
2
3
|
from collections.abc import Iterable
|
|
4
|
+
from datetime import datetime
|
|
3
5
|
from importlib.util import find_spec
|
|
6
|
+
from math import ceil
|
|
4
7
|
from os import urandom
|
|
5
8
|
from typing import TYPE_CHECKING
|
|
6
9
|
|
|
@@ -20,11 +23,42 @@ else:
|
|
|
20
23
|
|
|
21
24
|
HTTP_503_SERVICE_UNAVAILABLE = 503
|
|
22
25
|
|
|
26
|
+
event_id_number_table = dict(enumerate("0123456789ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"))
|
|
27
|
+
event_id_number_table_reversed = {v: k for k, v in event_id_number_table.items()}
|
|
28
|
+
event_id_number_table_len = len(event_id_number_table)
|
|
29
|
+
event_id_number_table_digit_ratio = 8 * math.log(2) / math.log(event_id_number_table_len)
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
|
|
32
|
+
def get_event_id_datetime(event_id: str) -> datetime:
|
|
33
|
+
"""
|
|
34
|
+
Returns naive datetime.
|
|
35
|
+
"""
|
|
36
|
+
return datetime( # noqa: DTZ001
|
|
37
|
+
year=event_id_number_table_reversed[event_id[0]],
|
|
38
|
+
month=event_id_number_table_reversed[event_id[1]],
|
|
39
|
+
day=event_id_number_table_reversed[event_id[2]],
|
|
40
|
+
hour=event_id_number_table_reversed[event_id[-3]],
|
|
41
|
+
minute=event_id_number_table_reversed[event_id[-2]],
|
|
42
|
+
second=event_id_number_table_reversed[event_id[-1]],
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def get_event_id(bytes=3):
|
|
25
47
|
dt = now()
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
year = event_id_number_table[dt.year % 100]
|
|
49
|
+
month = event_id_number_table[dt.month]
|
|
50
|
+
day = event_id_number_table[dt.day]
|
|
51
|
+
hour = event_id_number_table[dt.hour]
|
|
52
|
+
minute = event_id_number_table[dt.minute]
|
|
53
|
+
second = event_id_number_table[dt.second]
|
|
54
|
+
tag_num = int.from_bytes(urandom(bytes))
|
|
55
|
+
tag_parts = []
|
|
56
|
+
while tag_num > 0:
|
|
57
|
+
tag_num, rem = divmod(tag_num, event_id_number_table_len)
|
|
58
|
+
tag_parts.append(event_id_number_table[rem])
|
|
59
|
+
tag = "".join(reversed(tag_parts))
|
|
60
|
+
tag_pad = ceil(bytes * event_id_number_table_digit_ratio)
|
|
61
|
+
return dt.strftime(f"{year}{month}{day}{tag:0>{tag_pad}}{hour}{minute}{second}")
|
|
28
62
|
|
|
29
63
|
|
|
30
64
|
class TaggedError(Exception):
|
|
@@ -113,13 +113,10 @@ class HTTPServiceContext[RTYPE = HTTPServiceResponse]:
|
|
|
113
113
|
self.proxy = proxy
|
|
114
114
|
self.logger = service.logger
|
|
115
115
|
self.retries = service.retries
|
|
116
|
-
if event_id:
|
|
117
|
-
if ":" not in event_id:
|
|
118
|
-
raise ValueError("Expected a 'date:random:time' structured event id.")
|
|
119
|
-
else:
|
|
116
|
+
if event_id is None:
|
|
120
117
|
event_id = get_event_id()
|
|
121
|
-
|
|
122
|
-
self.
|
|
118
|
+
self.event_id = event_id
|
|
119
|
+
self.short_id = event_id[3:-3]
|
|
123
120
|
|
|
124
121
|
def __enter__(self) -> Self:
|
|
125
122
|
self.client.__enter__()
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
from typing import reveal_type
|
|
2
2
|
|
|
3
|
-
import time_machine
|
|
4
3
|
from niquests import PreparedRequest
|
|
5
4
|
from niquests import Response
|
|
6
5
|
|
|
7
|
-
from . import exceptions
|
|
8
|
-
from .exceptions import get_event_id
|
|
9
6
|
from .service import AsyncHTTPService
|
|
10
7
|
from .service import AsyncHTTPServiceContext
|
|
11
8
|
from .service import HTTPService
|
|
12
9
|
from .service import HTTPServiceContext
|
|
13
10
|
|
|
14
11
|
|
|
15
|
-
def test_get_accident_id(monkeypatch):
|
|
16
|
-
monkeypatch.setattr(exceptions, "urandom", lambda len: bytes(range(len)))
|
|
17
|
-
with time_machine.travel(1674777700.5816755):
|
|
18
|
-
assert get_event_id() == "230127:00010203:020140.58"
|
|
19
|
-
|
|
20
|
-
|
|
21
12
|
class CustomResponse:
|
|
22
13
|
def bar(self, x: float) -> float: ...
|
|
23
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: csu
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.7
|
|
4
4
|
Summary: Clean Slate Utils - bunch of utility code, mostly Django/DRF specific.
|
|
5
5
|
Author-email: Ionel Cristian Mărieș <contact@ionelmc.ro>
|
|
6
6
|
License-Expression: BSD-2-Clause
|
|
@@ -69,9 +69,9 @@ Overview
|
|
|
69
69
|
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/csu.svg
|
|
70
70
|
:alt: Supported implementations
|
|
71
71
|
:target: https://pypi.org/project/csu
|
|
72
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.
|
|
72
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.7.svg
|
|
73
73
|
:alt: Commits since latest release
|
|
74
|
-
:target: https://github.com/ionelmc/python-csu/compare/v2.6.
|
|
74
|
+
:target: https://github.com/ionelmc/python-csu/compare/v2.6.7...main
|
|
75
75
|
.. |scrutinizer| image:: https://img.shields.io/scrutinizer/quality/g/ionelmc/python-csu/main.svg
|
|
76
76
|
:alt: Scrutinizer Status
|
|
77
77
|
:target: https://scrutinizer-ci.com/g/ionelmc/python-csu/
|
|
@@ -36,7 +36,6 @@ src/csu/routers.py
|
|
|
36
36
|
src/csu/service.py
|
|
37
37
|
src/csu/test_consts.py
|
|
38
38
|
src/csu/test_env.py
|
|
39
|
-
src/csu/test_exceptions.py
|
|
40
39
|
src/csu/test_management.py
|
|
41
40
|
src/csu/test_service.py
|
|
42
41
|
src/csu/test_timezones.py
|
|
@@ -83,6 +82,7 @@ src/csu/worker/registry.py
|
|
|
83
82
|
tests/conftest.py
|
|
84
83
|
tests/exampleworker.py
|
|
85
84
|
tests/test_exampleworker.py
|
|
85
|
+
tests/test_exceptions.py
|
|
86
86
|
tests/test_logging.py
|
|
87
87
|
tests/test_models.py
|
|
88
88
|
tests/test_service.py
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
# ruff: noqa: DTZ001
|
|
1
2
|
import traceback
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
from zoneinfo import ZoneInfo
|
|
4
5
|
|
|
5
6
|
import time_machine
|
|
7
|
+
from inline_snapshot import snapshot
|
|
6
8
|
|
|
7
|
-
from
|
|
8
|
-
from .exceptions import APIServiceError
|
|
9
|
-
from .exceptions import ExhaustedRetriesError
|
|
10
|
-
from .exceptions import OpenServiceError
|
|
11
|
-
from .exceptions import get_event_id
|
|
9
|
+
from csu import exceptions
|
|
10
|
+
from csu.exceptions import APIServiceError
|
|
11
|
+
from csu.exceptions import ExhaustedRetriesError
|
|
12
|
+
from csu.exceptions import OpenServiceError
|
|
13
|
+
from csu.exceptions import get_event_id
|
|
14
|
+
from csu.exceptions import get_event_id_datetime
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
class OpenFooError(OpenServiceError):
|
|
@@ -25,11 +28,13 @@ def test_open_service_error(monkeypatch):
|
|
|
25
28
|
monkeypatch.setattr(exceptions, "get_event_id", lambda: 234)
|
|
26
29
|
api_exc = exc.as_api_service_error()
|
|
27
30
|
assert isinstance(api_exc, APIServiceError)
|
|
28
|
-
assert api_exc.detail ==
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
assert api_exc.detail == snapshot(
|
|
32
|
+
{
|
|
33
|
+
"accident_id": 234,
|
|
34
|
+
"code": "unknown",
|
|
35
|
+
"detail": "Unknown error",
|
|
36
|
+
}
|
|
37
|
+
)
|
|
33
38
|
|
|
34
39
|
|
|
35
40
|
def test_open_service_error_subclass(monkeypatch):
|
|
@@ -38,18 +43,22 @@ def test_open_service_error_subclass(monkeypatch):
|
|
|
38
43
|
monkeypatch.setattr(exceptions, "get_event_id", lambda: 123)
|
|
39
44
|
api_exc = exc.as_api_service_error()
|
|
40
45
|
assert isinstance(api_exc, APIServiceError)
|
|
41
|
-
assert api_exc.detail ==
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
assert api_exc.detail == snapshot(
|
|
47
|
+
{
|
|
48
|
+
"accident_id": 123,
|
|
49
|
+
"code": "unknown",
|
|
50
|
+
"detail": "proper foo",
|
|
51
|
+
}
|
|
52
|
+
)
|
|
46
53
|
|
|
47
54
|
|
|
48
55
|
def test_add_note():
|
|
49
56
|
exc = OpenServiceError("My message!", details=[1, 2, Exception(123)], event_id=None)
|
|
50
|
-
assert exc.__notes__ ==
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
assert exc.__notes__ == snapshot(
|
|
58
|
+
[
|
|
59
|
+
"(1, 2, Exception(123))",
|
|
60
|
+
]
|
|
61
|
+
)
|
|
53
62
|
|
|
54
63
|
exc = OpenServiceError("My message!", details=[], event_id=None)
|
|
55
64
|
assert getattr(exc, "__notes__", []) == []
|
|
@@ -83,5 +92,20 @@ def test_exhausted_retries_error():
|
|
|
83
92
|
|
|
84
93
|
def test_get_event_id(monkeypatch):
|
|
85
94
|
monkeypatch.setattr(exceptions, "urandom", lambda _: b"ZZZ")
|
|
86
|
-
with time_machine.travel(datetime(2024, 12,
|
|
87
|
-
assert get_event_id() == "
|
|
95
|
+
with time_machine.travel(datetime(2024, 12, 31, 12, 59, 59, microsecond=999999, tzinfo=ZoneInfo("Europe/Bucharest"))):
|
|
96
|
+
assert get_event_id() == snapshot("PCW0SPpVCzz")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_get_accident_id(monkeypatch):
|
|
100
|
+
monkeypatch.setattr(exceptions, "urandom", lambda len: bytes(range(len)))
|
|
101
|
+
with time_machine.travel(1674777700.5816755):
|
|
102
|
+
assert get_event_id() == snapshot("N1S0004I21f")
|
|
103
|
+
|
|
104
|
+
assert get_event_id_datetime("N1R0007620140") == snapshot(datetime(23, 1, 26, hour=1, minute=4))
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_get_event_id_datetime(monkeypatch):
|
|
108
|
+
|
|
109
|
+
assert get_event_id_datetime("N1R0007620140") == snapshot(datetime(23, 1, 26, hour=1, minute=4))
|
|
110
|
+
assert get_event_id_datetime("ZAT0007620AZZ") == snapshot(datetime(34, 10, 28, hour=10, minute=34, second=34))
|
|
111
|
+
assert get_event_id_datetime("TAT0007620Czz") == snapshot(datetime(28, 10, 28, hour=12, minute=59, second=59))
|