orionis 0.287.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/services/environment/contracts/types.py +70 -0
- orionis/services/environment/dot_env.py +11 -13
- orionis/services/environment/{type_hint.py → types.py} +64 -45
- orionis/services/paths/exceptions/not_found_exceptions.py +15 -12
- orionis/services/paths/exceptions/path_value_exceptions.py +13 -10
- orionis/services/standard/contracts/std.py +1 -1
- orionis/services/standard/exceptions/std_value_exception.py +23 -0
- orionis/services/standard/std.py +2 -2
- orionis/services/system/contracts/imports.py +27 -7
- orionis/services/system/contracts/workers.py +8 -3
- orionis/services/system/imports.py +31 -12
- orionis/services/system/runtime_imports.py +33 -23
- orionis/services/system/workers.py +6 -8
- orionis/services/wrapper/dicts/dot_dict.py +82 -41
- orionis/unittesting.py +12 -12
- {orionis-0.287.0.dist-info → orionis-0.289.0.dist-info}/METADATA +1 -1
- {orionis-0.287.0.dist-info → orionis-0.289.0.dist-info}/RECORD +76 -69
- tests/foundation/config/app/{test_app.py → test_foundation_config_app.py} +1 -1
- tests/foundation/config/auth/{test_auth.py → test_foundation_config_auth.py} +1 -1
- tests/foundation/config/cache/{test_cache.py → test_foundation_config_cache.py} +1 -1
- tests/foundation/config/cache/{test_cache_file.py → test_foundation_config_cache_file.py} +1 -1
- tests/foundation/config/cache/{test_cache_stores.py → test_foundation_config_cache_stores.py} +1 -1
- tests/foundation/config/cors/{test_cors.py → test_foundation_config_cors.py} +1 -1
- tests/foundation/config/database/{test_database.py → test_foundation_config_database.py} +1 -1
- tests/foundation/config/database/{test_database_connections.py → test_foundation_config_database_connections.py} +1 -1
- tests/foundation/config/database/{test_database_mysql.py → test_foundation_config_database_mysql.py} +1 -1
- tests/foundation/config/database/{test_database_oracle.py → test_foundation_config_database_oracle.py} +1 -1
- tests/foundation/config/database/{test_database_pgsql.py → test_foundation_config_database_pgsql.py} +1 -1
- tests/foundation/config/database/{test_database_sqlite.py → test_foundation_config_database_sqlite.py} +1 -1
- tests/foundation/config/exceptions/{test_exceptions_integrity.py → test_foundation_config_exceptions.py} +1 -1
- tests/foundation/config/filesystems/{test_filesystems.py → test_foundation_config_filesystems.py} +1 -1
- tests/foundation/config/filesystems/{test_filesystems_aws.py → test_foundation_config_filesystems_aws.py} +1 -1
- tests/foundation/config/filesystems/{test_filesystems_disks.py → test_foundation_config_filesystems_disks.py} +1 -1
- tests/foundation/config/filesystems/{test_filesystems_local.py → test_foundation_config_filesystems_local.py} +1 -1
- tests/foundation/config/filesystems/{test_filesystems_public.py → test_foundation_config_filesystems_public.py} +1 -1
- tests/foundation/config/logging/{test_logging.py → test_foundation_config_logging.py} +1 -1
- tests/foundation/config/logging/{test_logging_channels.py → test_foundation_config_logging_channels.py} +1 -1
- tests/foundation/config/logging/{test_logging_chunked.py → test_foundation_config_logging_chunked.py} +1 -1
- tests/foundation/config/logging/{test_logging_daily.py → test_foundation_config_logging_daily.py} +1 -1
- tests/foundation/config/logging/{test_logging_hourly.py → test_foundation_config_logging_hourly.py} +1 -1
- tests/foundation/config/logging/{test_logging_monthly.py → test_foundation_config_logging_monthly.py} +1 -1
- tests/foundation/config/logging/{test_logging_stack.py → test_foundation_config_logging_stack.py} +1 -1
- tests/foundation/config/logging/{test_logging_weekly.py → test_foundation_config_logging_weekly.py} +1 -1
- tests/foundation/config/mail/{test_mail.py → test_foundation_config_mail.py} +1 -1
- tests/foundation/config/mail/{test_mail_file.py → test_foundation_config_mail_file.py} +1 -1
- tests/foundation/config/mail/{test_mail_mailers.py → test_foundation_config_mail_mailers.py} +1 -1
- tests/foundation/config/mail/{test_mail_smtp.py → test_foundation_config_mail_smtp.py} +1 -1
- tests/foundation/config/queue/{test_queue.py → test_foundation_config_queue.py} +1 -1
- tests/foundation/config/queue/{test_queue_brokers.py → test_foundation_config_queue_brokers.py} +1 -1
- tests/foundation/config/queue/{test_queue_database.py → test_foundation_config_queue_database.py} +1 -1
- tests/foundation/config/root/{test_root_paths.py → test_foundation_config_root_paths.py} +1 -1
- tests/foundation/config/session/{test_session.py → test_foundation_config_session.py} +1 -1
- tests/foundation/config/startup/{test_config_startup.py → test_foundation_config_startup.py} +14 -14
- tests/foundation/config/testing/{test_testing.py → test_foundation_config_testing.py} +1 -1
- tests/metadata/__init__.py +0 -0
- tests/metadata/test_metadata_framework.py +101 -0
- tests/metadata/test_metadata_package.py +69 -0
- tests/patterns/singleton/{test_singleton.py → test_patterns_singleton.py} +1 -1
- tests/services/asynchrony/{test_async_io.py → test_services_asynchrony_coroutine.py} +1 -1
- tests/services/environment/test_services_environment.py +93 -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
- tests/services/path/{test_resolver.py → test_services_resolver.py} +51 -12
- tests/services/standard/{test_std.py → test_services_std.py} +45 -22
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +101 -0
- tests/services/system/test_services_system_workers.py +89 -0
- tests/services/wrapper/{test_wrapper_doc_dict.py → test_services_wrapper_docdict.py} +28 -16
- tests/testing/test_testing_result.py +1 -1
- tests/testing/test_testing_unit.py +16 -16
- orionis/services/standard/exceptions/path_value_exceptions.py +0 -28
- tests/services/environment/test_env.py +0 -154
- {orionis-0.287.0.dist-info → orionis-0.289.0.dist-info}/WHEEL +0 -0
- {orionis-0.287.0.dist-info → orionis-0.289.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.287.0.dist-info → orionis-0.289.0.dist-info}/top_level.txt +0 -0
- {orionis-0.287.0.dist-info → orionis-0.289.0.dist-info}/zip-safe +0 -0
tests/foundation/config/startup/{test_config_startup.py → test_foundation_config_startup.py}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
from dataclasses import is_dataclass
|
2
2
|
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
3
3
|
from orionis.foundation.config.startup import Configuration
|
4
|
-
from orionis.unittesting import TestCase,
|
4
|
+
from orionis.unittesting import TestCase, Mock
|
5
5
|
|
6
|
-
class
|
6
|
+
class TestFoundationConfigStartup(TestCase):
|
7
7
|
"""
|
8
8
|
Test suite for the Configuration dataclass.
|
9
9
|
|
@@ -98,18 +98,18 @@ class TestConfiguration(TestCase):
|
|
98
98
|
|
99
99
|
# Test each section with wrong type
|
100
100
|
sections = [
|
101
|
-
('paths',
|
102
|
-
('app',
|
103
|
-
('auth',
|
104
|
-
('cache',
|
105
|
-
('cors',
|
106
|
-
('database',
|
107
|
-
('filesystems',
|
108
|
-
('logging',
|
109
|
-
('mail',
|
110
|
-
('queue',
|
111
|
-
('session',
|
112
|
-
('testing',
|
101
|
+
('paths', Mock()),
|
102
|
+
('app', Mock()),
|
103
|
+
('auth', Mock()),
|
104
|
+
('cache', Mock()),
|
105
|
+
('cors', Mock()),
|
106
|
+
('database', Mock()),
|
107
|
+
('filesystems', Mock()),
|
108
|
+
('logging', Mock()),
|
109
|
+
('mail', Mock()),
|
110
|
+
('queue', Mock()),
|
111
|
+
('session', Mock()),
|
112
|
+
('testing', Mock())
|
113
113
|
]
|
114
114
|
|
115
115
|
for section_name, wrong_value in sections:
|
@@ -3,7 +3,7 @@ from orionis.foundation.config.exceptions.integrity import OrionisIntegrityExcep
|
|
3
3
|
from orionis.test.enums.test_mode import ExecutionMode
|
4
4
|
from orionis.unittesting import TestCase
|
5
5
|
|
6
|
-
class
|
6
|
+
class TestFoundationConfigTesting(TestCase):
|
7
7
|
"""
|
8
8
|
Test suite for the Testing configuration entity.
|
9
9
|
|
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")
|
@@ -3,7 +3,7 @@ from orionis.services.asynchrony.coroutines import Coroutine
|
|
3
3
|
from orionis.services.asynchrony.exceptions.coroutine_exception import OrionisCoroutineException
|
4
4
|
from orionis.unittesting import TestCase
|
5
5
|
|
6
|
-
class
|
6
|
+
class TestServicesAsynchronyCoroutine(TestCase):
|
7
7
|
|
8
8
|
async def testExecuteWithActiveEventLoop(self):
|
9
9
|
"""
|
@@ -0,0 +1,93 @@
|
|
1
|
+
from orionis.services.environment.env import Env
|
2
|
+
from orionis.unittesting import TestCase
|
3
|
+
|
4
|
+
class TestServicesEnvironment(TestCase):
|
5
|
+
|
6
|
+
async def testSetAndGetConstants(self):
|
7
|
+
"""
|
8
|
+
Test storing and retrieving framework metadata constants using Env.set and Env.get.
|
9
|
+
|
10
|
+
Imports several metadata constants from the `orionis.metadata.framework` module, sets each constant
|
11
|
+
in the Env storage using `Env.set`, and verifies that the operation succeeds. Then retrieves each
|
12
|
+
constant using `Env.get` and asserts that the retrieved value matches the original constant.
|
13
|
+
|
14
|
+
Ensures
|
15
|
+
-------
|
16
|
+
- `Env.set` returns True for each constant.
|
17
|
+
- `Env.get` returns the correct value for each constant.
|
18
|
+
"""
|
19
|
+
from orionis.metadata.framework import (
|
20
|
+
NAME, VERSION, AUTHOR, AUTHOR_EMAIL, DESCRIPTION,
|
21
|
+
SKELETON, FRAMEWORK, DOCS, API, PYTHON_REQUIRES
|
22
|
+
)
|
23
|
+
constants = {
|
24
|
+
"NAME": NAME,
|
25
|
+
"VERSION": VERSION,
|
26
|
+
"AUTHOR": AUTHOR,
|
27
|
+
"AUTHOR_EMAIL": AUTHOR_EMAIL,
|
28
|
+
"DESCRIPTION": DESCRIPTION,
|
29
|
+
"SKELETON": SKELETON,
|
30
|
+
"FRAMEWORK": FRAMEWORK,
|
31
|
+
"DOCS": DOCS,
|
32
|
+
"API": API,
|
33
|
+
"PYTHON_REQUIRES": PYTHON_REQUIRES
|
34
|
+
}
|
35
|
+
for key, value in constants.items():
|
36
|
+
result = Env.set(key, value)
|
37
|
+
self.assertTrue(result)
|
38
|
+
for key, value in constants.items():
|
39
|
+
retrieved = Env.get(key)
|
40
|
+
self.assertEqual(retrieved, value)
|
41
|
+
|
42
|
+
async def testGetNonExistentKey(self):
|
43
|
+
"""
|
44
|
+
Test that Env.get returns None for a non-existent environment key.
|
45
|
+
|
46
|
+
Ensures
|
47
|
+
-------
|
48
|
+
- `Env.get` returns None when the key does not exist.
|
49
|
+
"""
|
50
|
+
self.assertIsNone(Env.get("NON_EXISTENT_KEY"))
|
51
|
+
|
52
|
+
async def testTypeHints(self):
|
53
|
+
"""
|
54
|
+
Test that Env.set and Env.get correctly handle and preserve Python type hints.
|
55
|
+
|
56
|
+
Sets environment variables with various data types (int, float, bool, str, list, dict, tuple, set)
|
57
|
+
using the `Env.set` method, specifying the type as a string. Then retrieves each variable using
|
58
|
+
`Env.get` and asserts that the returned value is of the expected Python type.
|
59
|
+
|
60
|
+
Ensures
|
61
|
+
-------
|
62
|
+
- The returned value from `Env.get` matches the expected Python type for each variable.
|
63
|
+
"""
|
64
|
+
|
65
|
+
# Set environment variables with type hints
|
66
|
+
Env.set("TEST_INT", 42, 'int')
|
67
|
+
Env.set("TEST_FLOAT", 3.14, 'float')
|
68
|
+
Env.set("TEST_BOOL", True, 'bool')
|
69
|
+
Env.set("TEST_STR", "Hello, World!", 'str')
|
70
|
+
Env.set("TEST_LIST", [1, 2, 3], 'list')
|
71
|
+
Env.set("TEST_DICT", {"key": "value"}, 'dict')
|
72
|
+
Env.set("TEST_TUPLE", (1,2,3), 'tuple')
|
73
|
+
Env.set("TEST_SET", {1, 2, 3}, 'set')
|
74
|
+
|
75
|
+
# Retrieve and check types
|
76
|
+
self.assertIsInstance(Env.get("TEST_INT"), int)
|
77
|
+
self.assertIsInstance(Env.get("TEST_FLOAT"), float)
|
78
|
+
self.assertIsInstance(Env.get("TEST_BOOL"), bool)
|
79
|
+
self.assertIsInstance(Env.get("TEST_STR"), str)
|
80
|
+
self.assertIsInstance(Env.get("TEST_LIST"), list)
|
81
|
+
self.assertIsInstance(Env.get("TEST_DICT"), dict)
|
82
|
+
self.assertIsInstance(Env.get("TEST_TUPLE"), tuple)
|
83
|
+
self.assertIsInstance(Env.get("TEST_SET"), set)
|
84
|
+
|
85
|
+
# Clean up environment variables after test
|
86
|
+
Env.unset("TEST_INT")
|
87
|
+
Env.unset("TEST_FLOAT")
|
88
|
+
Env.unset("TEST_BOOL")
|
89
|
+
Env.unset("TEST_STR")
|
90
|
+
Env.unset("TEST_LIST")
|
91
|
+
Env.unset("TEST_DICT")
|
92
|
+
Env.unset("TEST_TUPLE")
|
93
|
+
Env.unset("TEST_SET")
|
@@ -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:
|
@@ -1,27 +1,42 @@
|
|
1
|
-
import tempfile
|
2
1
|
import os
|
2
|
+
import tempfile
|
3
3
|
from pathlib import Path
|
4
|
+
from orionis.services.paths.exceptions.not_found_exceptions import OrionisFileNotFoundException
|
4
5
|
from orionis.services.paths.resolver import Resolver
|
5
6
|
from orionis.unittesting import TestCase
|
6
7
|
|
7
|
-
class
|
8
|
-
"""
|
9
|
-
Unit tests for the Resolver class, which resolves file and directory paths relative to a base directory.
|
10
|
-
"""
|
8
|
+
class TestServicesResolver(TestCase):
|
11
9
|
|
12
|
-
async def
|
10
|
+
async def testFileNotFound(self):
|
13
11
|
"""
|
14
|
-
Test that resolving a non-existent file path raises
|
12
|
+
Test that resolving a non-existent file path raises OrionisFileNotFoundException.
|
13
|
+
|
14
|
+
Returns
|
15
|
+
-------
|
16
|
+
None
|
17
|
+
|
18
|
+
Raises
|
19
|
+
------
|
20
|
+
OrionisFileNotFoundException
|
21
|
+
If the file does not exist.
|
15
22
|
"""
|
16
23
|
with tempfile.TemporaryDirectory() as tmpdir:
|
17
24
|
resolver = Resolver(tmpdir)
|
18
25
|
non_existent = "does_not_exist.txt"
|
19
|
-
with self.assertRaises(
|
26
|
+
with self.assertRaises(OrionisFileNotFoundException):
|
20
27
|
resolver.relativePath(non_existent)
|
21
28
|
|
22
|
-
async def
|
29
|
+
async def testValidFilePath(self):
|
23
30
|
"""
|
24
31
|
Test that resolving a valid file path returns the correct absolute path.
|
32
|
+
|
33
|
+
Returns
|
34
|
+
-------
|
35
|
+
None
|
36
|
+
|
37
|
+
Asserts
|
38
|
+
-------
|
39
|
+
The resolved path ends with the file name and is absolute.
|
25
40
|
"""
|
26
41
|
with tempfile.TemporaryDirectory() as tmpdir:
|
27
42
|
# Create a temporary file inside the temp directory
|
@@ -34,9 +49,17 @@ class TestsResolver(TestCase):
|
|
34
49
|
# The resolved path should be absolute
|
35
50
|
self.assertTrue(os.path.isabs(resolved))
|
36
51
|
|
37
|
-
async def
|
52
|
+
async def testValidDirectoryPath(self):
|
38
53
|
"""
|
39
54
|
Test that resolving a valid directory path returns the correct absolute path.
|
55
|
+
|
56
|
+
Returns
|
57
|
+
-------
|
58
|
+
None
|
59
|
+
|
60
|
+
Asserts
|
61
|
+
-------
|
62
|
+
The resolved path ends with the directory name and is absolute.
|
40
63
|
"""
|
41
64
|
with tempfile.TemporaryDirectory() as tmpdir:
|
42
65
|
# Create a subdirectory inside the temp directory
|
@@ -47,9 +70,17 @@ class TestsResolver(TestCase):
|
|
47
70
|
self.assertTrue(resolved.endswith("subdir"))
|
48
71
|
self.assertTrue(os.path.isabs(resolved))
|
49
72
|
|
50
|
-
async def
|
73
|
+
async def testOtherBasePath(self):
|
51
74
|
"""
|
52
75
|
Test that providing a different base path to Resolver works as expected.
|
76
|
+
|
77
|
+
Returns
|
78
|
+
-------
|
79
|
+
None
|
80
|
+
|
81
|
+
Asserts
|
82
|
+
-------
|
83
|
+
The resolved path ends with the file name and is absolute.
|
53
84
|
"""
|
54
85
|
with tempfile.TemporaryDirectory() as tmpdir:
|
55
86
|
# Create a file in a subdirectory
|
@@ -62,9 +93,17 @@ class TestsResolver(TestCase):
|
|
62
93
|
self.assertTrue(resolved.endswith("file.txt"))
|
63
94
|
self.assertTrue(os.path.isabs(resolved))
|
64
95
|
|
65
|
-
async def
|
96
|
+
async def testEqualOutputString(self):
|
66
97
|
"""
|
67
98
|
Test that the string representation of the resolved path matches the output of toString().
|
99
|
+
|
100
|
+
Returns
|
101
|
+
-------
|
102
|
+
None
|
103
|
+
|
104
|
+
Asserts
|
105
|
+
-------
|
106
|
+
The string representation of the resolved path matches the output of toString().
|
68
107
|
"""
|
69
108
|
with tempfile.TemporaryDirectory() as tmpdir:
|
70
109
|
file_path = Path(tmpdir) / "file.txt"
|
@@ -1,14 +1,16 @@
|
|
1
|
-
|
1
|
+
from orionis.services.standard.exceptions.std_value_exception import OrionisStdValueException
|
2
2
|
from orionis.services.standard.std import StdClass
|
3
3
|
from orionis.unittesting import TestCase
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestServicesStd(TestCase):
|
6
6
|
|
7
7
|
async def testInitializationAndAccess(self):
|
8
8
|
"""
|
9
9
|
Test the initialization of StdClass and access to its attributes.
|
10
10
|
|
11
|
-
|
11
|
+
Notes
|
12
|
+
-----
|
13
|
+
Verifies that an instance of StdClass can be created with the given
|
12
14
|
first name, last name, and age, and that these attributes can be accessed
|
13
15
|
correctly after initialization.
|
14
16
|
"""
|
@@ -24,7 +26,9 @@ class TestStdClass(TestCase):
|
|
24
26
|
"""
|
25
27
|
Test that the toDict method of StdClass returns a dictionary with the correct data.
|
26
28
|
|
27
|
-
|
29
|
+
Notes
|
30
|
+
-----
|
31
|
+
Creates an instance of StdClass with specific attributes and verifies
|
28
32
|
that calling toDict() returns a dictionary containing those attributes and their values.
|
29
33
|
"""
|
30
34
|
obj = StdClass(a=1, b=2)
|
@@ -35,7 +39,9 @@ class TestStdClass(TestCase):
|
|
35
39
|
"""
|
36
40
|
Test that the `update` method of `StdClass` correctly sets multiple attributes.
|
37
41
|
|
38
|
-
|
42
|
+
Notes
|
43
|
+
-----
|
44
|
+
Creates an instance of `StdClass`, updates its attributes using the `update` method,
|
39
45
|
and asserts that the attributes `foo` and `number` are set to the expected values.
|
40
46
|
"""
|
41
47
|
obj = StdClass()
|
@@ -47,27 +53,36 @@ class TestStdClass(TestCase):
|
|
47
53
|
"""
|
48
54
|
Test that updating a reserved attribute (such as '__init__') on a StdClass instance
|
49
55
|
raises a ValueError exception.
|
56
|
+
|
57
|
+
Notes
|
58
|
+
-----
|
59
|
+
Ensures that updating a reserved attribute raises an OrionisStdValueException.
|
50
60
|
"""
|
51
61
|
obj = StdClass()
|
52
|
-
with self.assertRaises(
|
62
|
+
with self.assertRaises(OrionisStdValueException):
|
53
63
|
obj.update(__init__='bad')
|
54
64
|
|
55
65
|
async def testUpdateConflictingAttributeRaisesError(self):
|
56
66
|
"""
|
57
67
|
Test that updating an object with a conflicting attribute name ('toDict') raises a ValueError.
|
58
68
|
|
59
|
-
|
69
|
+
Notes
|
70
|
+
-----
|
71
|
+
Ensures that attempting to update the StdClass instance with a keyword argument
|
60
72
|
that conflicts with an existing method or reserved attribute ('toDict') correctly triggers
|
61
|
-
|
73
|
+
an OrionisStdValueException, enforcing attribute safety.
|
62
74
|
"""
|
63
75
|
obj = StdClass()
|
64
|
-
with self.assertRaises(
|
76
|
+
with self.assertRaises(OrionisStdValueException):
|
65
77
|
obj.update(toDict='oops')
|
66
78
|
|
67
79
|
async def testRemoveExistingAttributes(self):
|
68
80
|
"""
|
69
|
-
|
70
|
-
|
81
|
+
Test that the `remove` method of `StdClass` successfully removes an existing attribute.
|
82
|
+
|
83
|
+
Notes
|
84
|
+
-----
|
85
|
+
Removes attribute 'x' from the object and checks that 'y' remains.
|
71
86
|
"""
|
72
87
|
obj = StdClass(x=1, y=2)
|
73
88
|
obj.remove('x')
|
@@ -78,7 +93,9 @@ class TestStdClass(TestCase):
|
|
78
93
|
"""
|
79
94
|
Test that attempting to remove a non-existing attribute from a StdClass instance raises an AttributeError.
|
80
95
|
|
81
|
-
|
96
|
+
Notes
|
97
|
+
-----
|
98
|
+
Verifies that the `remove` method of `StdClass` raises an AttributeError
|
82
99
|
when called with the name of an attribute that does not exist on the object.
|
83
100
|
"""
|
84
101
|
obj = StdClass()
|
@@ -89,20 +106,23 @@ class TestStdClass(TestCase):
|
|
89
106
|
"""
|
90
107
|
Test that StdClass.from_dict creates an instance equivalent to the original data.
|
91
108
|
|
92
|
-
|
109
|
+
Notes
|
110
|
+
-----
|
111
|
+
Verifies that when a dictionary is passed to StdClass.from_dict,
|
93
112
|
the resulting object's toDict() method returns a dictionary equal to the original input.
|
94
113
|
"""
|
95
114
|
data = {'a': 10, 'b': 20}
|
96
|
-
obj = StdClass.
|
115
|
+
obj = StdClass.fromDict(data)
|
97
116
|
self.assertEqual(obj.toDict(), data)
|
98
117
|
|
99
118
|
async def testReprAndStr(self):
|
100
119
|
"""
|
101
120
|
Test that the __repr__ and __str__ methods of StdClass include the class name and the value of 'x' respectively.
|
102
121
|
|
103
|
-
|
104
|
-
|
105
|
-
-
|
122
|
+
Notes
|
123
|
+
-----
|
124
|
+
- Checks that repr(obj) contains the class name 'StdClass'.
|
125
|
+
- Checks that str(obj) contains the key-value pair "'x': 5".
|
106
126
|
"""
|
107
127
|
obj = StdClass(x=5)
|
108
128
|
self.assertIn("StdClass", repr(obj))
|
@@ -110,15 +130,18 @@ class TestStdClass(TestCase):
|
|
110
130
|
|
111
131
|
async def testEquality(self):
|
112
132
|
"""
|
113
|
-
|
133
|
+
Test the equality and inequality operations for StdClass instances.
|
114
134
|
|
115
|
-
|
135
|
+
Notes
|
136
|
+
-----
|
137
|
+
Creates three instances of StdClass:
|
116
138
|
- 'a' and 'b' with identical attributes (x=1, y=2), which should be considered equal.
|
117
139
|
- 'c' with a different attribute (x=3), which should not be equal to 'a'.
|
118
140
|
|
119
|
-
|
120
|
-
|
121
|
-
-
|
141
|
+
Asserts
|
142
|
+
-------
|
143
|
+
- 'a' and 'b' are equal.
|
144
|
+
- 'a' and 'c' are not equal.
|
122
145
|
"""
|
123
146
|
a = StdClass(x=1, y=2)
|
124
147
|
b = StdClass(x=1, y=2)
|
File without changes
|