orionis 0.545.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 (162) hide show
  1. orionis/console/base/scheduler_event_listener.py +0 -17
  2. orionis/console/contracts/schedule_event_listener.py +0 -18
  3. orionis/console/request/cli_request.py +2 -2
  4. orionis/foundation/config/app/entities/app.py +3 -2
  5. orionis/foundation/config/app/enums/ciphers.py +5 -19
  6. orionis/foundation/config/session/entities/session.py +2 -2
  7. orionis/foundation/providers/cli_request_provider.py +44 -0
  8. orionis/metadata/framework.py +1 -1
  9. orionis/services/encrypter/encrypter.py +115 -0
  10. orionis/services/environment/dynamic/caster.py +35 -27
  11. orionis/services/environment/key/key_generator.py +32 -11
  12. {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/METADATA +1 -1
  13. {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/RECORD +17 -160
  14. {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/top_level.txt +0 -1
  15. tests/container/__init__.py +0 -0
  16. tests/container/context/__init__.py +0 -0
  17. tests/container/context/test_manager.py +0 -38
  18. tests/container/context/test_scope.py +0 -32
  19. tests/container/core/__init__.py +0 -0
  20. tests/container/core/test_advanced_async.py +0 -234
  21. tests/container/core/test_async_optimizations.py +0 -268
  22. tests/container/core/test_container.py +0 -453
  23. tests/container/core/test_singleton.py +0 -122
  24. tests/container/core/test_thread_safety.py +0 -90
  25. tests/container/entities/__init__.py +0 -0
  26. tests/container/entities/test_binding.py +0 -242
  27. tests/container/enums/__init__.py +0 -0
  28. tests/container/enums/test_lifetimes.py +0 -97
  29. tests/container/facades/__init__.py +0 -0
  30. tests/container/facades/test_facade.py +0 -78
  31. tests/container/mocks/__init__.py +0 -0
  32. tests/container/mocks/mock_advanced_async.py +0 -332
  33. tests/container/mocks/mock_async_optimizations.py +0 -407
  34. tests/container/mocks/mock_auto_resolution.py +0 -192
  35. tests/container/mocks/mock_complex_classes.py +0 -792
  36. tests/container/mocks/mock_simple_classes.py +0 -98
  37. tests/container/providers/__init__.py +0 -0
  38. tests/container/providers/test_providers.py +0 -55
  39. tests/container/validators/__init__.py +0 -0
  40. tests/container/validators/test_implements.py +0 -186
  41. tests/container/validators/test_is_abstract_class.py +0 -147
  42. tests/container/validators/test_is_callable.py +0 -102
  43. tests/container/validators/test_is_concrete_class.py +0 -160
  44. tests/container/validators/test_is_instance.py +0 -150
  45. tests/container/validators/test_is_not_subclass.py +0 -49
  46. tests/container/validators/test_is_subclass.py +0 -178
  47. tests/container/validators/test_is_valid_alias.py +0 -147
  48. tests/container/validators/test_lifetime.py +0 -106
  49. tests/example/__init__.py +0 -0
  50. tests/example/test_example.py +0 -725
  51. tests/foundation/__init__.py +0 -0
  52. tests/foundation/config/__init__.py +0 -0
  53. tests/foundation/config/app/__init__.py +0 -0
  54. tests/foundation/config/app/test_foundation_config_app.py +0 -262
  55. tests/foundation/config/auth/__init__.py +0 -0
  56. tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
  57. tests/foundation/config/cache/__init__.py +0 -0
  58. tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
  59. tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
  60. tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
  61. tests/foundation/config/cors/__init__.py +0 -0
  62. tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
  63. tests/foundation/config/database/__init__.py +0 -0
  64. tests/foundation/config/database/test_foundation_config_database.py +0 -158
  65. tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
  66. tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
  67. tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
  68. tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
  69. tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
  70. tests/foundation/config/filesystems/__init__.py +0 -0
  71. tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
  72. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
  73. tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
  74. tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
  75. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
  76. tests/foundation/config/logging/__init__.py +0 -0
  77. tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
  78. tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
  79. tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
  80. tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
  81. tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
  82. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
  83. tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
  84. tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
  85. tests/foundation/config/mail/__init__.py +0 -0
  86. tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
  87. tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
  88. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
  89. tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
  90. tests/foundation/config/queue/__init__.py +0 -0
  91. tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
  92. tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
  93. tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
  94. tests/foundation/config/root/__init__.py +0 -0
  95. tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
  96. tests/foundation/config/session/__init__.py +0 -0
  97. tests/foundation/config/session/test_foundation_config_session.py +0 -213
  98. tests/foundation/config/startup/__init__.py +0 -0
  99. tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
  100. tests/foundation/config/testing/__init__.py +0 -0
  101. tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
  102. tests/metadata/__init__.py +0 -0
  103. tests/metadata/test_metadata_framework.py +0 -140
  104. tests/metadata/test_metadata_package.py +0 -139
  105. tests/services/__init__.py +0 -0
  106. tests/services/asynchrony/__init__.py +0 -0
  107. tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
  108. tests/services/environment/__init__.py +0 -0
  109. tests/services/environment/test_services_environment.py +0 -226
  110. tests/services/introspection/__init__.py +0 -0
  111. tests/services/introspection/dependencies/__init__.py +0 -0
  112. tests/services/introspection/dependencies/mocks/__init__.py +0 -0
  113. tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
  114. tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
  115. tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
  116. tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
  117. tests/services/introspection/reflection/__init__.py +0 -0
  118. tests/services/introspection/reflection/mock/__init__.py +0 -0
  119. tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
  120. tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
  121. tests/services/introspection/reflection/test_reflection_callable.py +0 -206
  122. tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
  123. tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
  124. tests/services/introspection/reflection/test_reflection_module.py +0 -567
  125. tests/services/introspection/test_reflection.py +0 -462
  126. tests/services/log/__init__.py +0 -0
  127. tests/services/log/test_log.py +0 -97
  128. tests/services/system/__init__.py +0 -0
  129. tests/services/system/test_services_system_imports.py +0 -204
  130. tests/services/system/test_services_system_workers.py +0 -131
  131. tests/support/__init__.py +0 -0
  132. tests/support/entities/__init__.py +0 -0
  133. tests/support/entities/mock_dataclass.py +0 -40
  134. tests/support/entities/test_base.py +0 -64
  135. tests/support/patterns/__init__.py +0 -0
  136. tests/support/patterns/singleton/__init__.py +0 -0
  137. tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
  138. tests/support/standard/__init__.py +0 -0
  139. tests/support/standard/test_services_std.py +0 -226
  140. tests/support/wrapper/__init__.py +0 -0
  141. tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
  142. tests/testing/__init__.py +0 -0
  143. tests/testing/cases/__init__.py +0 -0
  144. tests/testing/cases/test_testing_asynchronous.py +0 -63
  145. tests/testing/cases/test_testing_synchronous.py +0 -57
  146. tests/testing/entities/__init__.py +0 -0
  147. tests/testing/entities/test_testing_result.py +0 -146
  148. tests/testing/enums/__init__.py +0 -0
  149. tests/testing/enums/test_testing_status.py +0 -63
  150. tests/testing/output/__init__.py +0 -0
  151. tests/testing/output/test_testing_dumper.py +0 -29
  152. tests/testing/output/test_testing_printer.py +0 -42
  153. tests/testing/records/__init__.py +0 -0
  154. tests/testing/records/test_testing_records.py +0 -171
  155. tests/testing/test_testing_unit.py +0 -164
  156. tests/testing/validators/__init__.py +0 -0
  157. tests/testing/validators/test_testing_validators.py +0 -392
  158. tests/testing/view/__init__.py +0 -0
  159. tests/testing/view/test_render.py +0 -30
  160. {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
  161. {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
  162. {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
@@ -1,98 +0,0 @@
1
- from abc import ABC, abstractmethod
2
-
3
- class ICar(ABC):
4
- """
5
- Interface for car objects.
6
-
7
- Defines the required methods for car objects, including starting and stopping the car.
8
-
9
- Methods
10
- -------
11
- start() -> str
12
- Start the car and return a message indicating the car has started.
13
- stop() -> str
14
- Stop the car and return a message indicating the car has stopped.
15
- """
16
-
17
- @abstractmethod
18
- def start(self) -> str:
19
- """
20
- Start the car.
21
-
22
- Returns
23
- -------
24
- str
25
- Message indicating the car has started.
26
- """
27
- pass
28
-
29
- @abstractmethod
30
- def stop(self) -> str:
31
- """
32
- Stop the car.
33
-
34
- Returns
35
- -------
36
- str
37
- Message indicating the car has stopped.
38
- """
39
- pass
40
-
41
- class Car(ICar):
42
- """
43
- Concrete implementation of the ICar interface.
44
-
45
- Parameters
46
- ----------
47
- brand : str, optional
48
- The brand of the car (default is 'a').
49
- model : str, optional
50
- The model of the car (default is 'b').
51
-
52
- Attributes
53
- ----------
54
- brand : str
55
- The brand of the car.
56
- model : str
57
- The model of the car.
58
- """
59
-
60
- def __init__(self, brand: str = 'a', model: str = 'b'):
61
- """
62
- Initialize a new Car instance with the specified brand and model.
63
-
64
- Parameters
65
- ----------
66
- brand : str, optional
67
- The brand of the car. Default is 'a'.
68
- model : str, optional
69
- The model of the car. Default is 'b'.
70
-
71
- Notes
72
- -----
73
- This constructor sets the brand and model attributes for the Car object.
74
- """
75
- self.brand = brand # Set the brand of the car
76
- self.model = model # Set the model of the car
77
-
78
- def start(self):
79
- """
80
- Start the car.
81
-
82
- Returns
83
- -------
84
- str
85
- Message indicating the car is starting.
86
- """
87
- return f"{self.brand} {self.model} is starting."
88
-
89
- def stop(self):
90
- """
91
- Stop the car.
92
-
93
- Returns
94
- -------
95
- str
96
- Message indicating the car is stopping.
97
- """
98
- return f"{self.brand} {self.model} is stopping."
File without changes
@@ -1,55 +0,0 @@
1
- import inspect
2
- from orionis.container.contracts.service_provider import IServiceProvider
3
- from orionis.container.providers.service_provider import ServiceProvider
4
- from orionis.test.cases.asynchronous import AsyncTestCase
5
-
6
- class TestServiceProviderMethods(AsyncTestCase):
7
-
8
- async def testMethodsExist(self):
9
- """
10
- Validates the implementation of required methods and inheritance in the ServiceProvider class.
11
-
12
- This test performs the following checks:
13
- - Verifies that the ServiceProvider class defines the '__init__', 'register', and 'boot' methods.
14
- - Ensures that the 'register' and 'boot' methods are asynchronous coroutine functions.
15
- - Confirms that ServiceProvider is a subclass of IServiceProvider.
16
-
17
- Parameters
18
- ----------
19
- None
20
-
21
- Returns
22
- -------
23
- None
24
- The method does not return any value. Assertions are used to validate class structure and method types.
25
- """
26
-
27
- # List of required methods and their associated class
28
- expected_methods = [
29
- ("__init__", ServiceProvider),
30
- ("register", ServiceProvider),
31
- ("boot", ServiceProvider),
32
- ]
33
-
34
- # Check that each required method exists in ServiceProvider
35
- for method_name, cls in expected_methods:
36
- self.assertTrue(
37
- hasattr(cls, method_name),
38
- f"Method '{method_name}' does not exist in {cls.__name__}."
39
- )
40
-
41
- # Ensure 'register' and 'boot' are asynchronous methods
42
- self.assertTrue(
43
- inspect.iscoroutinefunction(ServiceProvider.register),
44
- "'register' must be an async coroutine function."
45
- )
46
- self.assertTrue(
47
- inspect.iscoroutinefunction(ServiceProvider.boot),
48
- "'boot' must be an async coroutine function."
49
- )
50
-
51
- # Ensure ServiceProvider inherits from IServiceProvider
52
- self.assertTrue(
53
- issubclass(ServiceProvider, IServiceProvider),
54
- "ServiceProvider must inherit from IServiceProvider."
55
- )
File without changes
@@ -1,186 +0,0 @@
1
- from abc import ABC, abstractmethod
2
- from orionis.test.cases.asynchronous import AsyncTestCase
3
- from orionis.container.validators.implements import ImplementsAbstractMethods
4
- from orionis.container.exceptions.exception import OrionisContainerException
5
-
6
- class TestImplementsAbstractMethods(AsyncTestCase):
7
-
8
- async def asyncSetUp(self) -> None:
9
- """
10
- Set up test fixtures for ImplementsAbstractMethods validator tests.
11
-
12
- This method defines several abstract and concrete classes to be used in the test cases:
13
- - An abstract base class with two abstract methods.
14
- - A concrete class that correctly implements all abstract methods.
15
- - A concrete class that does not implement all abstract methods.
16
- - A non-abstract base class for negative test cases.
17
-
18
- The defined classes are assigned to instance attributes for use in subsequent tests.
19
-
20
- Returns
21
- -------
22
- None
23
- This method does not return any value.
24
- """
25
- # Define an abstract base class with two abstract methods
26
- class AbstractBase(ABC):
27
- @abstractmethod
28
- def abstract_method(self) -> None:
29
- pass
30
-
31
- @abstractmethod
32
- def another_abstract_method(self) -> str:
33
- pass
34
-
35
- # Concrete class that implements all abstract methods
36
- class ConcreteCorrect(AbstractBase):
37
- def abstract_method(self) -> None:
38
- pass
39
-
40
- def another_abstract_method(self) -> str:
41
- return "implemented"
42
-
43
- # Concrete class that does not implement all abstract methods
44
- class ConcreteIncomplete(AbstractBase):
45
- def abstract_method(self) -> None:
46
- pass
47
-
48
- # Non-abstract base class for negative test cases
49
- class NonAbstractBase:
50
- def regular_method(self) -> None:
51
- pass
52
-
53
- # Assign classes to instance attributes for use in tests
54
- self.AbstractBase = AbstractBase
55
- self.ConcreteCorrect = ConcreteCorrect
56
- self.ConcreteIncomplete = ConcreteIncomplete
57
- self.NonAbstractBase = NonAbstractBase
58
-
59
- async def testValidImplementation(self) -> None:
60
- """
61
- Test that validation passes when all abstract methods are implemented.
62
-
63
- Returns
64
- -------
65
- None
66
- This method does not return any value.
67
- """
68
- # Test with class
69
- ImplementsAbstractMethods(
70
- abstract=self.AbstractBase,
71
- concrete=self.ConcreteCorrect
72
- )
73
-
74
- # Test with instance
75
- instance = self.ConcreteCorrect()
76
- ImplementsAbstractMethods(
77
- abstract=self.AbstractBase,
78
- instance=instance
79
- )
80
-
81
- async def testIncompleteImplementation(self) -> None:
82
- """
83
- Test that validation fails when not all abstract methods are implemented.
84
-
85
- Returns
86
- -------
87
- None
88
- This method does not return any value.
89
- """
90
- # Test with class missing an abstract method
91
- with self.assertRaises(OrionisContainerException) as context:
92
- ImplementsAbstractMethods(
93
- abstract=self.AbstractBase,
94
- concrete=self.ConcreteIncomplete
95
- )
96
-
97
- self.assertIn("does not implement the following abstract methods", str(context.exception))
98
- self.assertIn("another_abstract_method", str(context.exception))
99
-
100
- # Test with instance missing an abstract method
101
- with self.assertRaises(TypeError):
102
- ImplementsAbstractMethods(
103
- abstract=self.AbstractBase,
104
- instance=self.ConcreteIncomplete()
105
- )
106
-
107
- async def testMissingAbstractClass(self) -> None:
108
- """
109
- Test that validation fails when no abstract class is provided.
110
-
111
- Returns
112
- -------
113
- None
114
- This method does not return any value.
115
- """
116
- # Should raise exception if abstract class is not provided
117
- with self.assertRaises(OrionisContainerException) as context:
118
- ImplementsAbstractMethods(
119
- concrete=self.ConcreteCorrect
120
- )
121
-
122
- self.assertIn("Abstract class must be provided", str(context.exception))
123
-
124
- async def testMissingConcreteImplementation(self) -> None:
125
- """
126
- Test that validation fails when neither concrete class nor instance is provided.
127
-
128
- Returns
129
- -------
130
- None
131
- This method does not return any value.
132
- """
133
- # Should raise exception if neither concrete nor instance is provided
134
- with self.assertRaises(OrionisContainerException) as context:
135
- ImplementsAbstractMethods(
136
- abstract=self.AbstractBase
137
- )
138
-
139
- self.assertIn("Either concrete class or instance must be provided", str(context.exception))
140
-
141
- async def testNonAbstractClass(self) -> None:
142
- """
143
- Test that validation fails when the provided abstract class has no abstract methods.
144
-
145
- Returns
146
- -------
147
- None
148
- This method does not return any value.
149
- """
150
- # Should raise exception if abstract class does not define any abstract methods
151
- with self.assertRaises(OrionisContainerException) as context:
152
- ImplementsAbstractMethods(
153
- abstract=self.NonAbstractBase,
154
- concrete=self.ConcreteCorrect
155
- )
156
-
157
- self.assertIn("does not define any abstract methods", str(context.exception))
158
-
159
- async def testRenamedAbstractMethods(self) -> None:
160
- """
161
- Test handling of renamed abstract methods with class name prefixes.
162
-
163
- This test verifies that the validator correctly handles cases where abstract methods
164
- are renamed with class name prefixes in the concrete implementation.
165
-
166
- Returns
167
- -------
168
- None
169
- This method does not return any value.
170
- """
171
- # Define an abstract class with a prefixed abstract method
172
- class AbstractWithPrefix(ABC):
173
- @abstractmethod
174
- def _AbstractWithPrefix_method(self) -> None:
175
- pass
176
-
177
- # Concrete class with a similarly prefixed method
178
- class ConcreteWithPrefix:
179
- def _ConcreteWithPrefix_method(self) -> None:
180
- pass
181
-
182
- # Should pass validation because the method is renamed according to class name
183
- ImplementsAbstractMethods(
184
- abstract=AbstractWithPrefix,
185
- concrete=ConcreteWithPrefix
186
- )
@@ -1,147 +0,0 @@
1
- from abc import ABC, abstractmethod
2
- import unittest.mock
3
- from orionis.container.validators.is_abstract_class import IsAbstractClass
4
- from orionis.container.exceptions.type import OrionisContainerTypeError
5
- from orionis.test.cases.asynchronous import AsyncTestCase
6
-
7
- class TestIsAbstractClass(AsyncTestCase):
8
-
9
- async def testValidAbstractClass(self) -> None:
10
- """
11
- Validates that the IsAbstractClass validator accepts a valid abstract class.
12
-
13
- This test creates an abstract class using Python's `abc` module and verifies
14
- that the validator does not raise an exception when provided with a proper abstract class.
15
-
16
- Returns
17
- -------
18
- None
19
- This method does not return anything. It asserts correct behavior via exceptions and mocks.
20
- """
21
- # Create an abstract class with an abstract method
22
- class AbstractBase(ABC):
23
- @abstractmethod
24
- def abstract_method(self):
25
- pass
26
-
27
- # Patch the reflection method to ensure it is called correctly
28
- with unittest.mock.patch('orionis.services.introspection.abstract.reflection.ReflectionAbstract.ensureIsAbstractClass') as mock_ensure:
29
- IsAbstractClass(AbstractBase, "singleton")
30
- # Assert that the reflection method was called with the correct class
31
- mock_ensure.assert_called_once_with(AbstractBase)
32
-
33
- async def testNonAbstractClass(self) -> None:
34
- """
35
- Validates that the IsAbstractClass validator raises an error for non-abstract classes.
36
-
37
- This test provides a concrete class and mocks the reflection method to raise a ValueError,
38
- ensuring that the validator responds with an OrionisContainerTypeError.
39
-
40
- Returns
41
- -------
42
- None
43
- This method does not return anything. It asserts correct behavior via exceptions and mocks.
44
- """
45
- # Define a concrete class with no abstract methods
46
- class ConcreteClass:
47
- def some_method(self):
48
- pass
49
-
50
- # Patch the reflection method to simulate failure for non-abstract classes
51
- with unittest.mock.patch(
52
- 'orionis.services.introspection.abstract.reflection.ReflectionAbstract.ensureIsAbstractClass',
53
- side_effect=ValueError("Not an abstract class")
54
- ) as mock_ensure:
55
- # Assert that the validator raises the expected error
56
- with self.assertRaises(OrionisContainerTypeError) as context:
57
- IsAbstractClass(ConcreteClass, "scoped")
58
-
59
- self.assertIn("Unexpected error registering scoped service", str(context.exception))
60
- mock_ensure.assert_called_once_with(ConcreteClass)
61
-
62
- async def testWithInheritedAbstractClass(self) -> None:
63
- """
64
- Validates that the IsAbstractClass validator accepts classes that inherit from abstract classes and remain abstract.
65
-
66
- This test creates a base abstract class and a derived abstract class, ensuring that the validator
67
- does not raise an exception when the derived class is still abstract.
68
-
69
- Returns
70
- -------
71
- None
72
- This method does not return anything. It asserts correct behavior via exceptions and mocks.
73
- """
74
- # Define a base abstract class
75
- class BaseAbstract(ABC):
76
- @abstractmethod
77
- def method1(self):
78
- pass
79
-
80
- # Define a derived abstract class that adds another abstract method
81
- class DerivedAbstract(BaseAbstract):
82
- @abstractmethod
83
- def method2(self):
84
- pass
85
-
86
- # Patch the reflection method to ensure it is called correctly
87
- with unittest.mock.patch('orionis.services.introspection.abstract.reflection.ReflectionAbstract.ensureIsAbstractClass') as mock_ensure:
88
- IsAbstractClass(DerivedAbstract, "transient")
89
- mock_ensure.assert_called_once_with(DerivedAbstract)
90
-
91
- async def testWithConcreteImplementation(self) -> None:
92
- """
93
- Validates that the IsAbstractClass validator raises an error for concrete implementations of abstract classes.
94
-
95
- This test creates a concrete class that implements all abstract methods and mocks the reflection method
96
- to raise a TypeError, ensuring that the validator responds with an OrionisContainerTypeError.
97
-
98
- Returns
99
- -------
100
- None
101
- This method does not return anything. It asserts correct behavior via exceptions and mocks.
102
- """
103
- # Define a base abstract class
104
- class BaseAbstract(ABC):
105
- @abstractmethod
106
- def method(self):
107
- pass
108
-
109
- # Define a concrete class that implements the abstract method
110
- class ConcreteImplementation(BaseAbstract):
111
- def method(self):
112
- return "Implemented"
113
-
114
- # Patch the reflection method to simulate failure for concrete classes
115
- with unittest.mock.patch(
116
- 'orionis.services.introspection.abstract.reflection.ReflectionAbstract.ensureIsAbstractClass',
117
- side_effect=TypeError("Not an abstract class")
118
- ) as mock_ensure:
119
- # Assert that the validator raises the expected error
120
- with self.assertRaises(OrionisContainerTypeError) as context:
121
- IsAbstractClass(ConcreteImplementation, "singleton")
122
-
123
- self.assertIn("Unexpected error registering singleton service", str(context.exception))
124
- mock_ensure.assert_called_once_with(ConcreteImplementation)
125
-
126
- async def testWithNonClassTypes(self) -> None:
127
- """
128
- Validates that the IsAbstractClass validator raises an error for non-class types.
129
-
130
- This test iterates over several primitive and non-class values, mocking the reflection method
131
- to raise a TypeError, and ensures that the validator responds with an OrionisContainerTypeError.
132
-
133
- Returns
134
- -------
135
- None
136
- This method does not return anything. It asserts correct behavior via exceptions and mocks.
137
- """
138
- # Test with various non-class types
139
- for invalid_value in [1, "string", [], {}, lambda: None]:
140
- # Patch the reflection method to simulate failure for non-class types
141
- with unittest.mock.patch(
142
- 'orionis.services.introspection.abstract.reflection.ReflectionAbstract.ensureIsAbstractClass',
143
- side_effect=TypeError(f"{type(invalid_value)} is not a class")
144
- ) as mock_ensure:
145
- # Assert that the validator raises the expected error
146
- with self.assertRaises(OrionisContainerTypeError):
147
- IsAbstractClass(invalid_value, "transient")
@@ -1,102 +0,0 @@
1
- from orionis.container.validators.is_callable import IsCallable
2
- from orionis.container.exceptions.type import OrionisContainerTypeError
3
- from orionis.test.cases.asynchronous import AsyncTestCase
4
-
5
- class TestIsCallable(AsyncTestCase):
6
-
7
- async def testValidCallables(self) -> None:
8
- """
9
- Validate that IsCallable accepts valid callable objects without raising exceptions.
10
-
11
- This test covers various types of callables, including functions, classes with
12
- a __call__ method, lambda functions, and built-in functions.
13
-
14
- Returns
15
- -------
16
- None
17
- This method does not return any value. It asserts that no exception is raised
18
- for valid callables.
19
- """
20
- def simple_function():
21
- pass # Simple user-defined function
22
-
23
- class ClassWithCall:
24
- def __call__(self):
25
- pass # Class instance with __call__ method
26
-
27
- lambda_func = lambda x: x # Lambda function
28
-
29
- # These should not raise exceptions as they are all callable
30
- IsCallable(simple_function)
31
- IsCallable(ClassWithCall())
32
- IsCallable(lambda_func)
33
- IsCallable(len)
34
- IsCallable(print)
35
-
36
- async def testNonCallables(self) -> None:
37
- """
38
- Ensure that IsCallable raises OrionisContainerTypeError for non-callable objects.
39
-
40
- This test iterates over a list of non-callable objects and asserts that the
41
- expected exception is raised with the correct error message.
42
-
43
- Returns
44
- -------
45
- None
46
- This method does not return any value. It asserts that exceptions are raised
47
- for non-callable objects.
48
- """
49
- non_callables = [
50
- 42, # Integer
51
- "string", # String
52
- [1, 2, 3], # List
53
- {"key": "value"}, # Dictionary
54
- None, # NoneType
55
- True, # Boolean
56
- (1, 2, 3) # Tuple
57
- ]
58
-
59
- for value in non_callables:
60
- # Assert that IsCallable raises the expected exception for non-callables
61
- with self.assertRaises(OrionisContainerTypeError) as context:
62
- IsCallable(value)
63
- expected_message = f"Expected a callable type, but got {type(value).__name__} instead."
64
- self.assertEqual(str(context.exception), expected_message)
65
-
66
- async def testClassesAsCallables(self) -> None:
67
- """
68
- Verify that classes themselves are considered callable by IsCallable.
69
-
70
- Classes are callable because they can be instantiated. This test ensures
71
- that passing a class to IsCallable does not raise an exception.
72
-
73
- Returns
74
- -------
75
- None
76
- This method does not return any value. It asserts that no exception is raised
77
- for classes.
78
- """
79
- class SimpleClass:
80
- pass # Simple class definition
81
-
82
- # Should not raise an exception since classes are callable
83
- IsCallable(SimpleClass)
84
-
85
- async def testBuiltinFunctions(self) -> None:
86
- """
87
- Confirm that built-in functions are recognized as callable by IsCallable.
88
-
89
- This test checks several built-in functions to ensure they are accepted
90
- without raising exceptions.
91
-
92
- Returns
93
- -------
94
- None
95
- This method does not return any value. It asserts that no exception is raised
96
- for built-in functions.
97
- """
98
- # These built-in functions should not raise exceptions
99
- IsCallable(sum)
100
- IsCallable(map)
101
- IsCallable(filter)
102
- IsCallable(sorted)