orionis 0.286.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 (86) hide show
  1. orionis/metadata/framework.py +1 -1
  2. orionis/services/environment/contracts/env.py +45 -50
  3. orionis/services/environment/contracts/types.py +70 -0
  4. orionis/services/environment/dot_env.py +204 -182
  5. orionis/services/environment/env.py +68 -85
  6. orionis/services/{standard/exceptions/path_value_exceptions.py → environment/exceptions/environment_value_error.py} +2 -12
  7. orionis/services/environment/exceptions/environment_value_exception.py +23 -0
  8. orionis/services/environment/types.py +578 -0
  9. orionis/services/paths/exceptions/not_found_exceptions.py +15 -12
  10. orionis/services/paths/exceptions/path_value_exceptions.py +13 -10
  11. orionis/services/standard/contracts/std.py +1 -1
  12. orionis/services/standard/exceptions/std_value_exception.py +23 -0
  13. orionis/services/standard/std.py +2 -2
  14. orionis/services/system/contracts/imports.py +27 -7
  15. orionis/services/system/contracts/workers.py +8 -3
  16. orionis/services/system/imports.py +31 -12
  17. orionis/services/system/runtime_imports.py +33 -23
  18. orionis/services/system/workers.py +6 -8
  19. orionis/services/wrapper/dicts/dot_dict.py +82 -41
  20. orionis/test/logs/history.py +3 -5
  21. orionis/unittesting.py +12 -12
  22. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/METADATA +1 -1
  23. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/RECORD +76 -70
  24. tests/example/test_example.py +5 -2
  25. tests/foundation/config/app/{test_app.py → test_foundation_config_app.py} +14 -4
  26. tests/foundation/config/auth/{test_auth.py → test_foundation_config_auth.py} +10 -5
  27. tests/foundation/config/cache/{test_cache.py → test_foundation_config_cache.py} +61 -16
  28. tests/foundation/config/cache/test_foundation_config_cache_file.py +126 -0
  29. tests/foundation/config/cache/test_foundation_config_cache_stores.py +148 -0
  30. tests/foundation/config/cors/test_foundation_config_cors.py +190 -0
  31. tests/foundation/config/database/{test_database.py → test_foundation_config_database.py} +39 -15
  32. tests/foundation/config/database/{test_database_connections.py → test_foundation_config_database_connections.py} +80 -6
  33. tests/foundation/config/database/{test_database_mysql.py → test_foundation_config_database_mysql.py} +139 -16
  34. tests/foundation/config/database/{test_database_oracle.py → test_foundation_config_database_oracle.py} +111 -27
  35. tests/foundation/config/database/{test_database_pgsql.py → test_foundation_config_database_pgsql.py} +97 -27
  36. tests/foundation/config/database/{test_database_sqlite.py → test_foundation_config_database_sqlite.py} +57 -3
  37. tests/foundation/config/exceptions/{test_exceptions_integrity.py → test_foundation_config_exceptions.py} +45 -11
  38. tests/foundation/config/filesystems/{test_filesystems.py → test_foundation_config_filesystems.py} +65 -15
  39. tests/foundation/config/filesystems/{test_filesystems_aws.py → test_foundation_config_filesystems_aws.py} +46 -8
  40. tests/foundation/config/filesystems/{test_filesystems_disks.py → test_foundation_config_filesystems_disks.py} +79 -9
  41. tests/foundation/config/filesystems/{test_filesystems_local.py → test_foundation_config_filesystems_local.py} +67 -19
  42. tests/foundation/config/filesystems/{test_filesystems_public.py → test_foundation_config_filesystems_public.py} +38 -1
  43. tests/foundation/config/logging/test_foundation_config_logging.py +112 -0
  44. tests/foundation/config/logging/{test_logging_channels.py → test_foundation_config_logging_channels.py} +80 -3
  45. tests/foundation/config/logging/{test_logging_chunked.py → test_foundation_config_logging_chunked.py} +86 -13
  46. tests/foundation/config/logging/{test_logging_daily.py → test_foundation_config_logging_daily.py} +80 -13
  47. tests/foundation/config/logging/{test_logging_hourly.py → test_foundation_config_logging_hourly.py} +69 -3
  48. tests/foundation/config/logging/{test_logging_monthly.py → test_foundation_config_logging_monthly.py} +49 -3
  49. tests/foundation/config/logging/{test_logging_stack.py → test_foundation_config_logging_stack.py} +50 -15
  50. tests/foundation/config/logging/{test_logging_weekly.py → test_foundation_config_logging_weekly.py} +93 -3
  51. tests/foundation/config/mail/test_foundation_config_mail.py +145 -0
  52. tests/foundation/config/mail/{test_mail_file.py → test_foundation_config_mail_file.py} +41 -5
  53. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +106 -0
  54. tests/foundation/config/mail/{test_mail_smtp.py → test_foundation_config_mail_smtp.py} +59 -15
  55. tests/foundation/config/queue/test_foundation_config_queue.py +111 -0
  56. tests/foundation/config/queue/{test_queue_brokers.py → test_foundation_config_queue_brokers.py} +28 -11
  57. tests/foundation/config/queue/{test_queue_database.py → test_foundation_config_queue_database.py} +54 -16
  58. tests/foundation/config/root/{test_root_paths.py → test_foundation_config_root_paths.py} +70 -3
  59. tests/foundation/config/session/{test_session.py → test_foundation_config_session.py} +31 -2
  60. tests/foundation/config/startup/{test_config_startup.py → test_foundation_config_startup.py} +91 -21
  61. tests/foundation/config/testing/{test_testing.py → test_foundation_config_testing.py} +69 -1
  62. tests/patterns/singleton/test_patterns_singleton.py +27 -0
  63. tests/services/asynchrony/{test_async_io.py → test_services_asynchrony_coroutine.py} +1 -1
  64. tests/services/environment/test_services_environment.py +93 -0
  65. tests/services/path/{test_resolver.py → test_services_resolver.py} +51 -12
  66. tests/services/standard/{test_std.py → test_services_std.py} +45 -22
  67. tests/services/system/__init__.py +0 -0
  68. tests/services/system/test_services_system_imports.py +101 -0
  69. tests/services/system/test_services_system_workers.py +89 -0
  70. tests/services/wrapper/{test_wrapper_doc_dict.py → test_services_wrapper_docdict.py} +28 -16
  71. tests/testing/test_testing_result.py +57 -20
  72. tests/testing/test_testing_unit.py +110 -41
  73. orionis/services/environment/exceptions/value_exception.py +0 -27
  74. tests/foundation/config/cache/test_cache_file.py +0 -78
  75. tests/foundation/config/cache/test_cache_stores.py +0 -88
  76. tests/foundation/config/cors/test_cors.py +0 -121
  77. tests/foundation/config/logging/test_logging.py +0 -48
  78. tests/foundation/config/mail/test_mail.py +0 -73
  79. tests/foundation/config/mail/test_mail_mailers.py +0 -58
  80. tests/foundation/config/queue/test_queue.py +0 -58
  81. tests/patterns/singleton/test_singleton.py +0 -18
  82. tests/services/environment/test_env.py +0 -155
  83. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/WHEEL +0 -0
  84. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/licenses/LICENCE +0 -0
  85. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/top_level.txt +0 -0
  86. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/zip-safe +0 -0
