orionis 0.287.0__py3-none-any.whl → 0.288.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.
Files changed (72) hide show
  1. orionis/metadata/framework.py +1 -1
  2. orionis/services/environment/contracts/types.py +70 -0
  3. orionis/services/environment/dot_env.py +11 -13
  4. orionis/services/environment/{type_hint.py → types.py} +64 -45
  5. orionis/services/paths/exceptions/not_found_exceptions.py +15 -12
  6. orionis/services/paths/exceptions/path_value_exceptions.py +13 -10
  7. orionis/services/standard/contracts/std.py +1 -1
  8. orionis/services/standard/exceptions/std_value_exception.py +23 -0
  9. orionis/services/standard/std.py +2 -2
  10. orionis/services/system/contracts/imports.py +27 -7
  11. orionis/services/system/contracts/workers.py +8 -3
  12. orionis/services/system/imports.py +31 -12
  13. orionis/services/system/runtime_imports.py +33 -23
  14. orionis/services/system/workers.py +6 -8
  15. orionis/services/wrapper/dicts/dot_dict.py +82 -41
  16. orionis/unittesting.py +12 -12
  17. {orionis-0.287.0.dist-info → orionis-0.288.0.dist-info}/METADATA +1 -1
  18. {orionis-0.287.0.dist-info → orionis-0.288.0.dist-info}/RECORD +70 -66
  19. tests/foundation/config/app/{test_app.py → test_foundation_config_app.py} +1 -1
  20. tests/foundation/config/auth/{test_auth.py → test_foundation_config_auth.py} +1 -1
  21. tests/foundation/config/cache/{test_cache.py → test_foundation_config_cache.py} +1 -1
  22. tests/foundation/config/cache/{test_cache_file.py → test_foundation_config_cache_file.py} +1 -1
  23. tests/foundation/config/cache/{test_cache_stores.py → test_foundation_config_cache_stores.py} +1 -1
  24. tests/foundation/config/cors/{test_cors.py → test_foundation_config_cors.py} +1 -1
  25. tests/foundation/config/database/{test_database.py → test_foundation_config_database.py} +1 -1
  26. tests/foundation/config/database/{test_database_connections.py → test_foundation_config_database_connections.py} +1 -1
  27. tests/foundation/config/database/{test_database_mysql.py → test_foundation_config_database_mysql.py} +1 -1
  28. tests/foundation/config/database/{test_database_oracle.py → test_foundation_config_database_oracle.py} +1 -1
  29. tests/foundation/config/database/{test_database_pgsql.py → test_foundation_config_database_pgsql.py} +1 -1
  30. tests/foundation/config/database/{test_database_sqlite.py → test_foundation_config_database_sqlite.py} +1 -1
  31. tests/foundation/config/exceptions/{test_exceptions_integrity.py → test_foundation_config_exceptions.py} +1 -1
  32. tests/foundation/config/filesystems/{test_filesystems.py → test_foundation_config_filesystems.py} +1 -1
  33. tests/foundation/config/filesystems/{test_filesystems_aws.py → test_foundation_config_filesystems_aws.py} +1 -1
  34. tests/foundation/config/filesystems/{test_filesystems_disks.py → test_foundation_config_filesystems_disks.py} +1 -1
  35. tests/foundation/config/filesystems/{test_filesystems_local.py → test_foundation_config_filesystems_local.py} +1 -1
  36. tests/foundation/config/filesystems/{test_filesystems_public.py → test_foundation_config_filesystems_public.py} +1 -1
  37. tests/foundation/config/logging/{test_logging.py → test_foundation_config_logging.py} +1 -1
  38. tests/foundation/config/logging/{test_logging_channels.py → test_foundation_config_logging_channels.py} +1 -1
  39. tests/foundation/config/logging/{test_logging_chunked.py → test_foundation_config_logging_chunked.py} +1 -1
  40. tests/foundation/config/logging/{test_logging_daily.py → test_foundation_config_logging_daily.py} +1 -1
  41. tests/foundation/config/logging/{test_logging_hourly.py → test_foundation_config_logging_hourly.py} +1 -1
  42. tests/foundation/config/logging/{test_logging_monthly.py → test_foundation_config_logging_monthly.py} +1 -1
  43. tests/foundation/config/logging/{test_logging_stack.py → test_foundation_config_logging_stack.py} +1 -1
  44. tests/foundation/config/logging/{test_logging_weekly.py → test_foundation_config_logging_weekly.py} +1 -1
  45. tests/foundation/config/mail/{test_mail.py → test_foundation_config_mail.py} +1 -1
  46. tests/foundation/config/mail/{test_mail_file.py → test_foundation_config_mail_file.py} +1 -1
  47. tests/foundation/config/mail/{test_mail_mailers.py → test_foundation_config_mail_mailers.py} +1 -1
  48. tests/foundation/config/mail/{test_mail_smtp.py → test_foundation_config_mail_smtp.py} +1 -1
  49. tests/foundation/config/queue/{test_queue.py → test_foundation_config_queue.py} +1 -1
  50. tests/foundation/config/queue/{test_queue_brokers.py → test_foundation_config_queue_brokers.py} +1 -1
  51. tests/foundation/config/queue/{test_queue_database.py → test_foundation_config_queue_database.py} +1 -1
  52. tests/foundation/config/root/{test_root_paths.py → test_foundation_config_root_paths.py} +1 -1
  53. tests/foundation/config/session/{test_session.py → test_foundation_config_session.py} +1 -1
  54. tests/foundation/config/startup/{test_config_startup.py → test_foundation_config_startup.py} +14 -14
  55. tests/foundation/config/testing/{test_testing.py → test_foundation_config_testing.py} +1 -1
  56. tests/patterns/singleton/{test_singleton.py → test_patterns_singleton.py} +1 -1
  57. tests/services/asynchrony/{test_async_io.py → test_services_asynchrony_coroutine.py} +1 -1
  58. tests/services/environment/test_services_environment.py +93 -0
  59. tests/services/path/{test_resolver.py → test_services_resolver.py} +51 -12
  60. tests/services/standard/{test_std.py → test_services_std.py} +45 -22
  61. tests/services/system/__init__.py +0 -0
  62. tests/services/system/test_services_system_imports.py +101 -0
  63. tests/services/system/test_services_system_workers.py +89 -0
  64. tests/services/wrapper/{test_wrapper_doc_dict.py → test_services_wrapper_docdict.py} +28 -16
  65. tests/testing/test_testing_result.py +1 -1
  66. tests/testing/test_testing_unit.py +16 -16
  67. orionis/services/standard/exceptions/path_value_exceptions.py +0 -28
  68. tests/services/environment/test_env.py +0 -154
  69. {orionis-0.287.0.dist-info → orionis-0.288.0.dist-info}/WHEEL +0 -0
  70. {orionis-0.287.0.dist-info → orionis-0.288.0.dist-info}/licenses/LICENCE +0 -0
  71. {orionis-0.287.0.dist-info → orionis-0.288.0.dist-info}/top_level.txt +0 -0
  72. {orionis-0.287.0.dist-info → orionis-0.288.0.dist-info}/zip-safe +0 -0
