orionis 0.546.0__py3-none-any.whl → 0.547.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 (160) hide show
  1. orionis/console/base/scheduler_event_listener.py +0 -17
  2. orionis/console/contracts/schedule_event_listener.py +0 -18
  3. orionis/foundation/config/app/entities/app.py +3 -2
  4. orionis/foundation/config/app/enums/ciphers.py +5 -19
  5. orionis/foundation/config/session/entities/session.py +2 -2
  6. orionis/metadata/framework.py +1 -1
  7. orionis/services/encrypter/encrypter.py +115 -0
  8. orionis/services/environment/dynamic/caster.py +35 -27
  9. orionis/services/environment/key/key_generator.py +32 -11
  10. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/METADATA +1 -1
  11. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/RECORD +15 -159
  12. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/top_level.txt +0 -1
  13. tests/container/__init__.py +0 -0
  14. tests/container/context/__init__.py +0 -0
  15. tests/container/context/test_manager.py +0 -38
  16. tests/container/context/test_scope.py +0 -32
  17. tests/container/core/__init__.py +0 -0
  18. tests/container/core/test_advanced_async.py +0 -234
  19. tests/container/core/test_async_optimizations.py +0 -268
  20. tests/container/core/test_container.py +0 -453
  21. tests/container/core/test_singleton.py +0 -122
  22. tests/container/core/test_thread_safety.py +0 -90
  23. tests/container/entities/__init__.py +0 -0
  24. tests/container/entities/test_binding.py +0 -242
  25. tests/container/enums/__init__.py +0 -0
  26. tests/container/enums/test_lifetimes.py +0 -97
  27. tests/container/facades/__init__.py +0 -0
  28. tests/container/facades/test_facade.py +0 -78
  29. tests/container/mocks/__init__.py +0 -0
  30. tests/container/mocks/mock_advanced_async.py +0 -332
  31. tests/container/mocks/mock_async_optimizations.py +0 -407
  32. tests/container/mocks/mock_auto_resolution.py +0 -192
  33. tests/container/mocks/mock_complex_classes.py +0 -792
  34. tests/container/mocks/mock_simple_classes.py +0 -98
  35. tests/container/providers/__init__.py +0 -0
  36. tests/container/providers/test_providers.py +0 -55
  37. tests/container/validators/__init__.py +0 -0
  38. tests/container/validators/test_implements.py +0 -186
  39. tests/container/validators/test_is_abstract_class.py +0 -147
  40. tests/container/validators/test_is_callable.py +0 -102
  41. tests/container/validators/test_is_concrete_class.py +0 -160
  42. tests/container/validators/test_is_instance.py +0 -150
  43. tests/container/validators/test_is_not_subclass.py +0 -49
  44. tests/container/validators/test_is_subclass.py +0 -178
  45. tests/container/validators/test_is_valid_alias.py +0 -147
  46. tests/container/validators/test_lifetime.py +0 -106
  47. tests/example/__init__.py +0 -0
  48. tests/example/test_example.py +0 -725
  49. tests/foundation/__init__.py +0 -0
  50. tests/foundation/config/__init__.py +0 -0
  51. tests/foundation/config/app/__init__.py +0 -0
  52. tests/foundation/config/app/test_foundation_config_app.py +0 -262
  53. tests/foundation/config/auth/__init__.py +0 -0
  54. tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
  55. tests/foundation/config/cache/__init__.py +0 -0
  56. tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
  57. tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
  58. tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
  59. tests/foundation/config/cors/__init__.py +0 -0
  60. tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
  61. tests/foundation/config/database/__init__.py +0 -0
  62. tests/foundation/config/database/test_foundation_config_database.py +0 -158
  63. tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
  64. tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
  65. tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
  66. tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
  67. tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
  68. tests/foundation/config/filesystems/__init__.py +0 -0
  69. tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
  70. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
  71. tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
  72. tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
  73. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
  74. tests/foundation/config/logging/__init__.py +0 -0
  75. tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
  76. tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
  77. tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
  78. tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
  79. tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
  80. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
  81. tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
  82. tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
  83. tests/foundation/config/mail/__init__.py +0 -0
  84. tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
  85. tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
  86. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
  87. tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
  88. tests/foundation/config/queue/__init__.py +0 -0
  89. tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
  90. tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
  91. tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
  92. tests/foundation/config/root/__init__.py +0 -0
  93. tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
  94. tests/foundation/config/session/__init__.py +0 -0
  95. tests/foundation/config/session/test_foundation_config_session.py +0 -213
  96. tests/foundation/config/startup/__init__.py +0 -0
  97. tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
  98. tests/foundation/config/testing/__init__.py +0 -0
  99. tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
  100. tests/metadata/__init__.py +0 -0
  101. tests/metadata/test_metadata_framework.py +0 -140
  102. tests/metadata/test_metadata_package.py +0 -139
  103. tests/services/__init__.py +0 -0
  104. tests/services/asynchrony/__init__.py +0 -0
  105. tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
  106. tests/services/environment/__init__.py +0 -0
  107. tests/services/environment/test_services_environment.py +0 -226
  108. tests/services/introspection/__init__.py +0 -0
  109. tests/services/introspection/dependencies/__init__.py +0 -0
  110. tests/services/introspection/dependencies/mocks/__init__.py +0 -0
  111. tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
  112. tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
  113. tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
  114. tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
  115. tests/services/introspection/reflection/__init__.py +0 -0
  116. tests/services/introspection/reflection/mock/__init__.py +0 -0
  117. tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
  118. tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
  119. tests/services/introspection/reflection/test_reflection_callable.py +0 -206
  120. tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
  121. tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
  122. tests/services/introspection/reflection/test_reflection_module.py +0 -567
  123. tests/services/introspection/test_reflection.py +0 -462
  124. tests/services/log/__init__.py +0 -0
  125. tests/services/log/test_log.py +0 -97
  126. tests/services/system/__init__.py +0 -0
  127. tests/services/system/test_services_system_imports.py +0 -204
  128. tests/services/system/test_services_system_workers.py +0 -131
  129. tests/support/__init__.py +0 -0
  130. tests/support/entities/__init__.py +0 -0
  131. tests/support/entities/mock_dataclass.py +0 -40
  132. tests/support/entities/test_base.py +0 -64
  133. tests/support/patterns/__init__.py +0 -0
  134. tests/support/patterns/singleton/__init__.py +0 -0
  135. tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
  136. tests/support/standard/__init__.py +0 -0
  137. tests/support/standard/test_services_std.py +0 -226
  138. tests/support/wrapper/__init__.py +0 -0
  139. tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
  140. tests/testing/__init__.py +0 -0
  141. tests/testing/cases/__init__.py +0 -0
  142. tests/testing/cases/test_testing_asynchronous.py +0 -63
  143. tests/testing/cases/test_testing_synchronous.py +0 -57
  144. tests/testing/entities/__init__.py +0 -0
  145. tests/testing/entities/test_testing_result.py +0 -146
  146. tests/testing/enums/__init__.py +0 -0
  147. tests/testing/enums/test_testing_status.py +0 -63
  148. tests/testing/output/__init__.py +0 -0
  149. tests/testing/output/test_testing_dumper.py +0 -29
  150. tests/testing/output/test_testing_printer.py +0 -42
  151. tests/testing/records/__init__.py +0 -0
  152. tests/testing/records/test_testing_records.py +0 -171
  153. tests/testing/test_testing_unit.py +0 -164
  154. tests/testing/validators/__init__.py +0 -0
  155. tests/testing/validators/test_testing_validators.py +0 -392
  156. tests/testing/view/__init__.py +0 -0
  157. tests/testing/view/test_render.py +0 -30
  158. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
  159. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
  160. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