@@ -1,58 +0,0 @@
1
- from orionis.foundation.config.mail.entities.mailers import Mailers
2
- from orionis.foundation.config.mail.entities.smtp import Smtp
3
- from orionis.foundation.config.mail.entities.file import File
4
- from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
5
- from orionis.unittesting import TestCase
6
-
7
- class TestMailers(TestCase):
8
-
9
- async def testDefaultInitialization(self):
10
- """
11
- Test that Mailers instance is initialized with correct default factories.
12
- Verifies that smtp and file attributes are properly initialized with their respective types.
13
- """
14
- mailers = Mailers()
15
- self.assertIsInstance(mailers.smtp, Smtp)
16
- self.assertIsInstance(mailers.file, File)
17
-
18
- async def testTypeValidation(self):
19
- """
20
- Test type validation for smtp and file attributes.
21
- Verifies that invalid types raise OrionisIntegrityException.
22
- """
23
- with self.assertRaises(OrionisIntegrityException):
24
- Mailers(smtp="invalid_smtp")
25
- with self.assertRaises(OrionisIntegrityException):
26
- Mailers(file="invalid_file")
27
-
28
- async def testCustomInitialization(self):
29
- """
30
- Test custom initialization with valid parameters.
31
- Verifies that valid Smtp and File instances are accepted.
32
- """
33
- custom_smtp = Smtp()
34
- custom_file = File()
35
- mailers = Mailers(smtp=custom_smtp, file=custom_file)
36
- self.assertIs(mailers.smtp, custom_smtp)
37
- self.assertIs(mailers.file, custom_file)
38
-
39
- async def testToDictMethod(self):
40
- """
41
- Test the toDict method returns proper dictionary representation.
42
- Verifies the method returns a dict containing all fields with correct values.
43
- """
44
- mailers = Mailers()
45
- result = mailers.toDict()
46
- self.assertIsInstance(result, dict)
47
- self.assertIn("smtp", result)
48
- self.assertIn("file", result)
49
- self.assertIsInstance(result["smtp"], dict)
50
- self.assertIsInstance(result["file"], dict)
51
-
52
- async def testKwOnlyInitialization(self):
53
- """
54
- Test that Mailers requires keyword arguments for initialization.
55
- Verifies the class enforces kw_only=True in its dataclass decorator.
56
- """
57
- with self.assertRaises(TypeError):
58
- Mailers(Smtp(), File())
@@ -1,58 +0,0 @@
1
- from orionis.foundation.config.queue.entities.queue import Queue
2
- from orionis.foundation.config.queue.entities.brokers import Brokers
3
- from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
4
- from orionis.unittesting import TestCase
5
-
6
- class TestQueue(TestCase):
7
-
8
- async def testDefaultInitialization(self):
9
- """
10
- Test that Queue instance is initialized with correct default values.
11
- Verifies that default connection is 'sync' and brokers is a Brokers instance.
12
- """
13
- queue = Queue()
14
- self.assertEqual(queue.default, "sync")
15
- self.assertIsInstance(queue.brokers, Brokers)
16
-
17
- async def testDefaultValidation(self):
18
- """
19
- Test validation for default attribute.
20
- Verifies that invalid default values raise OrionisIntegrityException.
21
- """
22
- invalid_options = ["invalid", "", 123, None]
23
- for option in invalid_options:
24
- with self.assertRaises(OrionisIntegrityException):
25
- Queue(default=option)
26
-
27
- async def testBrokersValidation(self):
28
- """
29
- Test validation for brokers attribute.
30
- Verifies that non-Brokers values raise OrionisIntegrityException.
31
- """
32
- with self.assertRaises(OrionisIntegrityException):
33
- Queue(brokers="invalid_brokers")
34
- with self.assertRaises(OrionisIntegrityException):
35
- Queue(brokers={})
36
-
37
- async def testValidCustomInitialization(self):
38
- """
39
- Test custom initialization with valid parameters.
40
- Verifies that valid default and Brokers instances are accepted.
41
- """
42
- custom_brokers = Brokers(sync=False)
43
- queue = Queue(default="sync", brokers=custom_brokers)
44
- self.assertEqual(queue.default, "sync")
45
- self.assertIs(queue.brokers, custom_brokers)
46
- self.assertFalse(queue.brokers.sync)
47
-
48
- async def testToDictMethod(self):
49
- """
50
- Test the toDict method returns proper dictionary representation.
51
- Verifies all fields are included with correct values.
52
- """
53
- queue = Queue()
54
- result = queue.toDict()
55
- self.assertIsInstance(result, dict)
56
- self.assertEqual(result["default"], "sync")
57
- self.assertIsInstance(result["brokers"], dict)
58
- self.assertTrue(result["brokers"]["sync"])
@@ -1,18 +0,0 @@
1
- from orionis.patterns.singleton.meta_class import Singleton
2
- from orionis.test.cases.test_case import TestCase
3
-
4
- class TestsAsyncCoroutine(TestCase):
5
-
6
- async def testSingleton(self):
7
- """
8
- Test the Singleton metaclass to ensure that only one instance of a class is created.
9
- """
10
- class SingletonClass(metaclass=Singleton):
11
- def __init__(self, value):
12
- self.value = value
13
-
14
- instance1 = SingletonClass(1)
15
- instance2 = SingletonClass(2)
16
-
17
- self.assertIs(instance1, instance2)
18
- self.assertEqual(instance1.value, 1)
@@ -1,155 +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
- with unittest_mock_patch.object(DotEnv, 'get', return_value='test_value') as mock_get:
16
- result = Env.get('TEST_KEY')
17
- mock_get.assert_called_once_with('TEST_KEY', None, False)
18
- self.assertEqual(result, 'test_value')
19
-
20
- async def testGetMethodWithDefault(self):
21
- """
22
- Test that the get method returns default value when key not found.
23
- Verifies that the default parameter is properly passed to DotEnv.get().
24
- """
25
- with unittest_mock_patch.object(DotEnv, 'get', return_value='default_value') as mock_get:
26
- result = Env.get('NON_EXISTENT_KEY', 'default_value')
27
- mock_get.assert_called_once_with('NON_EXISTENT_KEY', 'default_value', False)
28
- self.assertEqual(result, 'default_value')
29
-
30
- async def testSetMethod(self):
31
- """
32
- Test that the set method updates environment variables.
33
- Verifies that Env.set() properly delegates to DotEnv.set() and returns True on success.
34
- """
35
- with unittest_mock_patch.object(DotEnv, 'set', return_value=True) as mock_set:
36
- result = Env.set('TEST_KEY', 'test_value')
37
- mock_set.assert_called_once_with('TEST_KEY', 'test_value', False)
38
- self.assertTrue(result)
39
-
40
- async def testUnsetMethod(self):
41
- """
42
- Test that the unset method removes environment variables.
43
- Verifies that Env.unset() properly delegates to DotEnv.unset() and returns True on success.
44
- """
45
- with unittest_mock_patch.object(DotEnv, 'unset', return_value=True) as mock_unset:
46
- result = Env.unset('TEST_KEY')
47
- mock_unset.assert_called_once_with('TEST_KEY')
48
- self.assertTrue(result)
49
-
50
- async def testAllMethod(self):
51
- """
52
- Test that the all method retrieves all environment variables.
53
- Verifies that Env.all() properly delegates to DotEnv.all() and returns the expected dictionary.
54
- """
55
- mock_env = {'KEY1': 'value1', 'KEY2': 'value2'}
56
- with unittest_mock_patch.object(DotEnv, 'all', return_value=mock_env) as mock_all:
57
- result = Env.all()
58
- mock_all.assert_called_once()
59
- self.assertEqual(result, mock_env)
60
-
61
- async def testToJsonMethod(self):
62
- """
63
- Test that the toJson method serializes environment variables to JSON.
64
- Verifies that Env.toJson() properly delegates to DotEnv.toJson() and returns a JSON string.
65
- """
66
- mock_json = '{"KEY": "value"}'
67
- with unittest_mock_patch.object(DotEnv, 'toJson', return_value=mock_json) as mock_to_json:
68
- result = Env.toJson()
69
- mock_to_json.assert_called_once()
70
- self.assertEqual(result, mock_json)
71
-
72
- async def testToBase64Method(self):
73
- """
74
- Test that the toBase64 method encodes environment variables in Base64.
75
- Verifies that Env.toBase64() properly delegates to DotEnv.toBase64() and returns a Base64 string.
76
- """
77
- mock_b64 = 'base64encodedstring'
78
- with unittest_mock_patch.object(DotEnv, 'toBase64', return_value=mock_b64) as mock_to_b64:
79
- result = Env.toBase64()
80
- mock_to_b64.assert_called_once()
81
- self.assertEqual(result, mock_b64)
82
-
83
- async def testDotenvInstanceManagement(self):
84
- """
85
- Test that the Env._dotenv() method implements singleton behavior by ensuring
86
- that multiple calls return the same instance. Also verifies that resetting
87
- Env._dotenv_instance allows for a new instance to be created.
88
- """
89
-
90
- # Clear any existing instance
91
- Env._dotenv_instance = None
92
-
93
- # First call should create instance
94
- instance1 = Env._dotenv()
95
- instance2 = Env._dotenv()
96
-
97
- # Verify that the same instance is returned
98
- self.assertEqual(instance1, instance2)
99
-
100
- async def testHelperFunctionEnv(self):
101
- """
102
- Test that the env helper function works correctly.
103
- Verifies that the env() function properly delegates to DotEnv.get().
104
- """
105
- with unittest_mock_patch.object(DotEnv, 'get', return_value='test_value') as mock_get:
106
- from orionis.services.environment.env import env
107
- result = env('TEST_KEY', 'default_value')
108
- mock_get.assert_called_once_with('TEST_KEY', 'default_value')
109
- self.assertEqual(result, 'test_value')
110
-
111
- async def testOrionisConstants(self):
112
- """
113
- Test that Orionis framework constants are correctly set and retrieved via Env.
114
-
115
- This test imports a set of well-known constants from the Orionis framework and ensures:
116
- - Each constant can be set as an environment variable using Env.set().
117
- - Each constant can be retrieved using Env.get() and matches the original value.
118
- - The Env.get() method returns None for a non-existent key.
119
- - All constants are present in the dictionary returned by Env.all().
120
- """
121
- from orionis.metadata.framework import (
122
- NAME, VERSION, AUTHOR, AUTHOR_EMAIL, DESCRIPTION,
123
- SKELETON, FRAMEWORK, DOCS, API, PYTHON_REQUIRES
124
- )
125
- constants = {
126
- "NAME": NAME,
127
- "VERSION": VERSION,
128
- "AUTHOR": AUTHOR,
129
- "AUTHOR_EMAIL": AUTHOR_EMAIL,
130
- "DESCRIPTION": DESCRIPTION,
131
- "SKELETON": SKELETON,
132
- "FRAMEWORK": FRAMEWORK,
133
- "DOCS": DOCS,
134
- "API": API,
135
- "PYTHON_REQUIRES": PYTHON_REQUIRES
136
- }
137
-
138
- # Set all constants as environment variables
139
- for key, value in constants.items():
140
- result = Env.set(key, value)
141
- self.assertTrue(result, f"Env.set() should return True for key '{key}'")
142
-
143
- # Retrieve and verify each constant
144
- for key, value in constants.items():
145
- retrieved = Env.get(key)
146
- self.assertEqual(retrieved, value, f"Env.get('{key}') should return '{value}'")
147
-
148
- # Check that a non-existent key returns None
149
- self.assertIsNone(Env.get("NON_EXISTENT_ORIONIS_KEY"), "Env.get() should return None for missing keys")
150
-
151
- # Ensure all constants are present in Env.all()
152
- env_all = Env.all()
153
- for key, value in constants.items():
154
- self.assertIn(key, env_all, f"'{key}' should be present in Env.all()")
155
- self.assertEqual(env_all[key], value, f"Env.all()['{key}'] should be '{value}'")