@@ -1,16 +1,23 @@
1
1
  from orionis.services.wrapper.dicts.dot_dict import DotDict
2
2
  from orionis.unittesting import TestCase
3
3
 
4
- class TestDotDict(TestCase):
4
+ class TestServicesWrapperDocDict(TestCase):
5
5
  """
6
6
  Test cases for the DotDict class which provides dictionary with dot notation access.
7
+
8
+ Notes
9
+ -----
10
+ These tests cover dot notation access, assignment, deletion, and utility methods
11
+ for the DotDict class, ensuring correct behavior and compatibility with nested
12
+ dictionaries.
7
13
  """
8
14
 
9
15
  async def testDotNotationAccess(self):
10
16
  """
11
- Test that dictionary values can be accessed using dot notation.
17
+ Test dot notation access for dictionary values.
18
+
12
19
  Verifies that both existing and non-existing keys can be accessed via dot notation,
13
- with None returned for missing keys.
20
+ with `None` returned for missing keys.
14
21
  """
15
22
  dd = DotDict({'key1': 'value1', 'nested': {'inner': 42}})
16
23
  self.assertEqual(dd.key1, 'value1')
@@ -19,7 +26,8 @@ class TestDotDict(TestCase):
19
26
 
20
27
  async def testDotNotationAssignment(self):
