orionis 0.288.0__py3-none-any.whl → 0.289.0__py3-none-any.whl
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.
- orionis/metadata/framework.py +1 -1
- orionis/metadata/package.py +17 -46
- {orionis-0.288.0.dist-info → orionis-0.289.0.dist-info}/METADATA +1 -1
- {orionis-0.288.0.dist-info → orionis-0.289.0.dist-info}/RECORD +13 -10
- tests/metadata/__init__.py +0 -0
- tests/metadata/test_metadata_framework.py +101 -0
- tests/metadata/test_metadata_package.py +69 -0
- tests/services/parsers/mocks/mock_custom_error.py +14 -4
- tests/services/parsers/{test_exception_parser.py → test_services_parser_exceptions.py} +21 -2
- {orionis-0.288.0.dist-info → orionis-0.289.0.dist-info}/WHEEL +0 -0
- {orionis-0.288.0.dist-info → orionis-0.289.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.288.0.dist-info → orionis-0.289.0.dist-info}/top_level.txt +0 -0
- {orionis-0.288.0.dist-info → orionis-0.289.0.dist-info}/zip-safe +0 -0
orionis/metadata/framework.py
CHANGED
orionis/metadata/package.py
CHANGED
@@ -7,38 +7,9 @@ class PypiPackageApi:
|
|
7
7
|
This class initializes by retrieving package information from the PyPI JSON API for the 'orionis' package.
|
8
8
|
It exposes various methods to access metadata such as the package name, version, author, description, license,
|
9
9
|
classifiers, required Python version, keywords, and project URLs.
|
10
|
-
Attributes:
|
11
|
-
_baseUrl (str): The URL to the PyPI JSON API for the Orionis package.
|
12
|
-
_info (dict): A dictionary containing the package metadata fetched from PyPI.
|
13
|
-
Methods:
|
14
|
-
getAllData():
|
15
|
-
Fetches and updates the internal information dictionary with the latest data from PyPI.
|
16
|
-
getName():
|
17
|
-
Returns the CLI name by appending '-cli' to the package name.
|
18
|
-
getVersion():
|
19
|
-
Returns the version string of the framework.
|
20
|
-
getAuthor():
|
21
|
-
Returns the author's name.
|
22
|
-
getAuthorEmail():
|
23
|
-
Returns the author's email address.
|
24
|
-
getDescription():
|
25
|
-
Returns the summary description of the framework.
|
26
|
-
getUrl():
|
27
|
-
Returns the homepage URL of the project.
|
28
|
-
getLongDescription():
|
29
|
-
getDescriptionContentType():
|
30
|
-
Returns the content type of the long description.
|
31
|
-
getLicense():
|
32
|
-
Returns the license type, defaulting to "MIT" if not specified.
|
33
|
-
getClassifiers():
|
34
|
-
Returns a list of PyPI classifiers for the package.
|
35
|
-
getPythonVersion():
|
36
|
-
Returns the required Python version specification.
|
37
|
-
getKeywords():
|
38
|
-
Returns a list of keywords associated with the package.
|
39
10
|
"""
|
40
11
|
|
41
|
-
def __init__(self):
|
12
|
+
def __init__(self) -> None:
|
42
13
|
"""
|
43
14
|
Initializes the class by setting the base URL for the Orionis PyPI package,
|
44
15
|
initializing the information dictionary, and retrieving all package data.
|
@@ -47,7 +18,7 @@ class PypiPackageApi:
|
|
47
18
|
self._info = {}
|
48
19
|
self.getAllData()
|
49
20
|
|
50
|
-
def getAllData(self):
|
21
|
+
def getAllData(self) -> dict:
|
51
22
|
"""
|
52
23
|
Fetches all data from the base URL and updates the internal info attribute.
|
53
24
|
|
@@ -76,16 +47,16 @@ class PypiPackageApi:
|
|
76
47
|
f"Invalid response structure from PyPI: {ve}"
|
77
48
|
)
|
78
49
|
|
79
|
-
def getName(self):
|
50
|
+
def getName(self) -> str:
|
80
51
|
"""
|
81
|
-
Returns the
|
52
|
+
Returns the package name from the value of the 'name' key in the _info dictionary.
|
82
53
|
|
83
54
|
Returns:
|
84
|
-
str: The
|
55
|
+
str: The package name.
|
85
56
|
"""
|
86
|
-
return
|
57
|
+
return self._info['name']
|
87
58
|
|
88
|
-
def getVersion(self):
|
59
|
+
def getVersion(self) -> str:
|
89
60
|
"""
|
90
61
|
Returns the version information of the framework.
|
91
62
|
|
@@ -94,7 +65,7 @@ class PypiPackageApi:
|
|
94
65
|
"""
|
95
66
|
return self._info['version']
|
96
67
|
|
97
|
-
def getAuthor(self):
|
68
|
+
def getAuthor(self) -> str:
|
98
69
|
"""
|
99
70
|
Returns the author of the framework.
|
100
71
|
|
@@ -103,7 +74,7 @@ class PypiPackageApi:
|
|
103
74
|
"""
|
104
75
|
return self._info['author']
|
105
76
|
|
106
|
-
def getAuthorEmail(self):
|
77
|
+
def getAuthorEmail(self) -> str:
|
107
78
|
"""
|
108
79
|
Retrieve the author's email address from the internal information dictionary.
|
109
80
|
|
@@ -112,7 +83,7 @@ class PypiPackageApi:
|
|
112
83
|
"""
|
113
84
|
return self._info['author_email']
|
114
85
|
|
115
|
-
def getDescription(self):
|
86
|
+
def getDescription(self) -> str:
|
116
87
|
"""
|
117
88
|
Returns the summary description from the internal information dictionary.
|
118
89
|
|
@@ -121,7 +92,7 @@ class PypiPackageApi:
|
|
121
92
|
"""
|
122
93
|
return self._info['summary']
|
123
94
|
|
124
|
-
def getUrl(self):
|
95
|
+
def getUrl(self) -> str:
|
125
96
|
"""
|
126
97
|
Retrieves the homepage URL from the project's information.
|
127
98
|
|
@@ -130,7 +101,7 @@ class PypiPackageApi:
|
|
130
101
|
"""
|
131
102
|
return self._info['project_urls']['Homepage']
|
132
103
|
|
133
|
-
def getLongDescription(self):
|
104
|
+
def getLongDescription(self) -> str:
|
134
105
|
"""
|
135
106
|
Returns the long description of the framework.
|
136
107
|
|
@@ -139,7 +110,7 @@ class PypiPackageApi:
|
|
139
110
|
"""
|
140
111
|
return self._info['description']
|
141
112
|
|
142
|
-
def getDescriptionContentType(self):
|
113
|
+
def getDescriptionContentType(self) -> str:
|
143
114
|
"""
|
144
115
|
Returns the content type of the description from the internal information dictionary.
|
145
116
|
|
@@ -148,7 +119,7 @@ class PypiPackageApi:
|
|
148
119
|
"""
|
149
120
|
return self._info['description_content_type']
|
150
121
|
|
151
|
-
def getLicense(self):
|
122
|
+
def getLicense(self) -> str:
|
152
123
|
"""
|
153
124
|
Returns the license type specified in the framework information.
|
154
125
|
|
@@ -159,7 +130,7 @@ class PypiPackageApi:
|
|
159
130
|
"""
|
160
131
|
return self._info['license'] or "MIT"
|
161
132
|
|
162
|
-
def getClassifiers(self):
|
133
|
+
def getClassifiers(self) -> list:
|
163
134
|
"""
|
164
135
|
Returns the list of classifiers from the internal _info dictionary.
|
165
136
|
|
@@ -168,7 +139,7 @@ class PypiPackageApi:
|
|
168
139
|
"""
|
169
140
|
return self._info['classifiers']
|
170
141
|
|
171
|
-
def getPythonVersion(self):
|
142
|
+
def getPythonVersion(self) -> str:
|
172
143
|
"""
|
173
144
|
Retrieves the required Python version for the framework.
|
174
145
|
|
@@ -177,7 +148,7 @@ class PypiPackageApi:
|
|
177
148
|
"""
|
178
149
|
return self._info['requires_python']
|
179
150
|
|
180
|
-
def getKeywords(self):
|
151
|
+
def getKeywords(self) -> list:
|
181
152
|
"""
|
182
153
|
Retrieve the list of keywords associated with the current object.
|
183
154
|
|
@@ -226,8 +226,8 @@ orionis/foundation/config/testing/entities/testing.py,sha256=m_i9jZlOXs_AzNKNNf0
|
|
226
226
|
orionis/foundation/config/testing/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
227
227
|
orionis/foundation/config/testing/enums/test_mode.py,sha256=IbFpauu7J-iSAfmC8jDbmTEYl8eZr-AexL-lyOh8_74,337
|
228
228
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
229
|
-
orionis/metadata/framework.py,sha256=
|
230
|
-
orionis/metadata/package.py,sha256=
|
229
|
+
orionis/metadata/framework.py,sha256=jGJvnj_7dnLfXIAVVVGam0pSWqJ-lOA_dsfHtD5mD6g,4960
|
230
|
+
orionis/metadata/package.py,sha256=tqLfBRo-w1j_GN4xvzUNFyweWYFS-qhSgAEc-AmCH1M,5452
|
231
231
|
orionis/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
232
232
|
orionis/patterns/singleton/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
233
233
|
orionis/patterns/singleton/meta_class.py,sha256=YN5mSSQeIX_Gh_TK5HD-ms6IYBTRsRcuzoUtpX-9kYY,2134
|
@@ -351,7 +351,7 @@ orionis/test/suites/contracts/test_suite.py,sha256=eluzYwkNBbKjxYStj_tHN_Fm3YDPp
|
|
351
351
|
orionis/test/suites/contracts/test_unit.py,sha256=l1LQllODyvcSByXMl1lGrUkoLsXbBHZZLWZI4A-mlQg,5881
|
352
352
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
353
353
|
orionis/test/view/index.html,sha256=U4XYO4hA-mAJCK1gcVRgIysmISK3g3Vgi2ntLofFAhE,6592
|
354
|
-
orionis-0.
|
354
|
+
orionis-0.289.0.dist-info/licenses/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
355
355
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
356
356
|
tests/example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
357
357
|
tests/example/test_example.py,sha256=byd_lI6tVDgGPEIrr7PLZbBu0UoZOymmdmyA_4u-QUw,601
|
@@ -408,6 +408,9 @@ tests/foundation/config/startup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
|
|
408
408
|
tests/foundation/config/startup/test_foundation_config_startup.py,sha256=xD5wuPAFsQMAuRACgK_O5wowPLZY-uftXNgxtFjnP7o,6776
|
409
409
|
tests/foundation/config/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
410
410
|
tests/foundation/config/testing/test_foundation_config_testing.py,sha256=AuR-h2974Hkdpo4iCkYOJyr8kydmDGN6G2wbVOYcqGM,8216
|
411
|
+
tests/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
412
|
+
tests/metadata/test_metadata_framework.py,sha256=V-GXnReHepHLGFvY9hQTYWrzVGgC-P7SinKHCmElXDA,3266
|
413
|
+
tests/metadata/test_metadata_package.py,sha256=_vz476d-6ZdMrfnczWaO2kGUzjNPwEQSlVAHz6xOwNM,1773
|
411
414
|
tests/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
412
415
|
tests/patterns/singleton/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
413
416
|
tests/patterns/singleton/test_patterns_singleton.py,sha256=DCvc-3nmsrM1xJr9WGeFZHyB-IVUVVGhfjvkly2E8rU,951
|
@@ -424,9 +427,9 @@ tests/services/inspection/dependencies/mocks/mock_user.py,sha256=RxATxe0-Vm4HfX5
|
|
424
427
|
tests/services/inspection/dependencies/mocks/mock_user_controller.py,sha256=P3sOUXVZ55auudwiNtvNCEQuTz0cgAZjvhicLZ4xaz4,1208
|
425
428
|
tests/services/inspection/dependencies/mocks/mock_users_permissions.py,sha256=oENXbS2qmQUudYSmnhB8fgHBqXZdbplplB-Y2nbx4hw,1388
|
426
429
|
tests/services/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
427
|
-
tests/services/parsers/
|
430
|
+
tests/services/parsers/test_services_parser_exceptions.py,sha256=fCi_nUsXSh80r7HzQibXbUuYMpqjBefsP-QPF76MLfM,2650
|
428
431
|
tests/services/parsers/mocks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
429
|
-
tests/services/parsers/mocks/mock_custom_error.py,sha256=
|
432
|
+
tests/services/parsers/mocks/mock_custom_error.py,sha256=LWgjeog2rpmfw6j7Bgzvfvmeby8uSBuB1B3d_DgRcFQ,752
|
430
433
|
tests/services/path/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
431
434
|
tests/services/path/test_services_resolver.py,sha256=ny6vyx_psF9iWXyMhqI95SJs84_dD1NIOXt0k1MfBQA,3902
|
432
435
|
tests/services/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -452,8 +455,8 @@ tests/support/inspection/fakes/fake_reflection_instance_with_abstract.py,sha256=
|
|
452
455
|
tests/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
453
456
|
tests/testing/test_testing_result.py,sha256=MrGK3ZimedL0b5Ydu69Dg8Iul017AzLTm7VPxpXlpfU,4315
|
454
457
|
tests/testing/test_testing_unit.py,sha256=A6QkiOkP7GPC1Szh_GqsrV7GxjWjK8cIwFez6YfrzmM,7683
|
455
|
-
orionis-0.
|
456
|
-
orionis-0.
|
457
|
-
orionis-0.
|
458
|
-
orionis-0.
|
459
|
-
orionis-0.
|
458
|
+
orionis-0.289.0.dist-info/METADATA,sha256=h7nzzgx-NOJZldvDJfW1X8_f5Ddp3k9Th-zxu7HWm_c,4772
|
459
|
+
orionis-0.289.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
460
|
+
orionis-0.289.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
461
|
+
orionis-0.289.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
462
|
+
orionis-0.289.0.dist-info/RECORD,,
|
File without changes
|
@@ -0,0 +1,101 @@
|
|
1
|
+
from orionis.metadata.framework import *
|
2
|
+
from orionis.test.cases.test_case import TestCase
|
3
|
+
|
4
|
+
class TestMetadataFramework(TestCase):
|
5
|
+
"""
|
6
|
+
Test cases for the metadata constants and utility functions in orionis.metadata.framework.
|
7
|
+
|
8
|
+
Notes
|
9
|
+
-----
|
10
|
+
This test suite validates the existence, type, and structure of metadata constants and utility
|
11
|
+
functions provided by the `orionis.metadata.framework` module.
|
12
|
+
"""
|
13
|
+
|
14
|
+
async def testConstantsExistAndAreStr(self):
|
15
|
+
"""
|
16
|
+
Test that all metadata constants exist and are of type `str`.
|
17
|
+
|
18
|
+
Raises
|
19
|
+
------
|
20
|
+
AssertionError
|
21
|
+
If any constant is not a string.
|
22
|
+
"""
|
23
|
+
for const in [
|
24
|
+
NAME, VERSION, AUTHOR, AUTHOR_EMAIL, DESCRIPTION,
|
25
|
+
SKELETON, FRAMEWORK, DOCS, API, PYTHON_REQUIRES
|
26
|
+
]:
|
27
|
+
assert isinstance(const, str)
|
28
|
+
|
29
|
+
async def testClassifiersStructure(self):
|
30
|
+
"""
|
31
|
+
Test that `CLASSIFIERS` is a list of tuples of strings.
|
32
|
+
|
33
|
+
Raises
|
34
|
+
------
|
35
|
+
AssertionError
|
36
|
+
If `CLASSIFIERS` is not a list of tuples of strings.
|
37
|
+
"""
|
38
|
+
assert isinstance(CLASSIFIERS, list)
|
39
|
+
for item in CLASSIFIERS:
|
40
|
+
assert isinstance(item, tuple)
|
41
|
+
assert all(isinstance(part, str) for part in item)
|
42
|
+
|
43
|
+
async def testGetClassifiers(self):
|
44
|
+
"""
|
45
|
+
Test that `get_classifiers` returns a list of classifier strings.
|
46
|
+
|
47
|
+
Raises
|
48
|
+
------
|
49
|
+
AssertionError
|
50
|
+
If the returned value is not a list of strings containing '::'.
|
51
|
+
"""
|
52
|
+
classifiers = get_classifiers()
|
53
|
+
assert isinstance(classifiers, list)
|
54
|
+
for c in classifiers:
|
55
|
+
assert isinstance(c, str)
|
56
|
+
assert " :: " in c or len(c.split(" :: ")) > 1
|
57
|
+
|
58
|
+
async def testKeywords(self):
|
59
|
+
"""
|
60
|
+
Test that `KEYWORDS` is a list of strings and contains specific keywords.
|
61
|
+
|
62
|
+
Raises
|
63
|
+
------
|
64
|
+
AssertionError
|
65
|
+
If `KEYWORDS` is not a list of strings or required keywords are missing.
|
66
|
+
"""
|
67
|
+
assert isinstance(KEYWORDS, list)
|
68
|
+
for kw in KEYWORDS:
|
69
|
+
assert isinstance(kw, str)
|
70
|
+
assert "orionis" in KEYWORDS
|
71
|
+
assert "framework" in KEYWORDS
|
72
|
+
|
73
|
+
async def testRequiresStructure(self):
|
74
|
+
"""
|
75
|
+
Test that `REQUIRES` is a list of 2-element tuples of strings.
|
76
|
+
|
77
|
+
Raises
|
78
|
+
------
|
79
|
+
AssertionError
|
80
|
+
If `REQUIRES` is not a list of 2-element tuples of strings.
|
81
|
+
"""
|
82
|
+
assert isinstance(REQUIRES, list)
|
83
|
+
for req in REQUIRES:
|
84
|
+
assert isinstance(req, tuple)
|
85
|
+
assert len(req) == 2
|
86
|
+
assert all(isinstance(part, str) for part in req)
|
87
|
+
|
88
|
+
async def testGetRequires(self):
|
89
|
+
"""
|
90
|
+
Test that `get_requires` returns a list of requirement strings.
|
91
|
+
|
92
|
+
Raises
|
93
|
+
------
|
94
|
+
AssertionError
|
95
|
+
If the returned value is not a list of strings containing '>='.
|
96
|
+
"""
|
97
|
+
requires = get_requires()
|
98
|
+
assert isinstance(requires, list)
|
99
|
+
for req in requires:
|
100
|
+
assert isinstance(req, str)
|
101
|
+
assert ">=" in req
|
@@ -0,0 +1,69 @@
|
|
1
|
+
from orionis.unittesting import TestCase
|
2
|
+
from orionis.metadata.package import PypiPackageApi
|
3
|
+
|
4
|
+
class TestPypiPackageApi(TestCase):
|
5
|
+
|
6
|
+
async def testGetName(self):
|
7
|
+
"""
|
8
|
+
Test getName method.
|
9
|
+
|
10
|
+
Tests that getName returns the correct package name.
|
11
|
+
|
12
|
+
Returns
|
13
|
+
-------
|
14
|
+
None
|
15
|
+
"""
|
16
|
+
api = PypiPackageApi()
|
17
|
+
self.assertEqual(api.getName(), "orionis")
|
18
|
+
|
19
|
+
async def testGetAuthor(self):
|
20
|
+
"""
|
21
|
+
Test getAuthor method.
|
22
|
+
|
23
|
+
Tests that getAuthor returns the correct author name.
|
24
|
+
|
25
|
+
Returns
|
26
|
+
-------
|
27
|
+
None
|
28
|
+
"""
|
29
|
+
api = PypiPackageApi()
|
30
|
+
self.assertEqual(api.getAuthor(), "Raul Mauricio Uñate Castro")
|
31
|
+
|
32
|
+
async def testGetAuthorEmail(self):
|
33
|
+
"""
|
34
|
+
Test getAuthorEmail method.
|
35
|
+
|
36
|
+
Tests that getAuthorEmail returns the correct author email.
|
37
|
+
|
38
|
+
Returns
|
39
|
+
-------
|
40
|
+
None
|
41
|
+
"""
|
42
|
+
api = PypiPackageApi()
|
43
|
+
self.assertEqual(api.getAuthorEmail(), "raulmauriciounate@gmail.com")
|
44
|
+
|
45
|
+
async def testGetDescription(self):
|
46
|
+
"""
|
47
|
+
Test getDescription method.
|
48
|
+
|
49
|
+
Tests that getDescription returns the correct description.
|
50
|
+
|
51
|
+
Returns
|
52
|
+
-------
|
53
|
+
None
|
54
|
+
"""
|
55
|
+
api = PypiPackageApi()
|
56
|
+
self.assertEqual(api.getDescription(), "Orionis Framework – Elegant, Fast, and Powerful.")
|
57
|
+
|
58
|
+
async def testGetPythonVersion(self):
|
59
|
+
"""
|
60
|
+
Test getPythonVersion method.
|
61
|
+
|
62
|
+
Tests that getPythonVersion returns the correct required Python version.
|
63
|
+
|
64
|
+
Returns
|
65
|
+
-------
|
66
|
+
None
|
67
|
+
"""
|
68
|
+
api = PypiPackageApi()
|
69
|
+
self.assertEqual(api.getPythonVersion(), ">=3.12")
|
@@ -1,15 +1,25 @@
|
|
1
1
|
class CustomError(Exception):
|
2
2
|
"""
|
3
|
-
|
3
|
+
Custom exception class for handling errors with an optional error code.
|
4
|
+
|
5
|
+
Parameters
|
6
|
+
----------
|
7
|
+
message : str
|
8
|
+
The error message describing the exception.
|
9
|
+
code : any, optional
|
10
|
+
An optional error code associated with the exception.
|
4
11
|
"""
|
5
12
|
|
6
13
|
def __init__(self, message, code=None):
|
7
14
|
"""
|
8
15
|
Initialize the custom error with a message and an optional error code.
|
9
16
|
|
10
|
-
|
11
|
-
|
12
|
-
|
17
|
+
Parameters
|
18
|
+
----------
|
19
|
+
message : str
|
20
|
+
The error message describing the exception.
|
21
|
+
code : any, optional
|
22
|
+
An optional error code associated with the exception.
|
13
23
|
"""
|
14
24
|
super().__init__(message)
|
15
25
|
self.code = code
|
@@ -2,11 +2,15 @@ from orionis.services.parsers.serializer import Parser
|
|
2
2
|
from orionis.unittesting import TestCase
|
3
3
|
from tests.services.parsers.mocks.mock_custom_error import CustomError
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestServicesParserExceptions(TestCase):
|
6
6
|
|
7
7
|
async def testBasicExceptionStructure(self):
|
8
8
|
"""
|
9
9
|
Ensure that the ExceptionParser correctly structures a basic exception.
|
10
|
+
|
11
|
+
Returns
|
12
|
+
-------
|
13
|
+
None
|
10
14
|
"""
|
11
15
|
try:
|
12
16
|
raise ValueError("Something went wrong")
|
@@ -29,7 +33,11 @@ class TestsExceptionParser(TestCase):
|
|
29
33
|
|
30
34
|
async def testRawExceptionProperty(self):
|
31
35
|
"""
|
32
|
-
Ensure that the
|
36
|
+
Ensure that the rawException property returns the original exception.
|
37
|
+
|
38
|
+
Returns
|
39
|
+
-------
|
40
|
+
None
|
33
41
|
"""
|
34
42
|
try:
|
35
43
|
raise RuntimeError("Test exception")
|
@@ -38,6 +46,13 @@ class TestsExceptionParser(TestCase):
|
|
38
46
|
self.assertIs(parser.raw_exception, e)
|
39
47
|
|
40
48
|
async def testExceptionWithCode(self):
|
49
|
+
"""
|
50
|
+
Ensure that exceptions with a custom error code are serialized correctly.
|
51
|
+
|
52
|
+
Returns
|
53
|
+
-------
|
54
|
+
None
|
55
|
+
"""
|
41
56
|
try:
|
42
57
|
raise CustomError("Custom message", code=404)
|
43
58
|
except Exception as e:
|
@@ -48,6 +63,10 @@ class TestsExceptionParser(TestCase):
|
|
48
63
|
async def testNestedExceptionCause(self):
|
49
64
|
"""
|
50
65
|
Ensure that the Parser.exception correctly handles nested exceptions.
|
66
|
+
|
67
|
+
Returns
|
68
|
+
-------
|
69
|
+
None
|
51
70
|
"""
|
52
71
|
try:
|
53
72
|
try:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|