@@ -1,140 +0,0 @@
1
- from orionis.metadata.framework import *
2
- from orionis.test.cases.asynchronous import AsyncTestCase
3
-
4
- class TestMetadataFramework(AsyncTestCase):
5
- """
6
- Test cases for the metadata constants and utility functions in orionis.metadata.framework.
7
- """
8
-
9
- async def testConstantsExistAndAreStr(self):
10
- """
11
- Test that all required metadata constants exist and are of type `str`.
12
-
13
- This method iterates over a predefined list of metadata constants and checks
14
- that each is an instance of `str`. This ensures that the metadata values
15
- required by the framework are properly defined and typed.
16
-
17
- Returns
18
- -------
19
- None
20
- This is a test method and does not return any value. Assertions are used
21
- to validate the conditions.
22
- """
23
-
24
- # List of metadata constants to check
25
- for const in [
26
- NAME, VERSION, AUTHOR, AUTHOR_EMAIL, DESCRIPTION,
27
- SKELETON, FRAMEWORK, DOCS, API, PYTHON_REQUIRES
28
- ]:
29
- # Assert that each constant is a string
30
- self.assertIsInstance(const, str)
31
-
32
- async def testClassifiersStructure(self):
33
- """
34
- Validate the structure and type of the `CLASSIFIERS` metadata constant.
35
-
36
- This test ensures that the `CLASSIFIERS` constant is a list of strings,
37
- and that each string contains at least one '::' separator, which is
38
- typical for Python package classifiers.
39
-
40
- Parameters
41
- ----------
42
- self : TestMetadataFramework
43
- The test case instance.
44
-
45
- Returns
46
- -------
47
- None
48
- This method does not return any value. Assertions are used to
49
- validate the structure and contents of `CLASSIFIERS`.
50
- """
51
-
52
- # Assert that CLASSIFIERS is a list
53
- self.assertIsInstance(CLASSIFIERS, list)
54
- for item in CLASSIFIERS:
55
-
56
- # Assert that each item in CLASSIFIERS is a string
57
- self.assertIsInstance(item, str)
58
-
59
- # Assert that each classifier string contains at least one '::' separator
60
- self.assertTrue("::" in item or len(item.split("::")) > 1)
61
-
62
- async def testKeywords(self):
63
- """
64
- Validate the structure and contents of the `KEYWORDS` metadata constant.
65
-
66
- This test checks that the `KEYWORDS` constant is a list of strings, ensuring
67
- that each keyword is properly typed. Additionally, it verifies that the list
68
- contains the essential keywords "orionis" and "framework", which are required
69
- for accurate metadata representation.
70
-
71
- Parameters
72
- ----------
73
- self : TestMetadataFramework
74
- The test case instance.
75
-
76
- Returns
77
- -------
78
- None
79
- This method does not return any value. Assertions are used to validate
80
- the structure and contents of `KEYWORDS`.
81
- """
82
-
83
- # Assert that KEYWORDS is a list
84
- self.assertIsInstance(KEYWORDS, list)
85
-
86
- # Check that each keyword in KEYWORDS is a string
87
- for kw in KEYWORDS:
88
- self.assertIsInstance(kw, str)
89
-
90
- # Ensure essential keywords are present in the list
91
- self.assertIn("orionis", KEYWORDS)
92
- self.assertIn("framework", KEYWORDS)
93
-
94
- async def testRequiresStructure(self):
95
- """
96
- Validate the structure and contents of the `REQUIRES` metadata constant.
97
-
98
- This test checks that the `REQUIRES` constant is a list of strings, where each string
99
- represents a package requirement and contains the '>=' version specifier. This ensures
100
- that all requirements are properly typed and formatted for dependency management.
101
-
102
- Parameters
103
- ----------
104
- self : TestMetadataFramework
105
- The test case instance.
106
-
107
- Returns
108
- -------
109
- None
110
- This method does not return any value. Assertions are used to validate
111
- the structure and contents of `REQUIRES`.
112
- """
113
-
114
- # Assert that REQUIRES is a list
115
- self.assertIsInstance(REQUIRES, list)
116
-
117
- # Check that each requirement in REQUIRES is a string and contains '>='
118
- for req in REQUIRES:
119
- self.assertIsInstance(req, str) # Each requirement should be a string
120
- self.assertIn(">=", req) # Each requirement should specify a minimum version
121
-
122
- async def testIconFunction(self):
123
- """
124
- Test the behavior and return type of the `icon()` utility function.
125
-
126
- This test verifies that the `icon()` function returns either a string containing
127
- SVG data or `None` if the icon file is not found. It ensures that the function's
128
- output is correctly typed and handles missing resources gracefully.
129
-
130
- Returns
131
- -------
132
- None
133
- This method does not return any value. Assertions are used to validate
134
- the type and behavior of the `icon()` function.
135
- """
136
- # Call the icon() function and store the result
137
- result = icon()
138
-
139
- # Assert that the result is either a string (SVG data) or None (file not found)
140
- self.assertTrue(isinstance(result, str) or result is None)
@@ -1,139 +0,0 @@
1
- from orionis.test.cases.asynchronous import AsyncTestCase
2
- from unittest.mock import patch
3
-
4
- class TestPypiOrionisPackage(AsyncTestCase):
5
-
6
- @patch("orionis.metadata.package.PypiOrionisPackage")
7
- async def testGetName(self, MockPypiOrionisPackage):
8
- """
9
- Tests the `getName` method of the `PypiOrionisPackage` class.
10
-
11
- This test verifies that the mocked `getName` method returns the expected package name.
12
-
13
- Parameters
14
- ----------
15
- MockPypiOrionisPackage : MagicMock
16
- Mocked `PypiOrionisPackage` class.
17
-
18
- Returns
19
- -------
20
- None
21
- This method does not return anything. It asserts the expected behavior.
22
- """
23
-
24
- # Get the mocked API instance
25
- api = MockPypiOrionisPackage.return_value
26
-
27
- # Set the return value for getName
28
- api.getName.return_value = "orionis"
29
-
30
- # Assert that getName returns the expected value
31
- self.assertEqual(api.getName(), "orionis")
32
-
33
- @patch("orionis.metadata.package.PypiOrionisPackage")
34
- async def testGetAuthor(self, MockPypiOrionisPackage):
35
- """
36
- Tests the `getAuthor` method of the `PypiOrionisPackage` class.
37
-
38
- This test checks that the mocked `getAuthor` method returns the correct author name.
39
-
40
- Parameters
41
- ----------
42
- MockPypiOrionisPackage : MagicMock
43
- Mocked `PypiOrionisPackage` class.
44
-
45
- Returns
46
- -------
47
- None
48
- This method does not return anything. It asserts the expected behavior.
49
- """
50
-
51
- # Get the mocked API instance
52
- api = MockPypiOrionisPackage.return_value
53
-
54
- # Set the return value for getAuthor
55
- api.getAuthor.return_value = "Raul Mauricio Uñate Castro"
56
-
57
- # Assert that getAuthor returns the expected value
58
- self.assertEqual(api.getAuthor(), "Raul Mauricio Uñate Castro")
59
-
60
- @patch("orionis.metadata.package.PypiOrionisPackage")
61
- async def testGetAuthorEmail(self, MockPypiOrionisPackage):
62
- """
63
- Tests the `getAuthorEmail` method of the `PypiOrionisPackage` class.
64
-
65
- This test ensures that the mocked `getAuthorEmail` method returns the correct author email address.
66
-
67
- Parameters
68
- ----------
69
- MockPypiOrionisPackage : MagicMock
70
- Mocked `PypiOrionisPackage` class.
71
-
72
- Returns
73
- -------
74
- None
75
- This method does not return anything. It asserts the expected behavior.
76
- """
77
-
78
- # Get the mocked API instance
79
- api = MockPypiOrionisPackage.return_value
80
-
81
- # Set the return value for getAuthorEmail
82
- api.getAuthorEmail.return_value = "raulmauriciounate@gmail.com"
83
-
84
- # Assert that getAuthorEmail returns the expected value
85
- self.assertEqual(api.getAuthorEmail(), "raulmauriciounate@gmail.com")
86
-
87
- @patch("orionis.metadata.package.PypiOrionisPackage")
88
- async def testGetDescription(self, MockPypiOrionisPackage):
89
- """
90
- Tests the `getDescription` method of the `PypiOrionisPackage` class.
91
-
92
- This test verifies that the mocked `getDescription` method returns the expected package description.
93
-
94
- Parameters
95
- ----------
96
- MockPypiOrionisPackage : MagicMock
97
- Mocked `PypiOrionisPackage` class.
98
-
99
- Returns
100
- -------
101
- None
102
- This method does not return anything. It asserts the expected behavior.
103
- """
104
-
105
- # Get the mocked API instance
106
- api = MockPypiOrionisPackage.return_value
107
-
108
- # Set the return value for getDescription
109
- api.getDescription.return_value = "Orionis Framework – Elegant, Fast, and Powerful."
110
-
111
- # Assert that getDescription returns the expected value
112
- self.assertEqual(api.getDescription(), "Orionis Framework – Elegant, Fast, and Powerful.")
113
-
114
- @patch("orionis.metadata.package.PypiOrionisPackage")
115
- async def testGetPythonVersion(self, MockPypiOrionisPackage):
116
- """
117
- Tests the `getPythonVersion` method of the `PypiOrionisPackage` class.
118
-
119
- This test checks that the mocked `getPythonVersion` method returns the correct Python version requirement.
120
-
121
- Parameters
122
- ----------
123
- MockPypiOrionisPackage : MagicMock
124
- Mocked `PypiOrionisPackage` class.
125
-
126
- Returns
127
- -------
128
- None
129
- This method does not return anything. It asserts the expected behavior.
130
- """
131
-
132
- # Get the mocked API instance
133
- api = MockPypiOrionisPackage.return_value
134
-
135
- # Set the return value for getPythonVersion
136
- api.getPythonVersion.return_value = ">=3.12"
137
-
138
- # Assert that getPythonVersion returns the expected value
139
- self.assertEqual(api.getPythonVersion(), ">=3.12")
File without changes
File without changes
@@ -1,85 +0,0 @@
1
-
2
- import asyncio
3
- from orionis.services.asynchrony.coroutines import Coroutine
4
- from orionis.services.asynchrony.exceptions import OrionisCoroutineException
5
- from orionis.test.cases.asynchronous import AsyncTestCase
6
-
7
- class TestServicesAsynchronyCoroutine(AsyncTestCase):
8
-
9
- async def testExecuteWithActiveEventLoop(self):
10
- """
11
- Tests coroutine execution within an active event loop.
12
-
13
- This method verifies that a coroutine can be executed successfully when an event loop is already running,
14
- such as in asynchronous environments (e.g., Jupyter notebooks or ASGI applications). It ensures that the
15
- Coroutine wrapper correctly awaits and returns the result of the coroutine.
16
-
17
- Returns
18
- -------
19
- None
20
- This is a test method and does not return a value. It asserts that the coroutine result matches the expected output.
21
- """
22
-
23
- # Simple coroutine that returns a string
24
- async def sample_coroutine():
25
- asyncio.sleep(0.1)
26
- return "Hello, World!"
27
-
28
- # Await the result of running the coroutine using the Coroutine wrapper
29
- result = await Coroutine(sample_coroutine()).run()
30
-
31
- # Assert that the result matches the expected output
32
- self.assertEqual(result, "Hello, World!")
33
-
34
- def testExecuteWithoutActiveEventLoop(self):
35
- """
36
- Tests coroutine execution without an active event loop.
37
-
38
- This method simulates the scenario where a coroutine is executed in a synchronous context,
39
- such as a standard Python script, where no event loop is running. It verifies that the
40
- Coroutine wrapper can correctly create and manage an event loop internally, execute the
41
- coroutine, and return the expected result.
42
-
43
- Returns
44
- -------
45
- None
46
- This test method does not return a value. It asserts that the coroutine result matches the expected output.
47
- """
48
-
49
- # Define a simple coroutine that returns a string
50
- async def sample_coroutine():
51
- asyncio.sleep(0.1)
52
- return "Hello, World!"
53
-
54
- # Run the coroutine using the Coroutine wrapper, which should handle event loop creation
55
- result = Coroutine(sample_coroutine()).run()
56
-
57
- # Assert that the result matches the expected output
58
- self.assertEqual(result, "Hello, World!")
59
-
60
- def testExecuteWithNonCoroutine(self):
61
- """
62
- Tests execution of a non-coroutine object.
63
-
64
- This method verifies that passing a non-coroutine object to the Coroutine wrapper
65
- raises an OrionisCoroutineException. It ensures that the Coroutine class enforces
66
- the requirement for coroutine objects and does not accept regular functions or other types.
67
-
68
- Parameters
69
- ----------
70
- self : TestServicesAsynchronyCoroutine
71
- The test case instance.
72
-
73
- Returns
74
- -------
75
- None
76
- This test method does not return a value. It asserts that the appropriate exception is raised.
77
- """
78
-
79
- # Define a regular function (not a coroutine)
80
- def sample_no_coroutine():
81
- return "Hello, World!"
82
-
83
- # Assert that passing a non-coroutine raises OrionisCoroutineException
84
- with self.assertRaises(OrionisCoroutineException):
85
- Coroutine(sample_no_coroutine()).run()
File without changes
@@ -1,226 +0,0 @@
1
- from orionis.services.environment.core.dot_env import DotEnv
2
- from orionis.services.environment.env import Env
3
- from orionis.services.environment.enums.value_type import EnvironmentValueType
4
- from orionis.services.environment.key.key_generator import SecureKeyGenerator
5
- from orionis.test.cases.asynchronous import AsyncTestCase
6
-
7
- class TestServicesEnvironment(AsyncTestCase):
8
-
9
- async def testSetAndGetConstants(self):
10
- """
11
- Stores and retrieves framework metadata constants using Env.set and Env.get.
12
-
13
- This test imports several metadata constants from the `orionis.metadata.framework` module,
14
- sets each constant in the Env storage using `Env.set`, and verifies that the operation succeeds.
15
- It then retrieves each constant using `Env.get` and asserts that the retrieved value matches
16
- the original constant.
17
-
18
- Parameters
19
- ----------
20
- self : TestServicesEnvironment
21
- The test case instance.
22
-
23
- Returns
24
- -------
25
- None
26
- This method does not return a value. Assertions are used to validate behavior.
27
-
28
- Notes
29
- -----
30
- - Ensures that `Env.set` returns True for each constant.
31
- - Ensures that `Env.get` returns the correct value for each constant.
32
- """
33
- from orionis.metadata.framework import (
34
- NAME, VERSION, AUTHOR, AUTHOR_EMAIL, DESCRIPTION,
35
- SKELETON, FRAMEWORK, DOCS, API, PYTHON_REQUIRES
36
- )
37
-
38
- # Prepare a dictionary of constant names and their values
39
- constants = {
40
- "NAME": NAME,
41
- "VERSION": VERSION,
42
- "AUTHOR": AUTHOR,
43
- "AUTHOR_EMAIL": AUTHOR_EMAIL,
44
- "DESCRIPTION": DESCRIPTION,
45
- "SKELETON": SKELETON,
46
- "FRAMEWORK": FRAMEWORK,
47
- "DOCS": DOCS,
48
- "API": API,
49
- "PYTHON_REQUIRES": PYTHON_REQUIRES
50
- }
51
-
52
- # Set each constant in the environment and assert the operation succeeds
53
- for key, value in constants.items():
54
- result = Env.set(key, value)
55
- self.assertTrue(result)
56
-
57
- # Retrieve each constant and assert the value matches the original
58
- for key, value in constants.items():
59
- retrieved = Env.get(key)
60
- self.assertEqual(retrieved, value)
61
-
62
- async def testGetNonExistentKey(self):
63
- """
64
- Test the behavior of `Env.get` when retrieving a non-existent environment key.
65
-
66
- This test verifies that attempting to retrieve a value for a key that has not been set
67
- in the environment returns `None`. This ensures that the environment behaves as expected
68
- when queried for missing keys.
69
-
70
- Parameters
71
- ----------
72
- self : TestServicesEnvironment
73
- The test case instance.
74
-
75
- Returns
76
- -------
77
- None
78
- This method does not return a value. Assertions are used to validate that `Env.get`
79
- returns `None` for a non-existent key.
80
-
81
- Notes
82
- -----
83
- - Ensures that `Env.get` returns `None` when the specified key does not exist in the environment.
84
- """
85
-
86
- # Attempt to retrieve a value for a key that has not been set.
87
- self.assertIsNone(Env.get("NON_EXISTENT_KEY"))
88
-
89
- async def testDotEnvSetAndGetWithType(self):
90
- """
91
- Test DotEnv.set and DotEnv.get with explicit EnvironmentValueType for various data types.
92
-
93
- This test verifies that the `DotEnv` class correctly stores and retrieves environment variables
94
- when an explicit `EnvironmentValueType` is provided. For each supported data type, the test sets
95
- a value using `DotEnv.set` with the corresponding `EnvironmentValueType`, then retrieves it using
96
- `DotEnv.get` and asserts that the returned value is correctly prefixed or formatted according to
97
- the specified type.
98
-
99
- Parameters
100
- ----------
101
- self : TestServicesEnvironment
102
- The test case instance.
103
-
104
- Returns
105
- -------
106
- None
107
- This method does not return a value. Assertions are used to validate the correct behavior
108
- of `DotEnv.set` and `DotEnv.get` with explicit type information.
109
-
110
- Notes
111
- -----
112
- - Ensures that values are stored and retrieved with the correct type prefixes or formatting.
113
- - Covers all supported types: PATH, STR, INT, FLOAT, BOOL, LIST, DICT, TUPLE, SET, BASE64.
114
- """
115
-
116
- env = DotEnv()
117
-
118
- # Set and assert a PATH value with explicit type
119
- env.set("CAST_EXAMPLE_PATH", '/tests', EnvironmentValueType.PATH)
120
- self.assertTrue(env.get("CAST_EXAMPLE_PATH").endswith('/tests'))
121
-
122
- # Set and assert a string value with explicit type
123
- env.set("CAST_EXAMPLE_STR", 'hello', EnvironmentValueType.STR)
124
- self.assertEqual(env.get("CAST_EXAMPLE_STR"), "hello")
125
-
126
- # Set and assert an integer value with explicit type
127
- env.set("CAST_EXAMPLE_INT", 123, EnvironmentValueType.INT)
128
- self.assertEqual(env.get("CAST_EXAMPLE_INT"), 123)
129
-
130
- # Set and assert a float value with explicit type
131
- env.set("CAST_EXAMPLE_FLOAT", 3.14, EnvironmentValueType.FLOAT)
132
- self.assertEqual(env.get("CAST_EXAMPLE_FLOAT"), 3.14)
133
-
134
- # Set and assert a boolean value with explicit type
135
- env.set("CAST_EXAMPLE_BOOL", True, EnvironmentValueType.BOOL)
136
- self.assertEqual(env.get("CAST_EXAMPLE_BOOL"), True)
137
-
138
- # Set and assert a list value with explicit type
139
- env.set("CAST_EXAMPLE_LIST", [1, 2, 3], EnvironmentValueType.LIST)
140
- self.assertEqual(env.get("CAST_EXAMPLE_LIST"), [1, 2, 3])
141
-
142
- # Set and assert a dictionary value with explicit type
143
- env.set("CAST_EXAMPLE_DICT", {"a": 1, "b": 2}, EnvironmentValueType.DICT)
144
- self.assertEqual(env.get("CAST_EXAMPLE_DICT"), {"a": 1, "b": 2})
145
-
146
- # Set and assert a tuple value with explicit type
147
- env.set("CAST_EXAMPLE_TUPLE", (1, 2), EnvironmentValueType.TUPLE)
148
- self.assertEqual(env.get("CAST_EXAMPLE_TUPLE"), (1, 2))
149
-
150
- # Set and assert a set value with explicit type
151
- env.set("CAST_EXAMPLE_SET", {1, 2, 3}, EnvironmentValueType.SET)
152
- self.assertEqual(env.get("CAST_EXAMPLE_SET"), {1, 2, 3})
153
-
154
- # Set and assert a base64 value with explicit type
155
- ramdon_text = SecureKeyGenerator.generate()
156
- env.set("CAST_EXAMPLE_BASE64", ramdon_text, EnvironmentValueType.BASE64)
157
- self.assertEqual(env.get("CAST_EXAMPLE_BASE64"), ramdon_text)
158
-
159
- async def testDotEnvSetAndGetWithoutType(self):
160
- """
161
- Test DotEnv.set and DotEnv.get without explicit EnvironmentValueType for various data types.
162
-
163
- This test verifies that the `DotEnv` class can store and retrieve environment variables of different
164
- Python data types without specifying an explicit `EnvironmentValueType`. It checks that the values
165
- are stored and retrieved as their string representations, and asserts the correctness of the returned
166
- values for each data type.
167
-
168
- Parameters
169
- ----------
170
- self : TestServicesEnvironment
171
- The test case instance.
172
-
173
- Returns
174
- -------
175
- None
176
- This method does not return a value. Assertions are used to validate that the returned values
177
- from `DotEnv.get` match the expected string representations for each data type.
178
-
179
- Notes
180
- -----
181
- - Ensures that values are stored and retrieved as strings when no explicit type is provided.
182
- - Covers various data types: path, str, int, float, bool, list, dict, tuple, set, and base64.
183
- """
184
-
185
- env = DotEnv()
186
-
187
- # Set and get a path value without explicit type
188
- env.set("EXAMPLE_PATH", '/tests')
189
- self.assertEqual(env.get("EXAMPLE_PATH"), '/tests')
190
-
191
- # Set and get a string value without explicit type
192
- env.set("EXAMPLE_STR", 'hello')
193
- self.assertEqual(env.get("EXAMPLE_STR"), 'hello')
194
-
195
- # Set and get an integer value without explicit type
196
- env.set("EXAMPLE_INT", 123)
197
- self.assertEqual(env.get("EXAMPLE_INT"), 123)
198
-
199
- # Set and get a float value without explicit type
200
- env.set("EXAMPLE_FLOAT", 3.14)
201
- self.assertEqual(env.get("EXAMPLE_FLOAT"), 3.14)
202
-
203
- # Set and get a boolean value without explicit type
204
- env.set("EXAMPLE_BOOL", True)
205
- self.assertEqual(env.get("EXAMPLE_BOOL"), True)
206
-
207
- # Set and get a list value without explicit type
208
- env.set("EXAMPLE_LIST", [1, 2, 3])
209
- self.assertEqual(env.get("EXAMPLE_LIST"), [1, 2, 3])
210
-
211
- # Set and get a dictionary value without explicit type
212
- env.set("EXAMPLE_DICT", {"a": 1, "b": 2})
213
- self.assertEqual(env.get("EXAMPLE_DICT"), {"a": 1, "b": 2})
214
-
215
- # Set and get a tuple value without explicit type
216
- env.set("EXAMPLE_TUPLE", (1, 2))
217
- self.assertEqual(env.get("EXAMPLE_TUPLE"), (1, 2))
218
-
219
- # Set and get a set value without explicit type
220
- env.set("EXAMPLE_SET", {1, 2, 3})
221
- self.assertEqual(env.get("EXAMPLE_SET"), {1, 2, 3})
222
-
223
- # Set and get a base64 value without explicit type
224
- ramdon_text = SecureKeyGenerator.generate()
225
- env.set("EXAMPLE_BASE64", ramdon_text)
226
- self.assertEqual(env.get("EXAMPLE_BASE64"), ramdon_text)
File without changes
File without changes
@@ -1,30 +0,0 @@
1
- class FakeUser:
2
- """
3
- FakeUser is a mock class intended for testing purposes, simulating a user entity.
4
- Methods:
5
- __init__():
6
- Initializes the FakeUser instance and sets user_data to None.
7
- getUser(user_id):
8
- Retrieves user information based on the provided user ID.
9
- """
10
-
11
- def __init__(self):
12
- """
13
- Initializes the instance and sets the user_data attribute to None.
14
-
15
- Attributes:
16
- user_data (Any): Placeholder for user-specific data, initialized as None.
17
- """
18
- self.user_data = None
19
-
20
- def getUser(self, user_id):
21
- """
22
- Retrieve user information based on the provided user ID.
23
-
24
- Args:
25
- user_id: The unique identifier of the user.
26
-
27
- Returns:
28
- The user data associated with the given user ID.
29
- """
30
- return self.user_data
@@ -1,27 +0,0 @@
1
- from tests.services.introspection.dependencies.mocks.mock_user import FakeUser
2
- from tests.services.introspection.dependencies.mocks.mock_users_permissions import FakeUserWithPermissions
3
-
4
-
5
- class UserController:
6
- """
7
- UserController manages user-related operations, utilizing a user repository for data access.
8
- Methods:
9
- __init__(user_repository: FakeUser)
10
- Initializes the controller with a user repository.
11
- createUserWithPermissions(user_permissions: FakeUserWithPermissions, permissions: list[str]) -> FakeUserWithPermissions
12
- Adds a list of permissions to the given user_permissions object and returns it.
13
- """
14
-
15
- def __init__(self, user_repository: FakeUser):
16
- """
17
- Initializes the class with a user repository.
18
-
19
- Args:
20
- user_repository (FakeUser): An instance of FakeUser to be used as the user repository.
21
- """
22
- self.user_repository = user_repository
23
-
24
- def createUserWithPermissions(self, user_permissions: FakeUserWithPermissions, permissions: list[str]):
25
- for permission in permissions:
26
- user_permissions.addPermission(permission)
27
- return user_permissions