21
28
  """
22
- Test that dictionary values can be set using dot notation.
29
+ Test assignment of dictionary values using dot notation.
30
+
23
31
  Verifies that new keys can be added and existing keys can be updated using dot notation,
24
32
  with automatic conversion of nested dictionaries to DotDict.
25
33
  """
@@ -33,8 +41,9 @@ class TestDotDict(TestCase):
33
41
 
34
42
  async def testDotNotationDeletion(self):
35
43
  """
36
- Test that dictionary keys can be deleted using dot notation.
37
- Verifies that existing keys can be deleted and appropriate AttributeError is raised
44
+ Test deletion of dictionary keys using dot notation.
45
+
46
+ Verifies that existing keys can be deleted and an AttributeError is raised
38
47
  when trying to delete non-existent keys.
39
48
  """
40
49
  dd = DotDict({'key1': 'value1', 'key2': 'value2'})
@@ -46,8 +55,9 @@ class TestDotDict(TestCase):
46
55
 
47
56
  async def testGetMethod(self):
48
57
  """
49
- Test that the get method works with automatic DotDict conversion.
50
- Verifies that the get method returns the correct value or default,
58
+ Test the `get` method with automatic DotDict conversion.
59
+
60
+ Verifies that the `get` method returns the correct value or default,
51
61
  and converts nested dictionaries to DotDict instances.
52
62
  """
53
63
  dd = DotDict({'key1': 'value1', 'nested': {'inner': 42}})
@@ -59,7 +69,8 @@ class TestDotDict(TestCase):
59
69
 
60
70
  async def testExportMethod(self):
61
71
  """
62
- Test that the export method converts to regular dictionary recursively.
72
+ Test the `export` method for recursive conversion to regular dict.
73
+
63
74
  Verifies that all nested DotDict instances are converted back to regular dicts.
64
75
  """
65
76
  dd = DotDict({
@@ -78,7 +89,8 @@ class TestDotDict(TestCase):
78
89
 
79
90
  async def testCopyMethod(self):
80
91
  """
81
- Test that the copy method creates a deep copy with DotDict conversion.
92
+ Test the `copy` method for deep copy with DotDict conversion.
93
+
82
94
  Verifies that the copy is independent of the original and maintains DotDict structure.
83
95
  """
84
96
  original = DotDict({
@@ -98,7 +110,8 @@ class TestDotDict(TestCase):
98
110
 
99
111
  async def testNestedDictConversion(self):
100
112
  """
101
- Test that nested dictionaries are automatically converted to DotDict.
113
+ Test automatic conversion of nested dictionaries to DotDict.
114
+
102
115
  Verifies that nested dicts are converted both during initialization and assignment.
103
116
  """
104
117
  dd = DotDict({
@@ -120,10 +133,9 @@ class TestDotDict(TestCase):
120
133
 
121
134
  async def testReprMethod(self):
122
135
  """
123
- Test that the string representation correctly identifies as DotDict.
124
- Verifies that the __repr__ method includes the DotDict prefix.
136
+ Test the string representation of DotDict.
137
+
138
+ Verifies that the `__repr__` method includes the DotDict prefix.
125
139
  """
126
140
  dd = DotDict({'key': 'value'})
127
- self.assertTrue(repr(dd).startswith('DotDict({'))
128
- self.assertTrue(repr(dd).endswith('})'))
129
- self.assertIn("'key': 'value'", repr(dd))
141
+ self.assertEqual(repr(dd), "{'key': 'value'}")
@@ -1,6 +1,6 @@
1
1
  from orionis.unittesting import TestCase, TestResult, TestStatus
2
2
 
3
- class TestTestResult(TestCase):
3
+ class TestTestingResult(TestCase):
4
4
 
5
5
  async def testDefaultValues(self) -> None:
6
6
  """
@@ -1,7 +1,7 @@
1
1
  from orionis.test.cases.test_case import TestCase
2
- from orionis.unittesting import UnitTest, ExecutionMode, UnittestTestLoader, UnittestTestSuite, unittest_mock_patch, UnittestMagicMock, UnittestTestResult
2
+ from orionis.unittesting import UnitTest, ExecutionMode, TestLoader, StandardTestSuite, patch, MagicMock, StandardTestResult
3
3
 
4
- class TestUnitTest(TestCase):
4
+ class TestTestingUnit(TestCase):
5
5
 
6
6
  async def testDefaultConfiguration(self) -> None:
7
7
  """
@@ -17,8 +17,8 @@ class TestUnitTest(TestCase):
17
17
  self.assertEqual(unit_test.max_workers, 4)
18
18
  self.assertFalse(unit_test.fail_fast)
19
19
  self.assertTrue(unit_test.print_result)
20
- self.assertIsInstance(unit_test.loader, UnittestTestLoader)
21
- self.assertIsInstance(unit_test.suite, UnittestTestSuite)
20
+ self.assertIsInstance(unit_test.loader, TestLoader)
21
+ self.assertIsInstance(unit_test.suite, StandardTestSuite)
22
22
 
23
23
  async def testConfigureMethod(self) -> None:
24
24
  """
@@ -74,8 +74,8 @@ class TestUnitTest(TestCase):
74
74
  returned suite is handled as expected.
75
75
  """
76
76
  unit_test = UnitTest()
77
- with unittest_mock_patch.object(unit_test.loader, 'loadTestsFromName') as mock_load:
78
- mock_load.return_value = UnittestTestSuite()
77
+ with patch.object(unit_test.loader, 'loadTestsFromName') as mock_load:
78
+ mock_load.return_value = StandardTestSuite()
79
79
  result = unit_test.discoverTestsInModule('test_module')
80
80
 
81
81
  mock_load.assert_called_once_with('test_module')
@@ -100,14 +100,14 @@ class TestUnitTest(TestCase):
100
100
  - Asserts that all test cases from nested suites are present in the flattened result.
101
101
  """
102
102
  unit_test = UnitTest()
103
- test_case1 = UnittestMagicMock()
104
- test_case2 = UnittestMagicMock()
103
+ test_case1 = MagicMock()
104
+ test_case2 = MagicMock()
105
105
 
106
- nested_suite = UnittestTestSuite()
106
+ nested_suite = StandardTestSuite()
107
107
  nested_suite.addTest(test_case1)
108
108
  nested_suite.addTest(test_case2)
109
109
 
110
- main_suite = UnittestTestSuite()
110
+ main_suite = StandardTestSuite()
111
111
  main_suite.addTest(nested_suite)
112
112
 
113
113
  flattened = unit_test._flattenTestSuite(main_suite)
@@ -127,8 +127,8 @@ class TestUnitTest(TestCase):
127
127
  - Checks that failures and errors are merged without loss of information.
128
128
  """
129
129
  unit_test = UnitTest()
130
- combined = UnittestTestResult()
131
- individual = UnittestTestResult()
130
+ combined = StandardTestResult()
131
+ individual = StandardTestResult()
132
132
 
133
133
  individual.testsRun = 2
134
134
  individual.failures = [('test1', 'failure')]
@@ -157,7 +157,7 @@ class TestUnitTest(TestCase):
157
157
  - The length of the test suite should be zero after calling clearTests.
158
158
  """
159
159
  unit_test = UnitTest()
160
- mock_test = UnittestMagicMock()
160
+ mock_test = MagicMock()
161
161
  unit_test.suite.addTest(mock_test)
162
162
 
163
163
  unit_test.clearTests()
@@ -175,7 +175,7 @@ class TestUnitTest(TestCase):
175
175
  - Asserts that the returned list of test names matches the expected value.
176
176
  """
177
177
  unit_test = UnitTest()
178
- mock_test = UnittestMagicMock()
178
+ mock_test = MagicMock()
179
179
  mock_test.id.return_value = 'test_id'
180
180
  unit_test.suite.addTest(mock_test)
181
181
 
@@ -198,8 +198,8 @@ class TestUnitTest(TestCase):
198
198
  None
199
199
  """
200
200
  unit_test = UnitTest()
201
- mock_test1 = UnittestMagicMock()
202
- mock_test2 = UnittestMagicMock()
201
+ mock_test1 = MagicMock()
202
+ mock_test2 = MagicMock()
203
203
  unit_test.suite.addTest(mock_test1)
204
204
  unit_test.suite.addTest(mock_test2)
205
205
 
@@ -1,28 +0,0 @@
1
- class OrionisStdValueException(Exception):
2
- """
3
- Exception raised for standard value errors in the Orionis framework.
4
-
5
- Args:
6
- msg (str): A detailed message describing the value error.
7
-
8
- Example:
9
- raise OrionisStdValueException("Invalid value for parameter 'timeout'.")
10
- """
11
-
12
- def __init__(self, msg: str):
13
- """
14
- Initializes the exception with a custom error message.
15
-
16
- Args:
17
- msg (str): The error message describing the exception.
18
- """
19
- super().__init__(msg)
20
-
21
- def __str__(self) -> str:
22
- """
23
- Return a string representation of the exception, including the class name and the first argument.
24
-
25
- Returns:
26
- str: A formatted string with the exception class name and the first argument.
27
- """
28
- return f"{self.__class__.__name__}: {self.args[0]}"
@@ -1,154 +0,0 @@
1
- from orionis.services.environment.dot_env import DotEnv
2
- from orionis.services.environment.env import Env
3
- from orionis.unittesting import TestCase, unittest_mock_patch
4
-
5
- class TestEnv(TestCase):
6
- """
7
- Test cases for the Env class which provides environment variable management.
8
- """
9
-
10
- async def testGetMethod(self):
11
- """
12
- Test that the get method retrieves values correctly.
13
- Verifies that Env.get() properly delegates to DotEnv.get() and returns the expected value.
14
- """
15
-
16
- # Set test key in.env
17
- Env.set('TEST_KEY', 'test_value')
18
-
19
- async def testGetMethodWithDefault(self):
20
- """
21
- Test that the get method returns default value when key not found.
22
- Verifies that the default parameter is properly passed to DotEnv.get().
23
- """
24
- with unittest_mock_patch.object(DotEnv, 'get', return_value='default_value') as mock_get:
25
- result = Env.get('NON_EXISTENT_KEY', 'default_value')
26
- mock_get.assert_called_once_with('NON_EXISTENT_KEY', 'default_value', False)
27
- self.assertEqual(result, 'default_value')
28
-
29
- async def testSetMethod(self):
30
- """
31
- Test that the set method updates environment variables.
32
- Verifies that Env.set() properly delegates to DotEnv.set() and returns True on success.
33
- """
34
- with unittest_mock_patch.object(DotEnv, 'set', return_value=True) as mock_set:
35
- result = Env.set('TEST_KEY', 'test_value')
36
- mock_set.assert_called_once_with('TEST_KEY', 'test_value', False)
37
- self.assertTrue(result)
38
-
39
- async def testUnsetMethod(self):
40
- """
41
- Test that the unset method removes environment variables.
42
- Verifies that Env.unset() properly delegates to DotEnv.unset() and returns True on success.
43
- """
44
- with unittest_mock_patch.object(DotEnv, 'unset', return_value=True) as mock_unset:
45
- result = Env.unset('TEST_KEY')
46
- mock_unset.assert_called_once_with('TEST_KEY')
47
- self.assertTrue(result)
48
-
49
- async def testAllMethod(self):
50
- """
51
- Test that the all method retrieves all environment variables.
52
- Verifies that Env.all() properly delegates to DotEnv.all() and returns the expected dictionary.
53
- """
54
- mock_env = {'KEY1': 'value1', 'KEY2': 'value2'}
55
- with unittest_mock_patch.object(DotEnv, 'all', return_value=mock_env) as mock_all:
56
- result = Env.all()
57
- mock_all.assert_called_once()
58
- self.assertEqual(result, mock_env)
59
-
60
- async def testToJsonMethod(self):
61
- """
62
- Test that the toJson method serializes environment variables to JSON.
63
- Verifies that Env.toJson() properly delegates to DotEnv.toJson() and returns a JSON string.
64
- """
65
- mock_json = '{"KEY": "value"}'
66
- with unittest_mock_patch.object(DotEnv, 'toJson', return_value=mock_json) as mock_to_json:
67
- result = Env.toJson()
68
- mock_to_json.assert_called_once()
69
- self.assertEqual(result, mock_json)
70
-
71
- async def testToBase64Method(self):
72
- """
73
- Test that the toBase64 method encodes environment variables in Base64.
74
- Verifies that Env.toBase64() properly delegates to DotEnv.toBase64() and returns a Base64 string.
75
- """
76
- mock_b64 = 'base64encodedstring'
77
- with unittest_mock_patch.object(DotEnv, 'toBase64', return_value=mock_b64) as mock_to_b64:
78
- result = Env.toBase64()
79
- mock_to_b64.assert_called_once()
80
- self.assertEqual(result, mock_b64)
81
-
82
- async def testDotenvInstanceManagement(self):
83
- """
84
- Test that the Env._dotenv() method implements singleton behavior by ensuring
85
- that multiple calls return the same instance. Also verifies that resetting
86
- Env._dotenv_instance allows for a new instance to be created.
87
- """
88
-
89
- # Clear any existing instance
90
- Env._dotenv_instance = None
91
-
92
- # First call should create instance
93
- instance1 = Env._dotenv()
94
- instance2 = Env._dotenv()
95
-
96
- # Verify that the same instance is returned
97
- self.assertEqual(instance1, instance2)
98
-
99
- async def testHelperFunctionEnv(self):
100
- """
101
- Test that the env helper function works correctly.
102
- Verifies that the env() function properly delegates to DotEnv.get().
103
- """
104
- with unittest_mock_patch.object(DotEnv, 'get', return_value='test_value') as mock_get:
105
- from orionis.services.environment.env import env
106
- result = env('TEST_KEY', 'default_value')
107
- mock_get.assert_called_once_with('TEST_KEY', 'default_value')
108
- self.assertEqual(result, 'test_value')
109
-
110
- async def testOrionisConstants(self):
111
- """
112
- Test that Orionis framework constants are correctly set and retrieved via Env.
113
-
114
- This test imports a set of well-known constants from the Orionis framework and ensures:
115
- - Each constant can be set as an environment variable using Env.set().
116
- - Each constant can be retrieved using Env.get() and matches the original value.
117
- - The Env.get() method returns None for a non-existent key.
118
- - All constants are present in the dictionary returned by Env.all().
119
- """
120
- from orionis.metadata.framework import (
121
- NAME, VERSION, AUTHOR, AUTHOR_EMAIL, DESCRIPTION,
122
- SKELETON, FRAMEWORK, DOCS, API, PYTHON_REQUIRES
123
- )
124
- constants = {
125
- "NAME": NAME,
126
- "VERSION": VERSION,
127
- "AUTHOR": AUTHOR,
128
- "AUTHOR_EMAIL": AUTHOR_EMAIL,
129
- "DESCRIPTION": DESCRIPTION,
130
- "SKELETON": SKELETON,
131
- "FRAMEWORK": FRAMEWORK,
132
- "DOCS": DOCS,
133
- "API": API,
134
- "PYTHON_REQUIRES": PYTHON_REQUIRES
135
- }
136
-
137
- # Set all constants as environment variables
138
- for key, value in constants.items():
139
- result = Env.set(key, value)
140
- self.assertTrue(result, f"Env.set() should return True for key '{key}'")
141
-
142
- # Retrieve and verify each constant
143
- for key, value in constants.items():
144
- retrieved = Env.get(key)
145
- self.assertEqual(retrieved, value, f"Env.get('{key}') should return '{value}'")
146
-
147
- # Check that a non-existent key returns None
148
- self.assertIsNone(Env.get("NON_EXISTENT_ORIONIS_KEY"), "Env.get() should return None for missing keys")
149
-
150
- # Ensure all constants are present in Env.all()
151
- env_all = Env.all()
152
- for key, value in constants.items():
153
- self.assertIn(key, env_all, f"'{key}' should be present in Env.all()")
154
- self.assertEqual(env_all[key], value, f"Env.all()['{key}'] should be '{value}'")