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.
- orionis/console/base/scheduler_event_listener.py +0 -17
- orionis/console/contracts/schedule_event_listener.py +0 -18
- orionis/console/request/cli_request.py +2 -2
- orionis/foundation/config/app/entities/app.py +3 -2
- orionis/foundation/config/app/enums/ciphers.py +5 -19
- orionis/foundation/config/session/entities/session.py +2 -2
- orionis/foundation/providers/cli_request_provider.py +44 -0
- orionis/metadata/framework.py +1 -1
- orionis/services/encrypter/encrypter.py +115 -0
- orionis/services/environment/dynamic/caster.py +35 -27
- orionis/services/environment/key/key_generator.py +32 -11
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/METADATA +1 -1
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/RECORD +17 -160
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/top_level.txt +0 -1
- tests/container/__init__.py +0 -0
- tests/container/context/__init__.py +0 -0
- tests/container/context/test_manager.py +0 -38
- tests/container/context/test_scope.py +0 -32
- tests/container/core/__init__.py +0 -0
- tests/container/core/test_advanced_async.py +0 -234
- tests/container/core/test_async_optimizations.py +0 -268
- tests/container/core/test_container.py +0 -453
- tests/container/core/test_singleton.py +0 -122
- tests/container/core/test_thread_safety.py +0 -90
- tests/container/entities/__init__.py +0 -0
- tests/container/entities/test_binding.py +0 -242
- tests/container/enums/__init__.py +0 -0
- tests/container/enums/test_lifetimes.py +0 -97
- tests/container/facades/__init__.py +0 -0
- tests/container/facades/test_facade.py +0 -78
- tests/container/mocks/__init__.py +0 -0
- tests/container/mocks/mock_advanced_async.py +0 -332
- tests/container/mocks/mock_async_optimizations.py +0 -407
- tests/container/mocks/mock_auto_resolution.py +0 -192
- tests/container/mocks/mock_complex_classes.py +0 -792
- tests/container/mocks/mock_simple_classes.py +0 -98
- tests/container/providers/__init__.py +0 -0
- tests/container/providers/test_providers.py +0 -55
- tests/container/validators/__init__.py +0 -0
- tests/container/validators/test_implements.py +0 -186
- tests/container/validators/test_is_abstract_class.py +0 -147
- tests/container/validators/test_is_callable.py +0 -102
- tests/container/validators/test_is_concrete_class.py +0 -160
- tests/container/validators/test_is_instance.py +0 -150
- tests/container/validators/test_is_not_subclass.py +0 -49
- tests/container/validators/test_is_subclass.py +0 -178
- tests/container/validators/test_is_valid_alias.py +0 -147
- tests/container/validators/test_lifetime.py +0 -106
- tests/example/__init__.py +0 -0
- tests/example/test_example.py +0 -725
- tests/foundation/__init__.py +0 -0
- tests/foundation/config/__init__.py +0 -0
- tests/foundation/config/app/__init__.py +0 -0
- tests/foundation/config/app/test_foundation_config_app.py +0 -262
- tests/foundation/config/auth/__init__.py +0 -0
- tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
- tests/foundation/config/cache/__init__.py +0 -0
- tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
- tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
- tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
- tests/foundation/config/cors/__init__.py +0 -0
- tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
- tests/foundation/config/database/__init__.py +0 -0
- tests/foundation/config/database/test_foundation_config_database.py +0 -158
- tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
- tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
- tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
- tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
- tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
- tests/foundation/config/filesystems/__init__.py +0 -0
- tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
- tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
- tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
- tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
- tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
- tests/foundation/config/logging/__init__.py +0 -0
- tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
- tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
- tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
- tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
- tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
- tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
- tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
- tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
- tests/foundation/config/mail/__init__.py +0 -0
- tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
- tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
- tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
- tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
- tests/foundation/config/queue/__init__.py +0 -0
- tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
- tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
- tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
- tests/foundation/config/root/__init__.py +0 -0
- tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
- tests/foundation/config/session/__init__.py +0 -0
- tests/foundation/config/session/test_foundation_config_session.py +0 -213
- tests/foundation/config/startup/__init__.py +0 -0
- tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
- tests/foundation/config/testing/__init__.py +0 -0
- tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
- tests/metadata/__init__.py +0 -0
- tests/metadata/test_metadata_framework.py +0 -140
- tests/metadata/test_metadata_package.py +0 -139
- tests/services/__init__.py +0 -0
- tests/services/asynchrony/__init__.py +0 -0
- tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
- tests/services/environment/__init__.py +0 -0
- tests/services/environment/test_services_environment.py +0 -226
- tests/services/introspection/__init__.py +0 -0
- tests/services/introspection/dependencies/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
- tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
- tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
- tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
- tests/services/introspection/reflection/__init__.py +0 -0
- tests/services/introspection/reflection/mock/__init__.py +0 -0
- tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
- tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
- tests/services/introspection/reflection/test_reflection_callable.py +0 -206
- tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
- tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
- tests/services/introspection/reflection/test_reflection_module.py +0 -567
- tests/services/introspection/test_reflection.py +0 -462
- tests/services/log/__init__.py +0 -0
- tests/services/log/test_log.py +0 -97
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +0 -204
- tests/services/system/test_services_system_workers.py +0 -131
- tests/support/__init__.py +0 -0
- tests/support/entities/__init__.py +0 -0
- tests/support/entities/mock_dataclass.py +0 -40
- tests/support/entities/test_base.py +0 -64
- tests/support/patterns/__init__.py +0 -0
- tests/support/patterns/singleton/__init__.py +0 -0
- tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
- tests/support/standard/__init__.py +0 -0
- tests/support/standard/test_services_std.py +0 -226
- tests/support/wrapper/__init__.py +0 -0
- tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
- tests/testing/__init__.py +0 -0
- tests/testing/cases/__init__.py +0 -0
- tests/testing/cases/test_testing_asynchronous.py +0 -63
- tests/testing/cases/test_testing_synchronous.py +0 -57
- tests/testing/entities/__init__.py +0 -0
- tests/testing/entities/test_testing_result.py +0 -146
- tests/testing/enums/__init__.py +0 -0
- tests/testing/enums/test_testing_status.py +0 -63
- tests/testing/output/__init__.py +0 -0
- tests/testing/output/test_testing_dumper.py +0 -29
- tests/testing/output/test_testing_printer.py +0 -42
- tests/testing/records/__init__.py +0 -0
- tests/testing/records/test_testing_records.py +0 -171
- tests/testing/test_testing_unit.py +0 -164
- tests/testing/validators/__init__.py +0 -0
- tests/testing/validators/test_testing_validators.py +0 -392
- tests/testing/view/__init__.py +0 -0
- tests/testing/view/test_render.py +0 -30
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from orionis.container.validators.is_concrete_class import IsConcreteClass
|
|
3
|
-
from orionis.container.exceptions.type import OrionisContainerTypeError
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestIsConcreteClass(AsyncTestCase):
|
|
7
|
-
|
|
8
|
-
async def testValidConcreteClasses(self) -> None:
|
|
9
|
-
"""
|
|
10
|
-
Test that validation passes for valid concrete classes.
|
|
11
|
-
|
|
12
|
-
This test verifies that the `IsConcreteClass` validator does not raise an exception
|
|
13
|
-
when provided with classes that are concrete (i.e., not abstract and fully implemented).
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
self : TestIsConcreteClass
|
|
18
|
-
The test case instance.
|
|
19
|
-
|
|
20
|
-
Returns
|
|
21
|
-
-------
|
|
22
|
-
None
|
|
23
|
-
This method does not return anything. It asserts that no exception is raised for valid concrete classes.
|
|
24
|
-
"""
|
|
25
|
-
class SimpleClass:
|
|
26
|
-
pass # A basic concrete class with no methods
|
|
27
|
-
|
|
28
|
-
class ClassWithInit:
|
|
29
|
-
def __init__(self, value):
|
|
30
|
-
self.value = value # Concrete class with an initializer
|
|
31
|
-
|
|
32
|
-
# These should not raise exceptions since both are concrete classes
|
|
33
|
-
IsConcreteClass(SimpleClass, "singleton")
|
|
34
|
-
IsConcreteClass(ClassWithInit, "transient")
|
|
35
|
-
|
|
36
|
-
async def testAbstractClasses(self) -> None:
|
|
37
|
-
"""
|
|
38
|
-
Test that validation fails for abstract classes.
|
|
39
|
-
|
|
40
|
-
This test ensures that the `IsConcreteClass` validator raises an `OrionisContainerTypeError`
|
|
41
|
-
when provided with an abstract class.
|
|
42
|
-
|
|
43
|
-
Parameters
|
|
44
|
-
----------
|
|
45
|
-
self : TestIsConcreteClass
|
|
46
|
-
The test case instance.
|
|
47
|
-
|
|
48
|
-
Returns
|
|
49
|
-
-------
|
|
50
|
-
None
|
|
51
|
-
This method does not return anything. It asserts that an exception is raised for abstract classes.
|
|
52
|
-
"""
|
|
53
|
-
class AbstractBase(ABC):
|
|
54
|
-
@abstractmethod
|
|
55
|
-
def abstract_method(self):
|
|
56
|
-
pass # Abstract method, making this class abstract
|
|
57
|
-
|
|
58
|
-
# Should raise an exception because AbstractBase is abstract
|
|
59
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
60
|
-
IsConcreteClass(AbstractBase, "scoped")
|
|
61
|
-
self.assertIn("Unexpected error registering scoped service", str(context.exception))
|
|
62
|
-
|
|
63
|
-
async def testNonClassTypes(self) -> None:
|
|
64
|
-
"""
|
|
65
|
-
Test that validation fails for non-class types.
|
|
66
|
-
|
|
67
|
-
This test checks that the `IsConcreteClass` validator raises an `OrionisContainerTypeError`
|
|
68
|
-
when provided with values that are not classes (e.g., integers, strings, functions).
|
|
69
|
-
|
|
70
|
-
Parameters
|
|
71
|
-
----------
|
|
72
|
-
self : TestIsConcreteClass
|
|
73
|
-
The test case instance.
|
|
74
|
-
|
|
75
|
-
Returns
|
|
76
|
-
-------
|
|
77
|
-
None
|
|
78
|
-
This method does not return anything. It asserts that an exception is raised for non-class types.
|
|
79
|
-
"""
|
|
80
|
-
# Should raise an exception for integer input
|
|
81
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
82
|
-
IsConcreteClass(42, "singleton")
|
|
83
|
-
self.assertIn("Unexpected error registering singleton service", str(context.exception))
|
|
84
|
-
|
|
85
|
-
# Should raise an exception for string input
|
|
86
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
87
|
-
IsConcreteClass("string", "scoped")
|
|
88
|
-
self.assertIn("Unexpected error registering scoped service", str(context.exception))
|
|
89
|
-
|
|
90
|
-
# Should raise an exception for function input
|
|
91
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
92
|
-
IsConcreteClass(lambda x: x, "transient")
|
|
93
|
-
self.assertIn("Unexpected error registering transient service", str(context.exception))
|
|
94
|
-
|
|
95
|
-
async def testInheritedConcreteClasses(self) -> None:
|
|
96
|
-
"""
|
|
97
|
-
Test that validation passes for concrete classes that inherit from abstract classes.
|
|
98
|
-
|
|
99
|
-
This test verifies that the `IsConcreteClass` validator does not raise an exception
|
|
100
|
-
for classes that inherit from abstract base classes but implement all abstract methods,
|
|
101
|
-
making them concrete.
|
|
102
|
-
|
|
103
|
-
Parameters
|
|
104
|
-
----------
|
|
105
|
-
self : TestIsConcreteClass
|
|
106
|
-
The test case instance.
|
|
107
|
-
|
|
108
|
-
Returns
|
|
109
|
-
-------
|
|
110
|
-
None
|
|
111
|
-
This method does not return anything. It asserts that no exception is raised for concrete subclasses.
|
|
112
|
-
"""
|
|
113
|
-
class AbstractBase(ABC):
|
|
114
|
-
@abstractmethod
|
|
115
|
-
def abstract_method(self):
|
|
116
|
-
pass # Abstract method
|
|
117
|
-
|
|
118
|
-
class ConcreteImplementation(AbstractBase):
|
|
119
|
-
def abstract_method(self):
|
|
120
|
-
return "Implemented" # Implements all abstract methods
|
|
121
|
-
|
|
122
|
-
# Should not raise an exception since all abstract methods are implemented
|
|
123
|
-
IsConcreteClass(ConcreteImplementation, "singleton")
|
|
124
|
-
|
|
125
|
-
async def testPartialImplementations(self) -> None:
|
|
126
|
-
"""
|
|
127
|
-
Test that validation fails for classes that don't implement all abstract methods.
|
|
128
|
-
|
|
129
|
-
This test ensures that the `IsConcreteClass` validator raises an `OrionisContainerTypeError`
|
|
130
|
-
when a class inherits from an abstract base class but does not implement all required abstract methods.
|
|
131
|
-
|
|
132
|
-
Parameters
|
|
133
|
-
----------
|
|
134
|
-
self : TestIsConcreteClass
|
|
135
|
-
The test case instance.
|
|
136
|
-
|
|
137
|
-
Returns
|
|
138
|
-
-------
|
|
139
|
-
None
|
|
140
|
-
This method does not return anything. It asserts that an exception is raised for partial implementations.
|
|
141
|
-
"""
|
|
142
|
-
class AbstractBase(ABC):
|
|
143
|
-
@abstractmethod
|
|
144
|
-
def method1(self):
|
|
145
|
-
pass
|
|
146
|
-
|
|
147
|
-
@abstractmethod
|
|
148
|
-
def method2(self):
|
|
149
|
-
pass
|
|
150
|
-
|
|
151
|
-
class PartialImplementation(AbstractBase):
|
|
152
|
-
def method1(self):
|
|
153
|
-
return "Implemented" # Only one abstract method is implemented
|
|
154
|
-
|
|
155
|
-
# method2 is not implemented, so this class remains abstract
|
|
156
|
-
|
|
157
|
-
# Should raise an exception since not all abstract methods are implemented
|
|
158
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
159
|
-
IsConcreteClass(PartialImplementation, "scoped")
|
|
160
|
-
self.assertIn("Unexpected error registering scoped service", str(context.exception))
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from orionis.container.validators.is_instance import IsInstance
|
|
3
|
-
from orionis.container.exceptions.type import OrionisContainerTypeError
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestIsInstance(AsyncTestCase):
|
|
7
|
-
|
|
8
|
-
async def testValidInstances(self) -> None:
|
|
9
|
-
"""
|
|
10
|
-
Validate that IsInstance accepts valid object instances.
|
|
11
|
-
|
|
12
|
-
This test checks that IsInstance does not raise an exception when provided with
|
|
13
|
-
instances of user-defined classes, including those with and without an __init__ method.
|
|
14
|
-
|
|
15
|
-
Returns
|
|
16
|
-
-------
|
|
17
|
-
None
|
|
18
|
-
This method does not return any value.
|
|
19
|
-
"""
|
|
20
|
-
# Custom class instance
|
|
21
|
-
class SimpleClass:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
# Class with __init__ method
|
|
25
|
-
class ClassWithInit:
|
|
26
|
-
def __init__(self, value):
|
|
27
|
-
self.value = value
|
|
28
|
-
|
|
29
|
-
# Should not raise an exception for valid instances
|
|
30
|
-
IsInstance(SimpleClass())
|
|
31
|
-
IsInstance(ClassWithInit(42))
|
|
32
|
-
|
|
33
|
-
async def testInvalidClasses(self) -> None:
|
|
34
|
-
"""
|
|
35
|
-
Ensure IsInstance raises an error when provided with class objects instead of instances.
|
|
36
|
-
|
|
37
|
-
This test verifies that passing class types (rather than instances) to IsInstance
|
|
38
|
-
results in an OrionisContainerTypeError.
|
|
39
|
-
|
|
40
|
-
Returns
|
|
41
|
-
-------
|
|
42
|
-
None
|
|
43
|
-
This method does not return any value.
|
|
44
|
-
"""
|
|
45
|
-
# Passing built-in type should raise an error
|
|
46
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
47
|
-
IsInstance(str)
|
|
48
|
-
self.assertIn("Error registering instance", str(context.exception))
|
|
49
|
-
|
|
50
|
-
# Passing user-defined class should raise an error
|
|
51
|
-
class TestClass:
|
|
52
|
-
pass
|
|
53
|
-
|
|
54
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
55
|
-
IsInstance(TestClass)
|
|
56
|
-
self.assertIn("Error registering instance", str(context.exception))
|
|
57
|
-
|
|
58
|
-
async def testAbstractClasses(self) -> None:
|
|
59
|
-
"""
|
|
60
|
-
Test IsInstance behavior with abstract classes and their concrete implementations.
|
|
61
|
-
|
|
62
|
-
This test ensures that abstract classes are not accepted as valid instances,
|
|
63
|
-
but instances of concrete subclasses are accepted.
|
|
64
|
-
|
|
65
|
-
Returns
|
|
66
|
-
-------
|
|
67
|
-
None
|
|
68
|
-
This method does not return any value.
|
|
69
|
-
"""
|
|
70
|
-
# Define an abstract base class
|
|
71
|
-
class AbstractBase(ABC):
|
|
72
|
-
@abstractmethod
|
|
73
|
-
def abstract_method(self):
|
|
74
|
-
pass
|
|
75
|
-
|
|
76
|
-
# Concrete implementation of the abstract base
|
|
77
|
-
class ConcreteImplementation(AbstractBase):
|
|
78
|
-
def abstract_method(self):
|
|
79
|
-
return "Implemented"
|
|
80
|
-
|
|
81
|
-
# Abstract class should raise an error
|
|
82
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
83
|
-
IsInstance(AbstractBase)
|
|
84
|
-
self.assertIn("Error registering instance", str(context.exception))
|
|
85
|
-
|
|
86
|
-
# Instance of concrete implementation should not raise an error
|
|
87
|
-
IsInstance(ConcreteImplementation())
|
|
88
|
-
|
|
89
|
-
async def testTypeObjects(self) -> None:
|
|
90
|
-
"""
|
|
91
|
-
Verify that IsInstance raises errors for type objects.
|
|
92
|
-
|
|
93
|
-
This test checks that passing type objects such as `type`, `int`, or `list`
|
|
94
|
-
to IsInstance results in an OrionisContainerTypeError.
|
|
95
|
-
|
|
96
|
-
Returns
|
|
97
|
-
-------
|
|
98
|
-
None
|
|
99
|
-
This method does not return any value.
|
|
100
|
-
"""
|
|
101
|
-
# Should raise error for built-in type objects
|
|
102
|
-
with self.assertRaises(OrionisContainerTypeError):
|
|
103
|
-
IsInstance(type)
|
|
104
|
-
|
|
105
|
-
with self.assertRaises(OrionisContainerTypeError):
|
|
106
|
-
IsInstance(int)
|
|
107
|
-
|
|
108
|
-
with self.assertRaises(OrionisContainerTypeError):
|
|
109
|
-
IsInstance(list)
|
|
110
|
-
|
|
111
|
-
async def testNoneValue(self) -> None:
|
|
112
|
-
"""
|
|
113
|
-
Test IsInstance validation with None value.
|
|
114
|
-
|
|
115
|
-
This test verifies that passing None to IsInstance raises an OrionisContainerTypeError,
|
|
116
|
-
even though None is a valid instance in Python.
|
|
117
|
-
|
|
118
|
-
Returns
|
|
119
|
-
-------
|
|
120
|
-
None
|
|
121
|
-
This method does not return any value.
|
|
122
|
-
"""
|
|
123
|
-
# Should raise error for None value
|
|
124
|
-
with self.assertRaises(OrionisContainerTypeError):
|
|
125
|
-
IsInstance(None)
|
|
126
|
-
|
|
127
|
-
async def testCallables(self) -> None:
|
|
128
|
-
"""
|
|
129
|
-
Test IsInstance validation with callable objects.
|
|
130
|
-
|
|
131
|
-
This test checks that passing function objects and lambda functions to IsInstance
|
|
132
|
-
raises an OrionisContainerTypeError, while passing their types also raises an error.
|
|
133
|
-
|
|
134
|
-
Returns
|
|
135
|
-
-------
|
|
136
|
-
None
|
|
137
|
-
This method does not return any value.
|
|
138
|
-
"""
|
|
139
|
-
# Define a function for testing
|
|
140
|
-
def test_function():
|
|
141
|
-
pass
|
|
142
|
-
|
|
143
|
-
# Should raise error for function and lambda instances
|
|
144
|
-
with self.assertRaises(OrionisContainerTypeError):
|
|
145
|
-
IsInstance(test_function)
|
|
146
|
-
IsInstance(lambda x: x * 2)
|
|
147
|
-
|
|
148
|
-
# Should raise error for type of function
|
|
149
|
-
with self.assertRaises(OrionisContainerTypeError):
|
|
150
|
-
IsInstance(type(test_function))
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
from abc import ABC
|
|
2
|
-
from orionis.container.validators.is_not_subclass import IsNotSubclass
|
|
3
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
-
|
|
5
|
-
class TestIsNotSubclass(AsyncTestCase):
|
|
6
|
-
|
|
7
|
-
async def testValidNonSubclass(self) -> None:
|
|
8
|
-
"""
|
|
9
|
-
Validate that `IsNotSubclass` does not raise an exception when the second argument
|
|
10
|
-
is not a subclass of the first argument.
|
|
11
|
-
|
|
12
|
-
This test covers various scenarios including unrelated abstract classes, concrete classes,
|
|
13
|
-
and built-in types to ensure that only true subclass relationships trigger validation errors.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
self : TestIsNotSubclass
|
|
18
|
-
The test case instance.
|
|
19
|
-
|
|
20
|
-
Returns
|
|
21
|
-
-------
|
|
22
|
-
None
|
|
23
|
-
This method does not return any value.
|
|
24
|
-
|
|
25
|
-
Raises
|
|
26
|
-
------
|
|
27
|
-
AssertionError
|
|
28
|
-
If `IsNotSubclass` raises an exception for valid non-subclass relationships.
|
|
29
|
-
"""
|
|
30
|
-
# Define abstract base classes
|
|
31
|
-
class AbstractClass1(ABC):
|
|
32
|
-
pass
|
|
33
|
-
|
|
34
|
-
class AbstractClass2(ABC):
|
|
35
|
-
pass
|
|
36
|
-
|
|
37
|
-
# Define concrete classes inheriting from abstract base classes
|
|
38
|
-
class ConcreteClass1(AbstractClass1):
|
|
39
|
-
pass
|
|
40
|
-
|
|
41
|
-
class ConcreteClass2(AbstractClass2):
|
|
42
|
-
pass
|
|
43
|
-
|
|
44
|
-
# These calls should NOT raise exceptions since there is no subclass relationship
|
|
45
|
-
IsNotSubclass(AbstractClass1, AbstractClass2) # Unrelated abstract classes
|
|
46
|
-
IsNotSubclass(AbstractClass1, ConcreteClass2) # Unrelated concrete class
|
|
47
|
-
IsNotSubclass(ConcreteClass1, AbstractClass1) # Concrete is not subclass of unrelated abstract
|
|
48
|
-
IsNotSubclass(int, str) # Built-in types, no subclass relationship
|
|
49
|
-
IsNotSubclass(list, dict) # Built-in types, no subclass relationship
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
from abc import ABC
|
|
2
|
-
from orionis.container.validators.is_subclass import IsSubclass
|
|
3
|
-
from orionis.container.exceptions.exception import OrionisContainerException
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestIsSubclass(AsyncTestCase):
|
|
7
|
-
|
|
8
|
-
async def testValidSubclass(self) -> None:
|
|
9
|
-
"""
|
|
10
|
-
Validate that `IsSubclass` does not raise an exception when the concrete class is a valid subclass of the abstract class.
|
|
11
|
-
|
|
12
|
-
Parameters
|
|
13
|
-
----------
|
|
14
|
-
None
|
|
15
|
-
|
|
16
|
-
Returns
|
|
17
|
-
-------
|
|
18
|
-
None
|
|
19
|
-
This method does not return anything. It passes if no exception is raised.
|
|
20
|
-
|
|
21
|
-
Notes
|
|
22
|
-
-----
|
|
23
|
-
The test covers direct and indirect subclass relationships.
|
|
24
|
-
"""
|
|
25
|
-
# Define an abstract base class
|
|
26
|
-
class AbstractClass(ABC):
|
|
27
|
-
pass
|
|
28
|
-
|
|
29
|
-
# Define a concrete class inheriting from AbstractClass
|
|
30
|
-
class ConcreteClass(AbstractClass):
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
# Define a subclass of ConcreteClass
|
|
34
|
-
class SubConcreteClass(ConcreteClass):
|
|
35
|
-
pass
|
|
36
|
-
|
|
37
|
-
# These calls should not raise exceptions since subclass relationships are valid
|
|
38
|
-
IsSubclass(AbstractClass, ConcreteClass)
|
|
39
|
-
IsSubclass(AbstractClass, SubConcreteClass)
|
|
40
|
-
IsSubclass(ConcreteClass, SubConcreteClass)
|
|
41
|
-
|
|
42
|
-
async def testInvalidSubclass(self) -> None:
|
|
43
|
-
"""
|
|
44
|
-
Validate that `IsSubclass` raises `OrionisContainerException` when the concrete class is not a subclass of the abstract class.
|
|
45
|
-
|
|
46
|
-
Parameters
|
|
47
|
-
----------
|
|
48
|
-
None
|
|
49
|
-
|
|
50
|
-
Returns
|
|
51
|
-
-------
|
|
52
|
-
None
|
|
53
|
-
This method does not return anything. It passes if the expected exception is raised.
|
|
54
|
-
|
|
55
|
-
Notes
|
|
56
|
-
-----
|
|
57
|
-
The test covers cases where classes are unrelated or the inheritance direction is incorrect.
|
|
58
|
-
"""
|
|
59
|
-
# Define two unrelated abstract base classes
|
|
60
|
-
class AbstractClass1(ABC):
|
|
61
|
-
pass
|
|
62
|
-
|
|
63
|
-
class AbstractClass2(ABC):
|
|
64
|
-
pass
|
|
65
|
-
|
|
66
|
-
# Define concrete classes inheriting from each abstract class
|
|
67
|
-
class ConcreteClass1(AbstractClass1):
|
|
68
|
-
pass
|
|
69
|
-
|
|
70
|
-
class ConcreteClass2(AbstractClass2):
|
|
71
|
-
pass
|
|
72
|
-
|
|
73
|
-
# These calls should raise exceptions due to invalid subclass relationships
|
|
74
|
-
with self.assertRaises(OrionisContainerException) as context:
|
|
75
|
-
IsSubclass(AbstractClass1, AbstractClass2)
|
|
76
|
-
self.assertIn("concrete class must inherit", str(context.exception))
|
|
77
|
-
|
|
78
|
-
with self.assertRaises(OrionisContainerException) as context:
|
|
79
|
-
IsSubclass(AbstractClass1, ConcreteClass2)
|
|
80
|
-
self.assertIn("concrete class must inherit", str(context.exception))
|
|
81
|
-
|
|
82
|
-
with self.assertRaises(OrionisContainerException) as context:
|
|
83
|
-
IsSubclass(ConcreteClass1, AbstractClass1)
|
|
84
|
-
self.assertIn("concrete class must inherit", str(context.exception))
|
|
85
|
-
|
|
86
|
-
async def testSameClass(self) -> None:
|
|
87
|
-
"""
|
|
88
|
-
Validate that `IsSubclass` does not raise an exception when the abstract and concrete classes are the same.
|
|
89
|
-
|
|
90
|
-
Parameters
|
|
91
|
-
----------
|
|
92
|
-
None
|
|
93
|
-
|
|
94
|
-
Returns
|
|
95
|
-
-------
|
|
96
|
-
None
|
|
97
|
-
This method does not return anything. It passes if no exception is raised.
|
|
98
|
-
|
|
99
|
-
Notes
|
|
100
|
-
-----
|
|
101
|
-
In Python, a class is considered a subclass of itself.
|
|
102
|
-
"""
|
|
103
|
-
# Define a test class
|
|
104
|
-
class TestClass:
|
|
105
|
-
pass
|
|
106
|
-
|
|
107
|
-
# Should not raise since a class is a subclass of itself
|
|
108
|
-
IsSubclass(TestClass, TestClass)
|
|
109
|
-
|
|
110
|
-
async def testBuiltinTypes(self) -> None:
|
|
111
|
-
"""
|
|
112
|
-
Validate `IsSubclass` behavior with built-in types, ensuring correct subclass relationships and exception raising.
|
|
113
|
-
|
|
114
|
-
Parameters
|
|
115
|
-
----------
|
|
116
|
-
None
|
|
117
|
-
|
|
118
|
-
Returns
|
|
119
|
-
-------
|
|
120
|
-
None
|
|
121
|
-
This method does not return anything. It passes if exceptions are raised or not as expected.
|
|
122
|
-
|
|
123
|
-
Notes
|
|
124
|
-
-----
|
|
125
|
-
The test covers both valid and invalid subclass relationships among built-in types.
|
|
126
|
-
"""
|
|
127
|
-
# Valid subclass relationships for built-in types
|
|
128
|
-
IsSubclass(Exception, ValueError)
|
|
129
|
-
IsSubclass(BaseException, Exception)
|
|
130
|
-
|
|
131
|
-
# Invalid subclass relationships should raise exceptions
|
|
132
|
-
with self.assertRaises(OrionisContainerException):
|
|
133
|
-
IsSubclass(ValueError, Exception)
|
|
134
|
-
|
|
135
|
-
with self.assertRaises(OrionisContainerException):
|
|
136
|
-
IsSubclass(int, str)
|
|
137
|
-
|
|
138
|
-
with self.assertRaises(OrionisContainerException):
|
|
139
|
-
IsSubclass(list, dict)
|
|
140
|
-
|
|
141
|
-
async def testNonClassArguments(self) -> None:
|
|
142
|
-
"""
|
|
143
|
-
Validate that `IsSubclass` raises `TypeError` when non-class arguments are provided.
|
|
144
|
-
|
|
145
|
-
Parameters
|
|
146
|
-
----------
|
|
147
|
-
None
|
|
148
|
-
|
|
149
|
-
Returns
|
|
150
|
-
-------
|
|
151
|
-
None
|
|
152
|
-
This method does not return anything. It passes if `TypeError` is raised for non-class arguments.
|
|
153
|
-
|
|
154
|
-
Notes
|
|
155
|
-
-----
|
|
156
|
-
The test covers various non-class types such as None, int, str, list, dict, and function.
|
|
157
|
-
"""
|
|
158
|
-
# Define a valid test class
|
|
159
|
-
class TestClass:
|
|
160
|
-
pass
|
|
161
|
-
|
|
162
|
-
# List of non-class arguments to test
|
|
163
|
-
non_class_args = [
|
|
164
|
-
None,
|
|
165
|
-
123,
|
|
166
|
-
"string",
|
|
167
|
-
[],
|
|
168
|
-
{},
|
|
169
|
-
lambda x: x
|
|
170
|
-
]
|
|
171
|
-
|
|
172
|
-
# Each non-class argument should raise TypeError when used as either abstract or concrete class
|
|
173
|
-
for arg in non_class_args:
|
|
174
|
-
with self.assertRaises(TypeError):
|
|
175
|
-
IsSubclass(TestClass, arg)
|
|
176
|
-
|
|
177
|
-
with self.assertRaises(TypeError):
|
|
178
|
-
IsSubclass(arg, TestClass)
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
from orionis.container.validators.is_valid_alias import IsValidAlias
|
|
2
|
-
from orionis.container.exceptions.type import OrionisContainerTypeError
|
|
3
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
-
|
|
5
|
-
class TestIsValidAlias(AsyncTestCase):
|
|
6
|
-
|
|
7
|
-
async def testValidAliases(self) -> None:
|
|
8
|
-
"""
|
|
9
|
-
Validates that the IsValidAlias validator accepts valid alias strings.
|
|
10
|
-
|
|
11
|
-
This test iterates over a list of valid alias strings and ensures that
|
|
12
|
-
the IsValidAlias validator does not raise any exceptions for these values.
|
|
13
|
-
Valid aliases include strings with letters, numbers, and underscores.
|
|
14
|
-
|
|
15
|
-
Returns
|
|
16
|
-
-------
|
|
17
|
-
None
|
|
18
|
-
This method does not return any value. It passes if no exception is raised.
|
|
19
|
-
"""
|
|
20
|
-
valid_aliases = [
|
|
21
|
-
"valid",
|
|
22
|
-
"valid_alias",
|
|
23
|
-
"validAlias",
|
|
24
|
-
"valid123",
|
|
25
|
-
"valid_123",
|
|
26
|
-
"v",
|
|
27
|
-
"1",
|
|
28
|
-
"_",
|
|
29
|
-
"valid_alias_with_underscores",
|
|
30
|
-
"ValidAliasWithMixedCase",
|
|
31
|
-
"VALID_UPPERCASE_ALIAS"
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
# Ensure each valid alias passes validation without raising an exception
|
|
35
|
-
for alias in valid_aliases:
|
|
36
|
-
IsValidAlias(alias)
|
|
37
|
-
|
|
38
|
-
async def testInvalidAliasTypes(self) -> None:
|
|
39
|
-
"""
|
|
40
|
-
Ensures that IsValidAlias raises an exception for non-string types.
|
|
41
|
-
|
|
42
|
-
This test checks that passing values of types other than string (such as
|
|
43
|
-
integers, floats, None, booleans, lists, dictionaries, tuples, and sets)
|
|
44
|
-
to the IsValidAlias validator results in an OrionisContainerTypeError.
|
|
45
|
-
|
|
46
|
-
Returns
|
|
47
|
-
-------
|
|
48
|
-
None
|
|
49
|
-
This method does not return any value. It passes if the expected exception is raised.
|
|
50
|
-
"""
|
|
51
|
-
invalid_types = [
|
|
52
|
-
123,
|
|
53
|
-
3.14,
|
|
54
|
-
None,
|
|
55
|
-
True,
|
|
56
|
-
False,
|
|
57
|
-
[],
|
|
58
|
-
{},
|
|
59
|
-
(),
|
|
60
|
-
set()
|
|
61
|
-
]
|
|
62
|
-
|
|
63
|
-
# Ensure each invalid type raises the expected exception
|
|
64
|
-
for value in invalid_types:
|
|
65
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
66
|
-
IsValidAlias(value)
|
|
67
|
-
|
|
68
|
-
async def testAliasWithInvalidCharacters(self) -> None:
|
|
69
|
-
"""
|
|
70
|
-
Verifies that aliases containing invalid characters are rejected.
|
|
71
|
-
|
|
72
|
-
This test iterates over a list of alias strings containing whitespace,
|
|
73
|
-
control characters, and special symbols, and asserts that the
|
|
74
|
-
IsValidAlias validator raises an OrionisContainerTypeError for each.
|
|
75
|
-
It also checks that the exception message is descriptive.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
None
|
|
80
|
-
This method does not return any value. It passes if the expected exception and message are raised.
|
|
81
|
-
"""
|
|
82
|
-
invalid_aliases = [
|
|
83
|
-
"invalid alias", # space
|
|
84
|
-
"invalid\talias", # tab
|
|
85
|
-
"invalid\nalias", # newline
|
|
86
|
-
"invalid@alias", # special character
|
|
87
|
-
"invalid#alias", # special character
|
|
88
|
-
"invalid$alias", # special character
|
|
89
|
-
"invalid%alias", # special character
|
|
90
|
-
"invalid&alias", # special character
|
|
91
|
-
"invalid*alias", # special character
|
|
92
|
-
"invalid(alias)", # parentheses
|
|
93
|
-
"invalid[alias]", # brackets
|
|
94
|
-
"invalid{alias}", # braces
|
|
95
|
-
"invalid;alias", # semicolon
|
|
96
|
-
"invalid:alias", # colon
|
|
97
|
-
"invalid,alias", # comma
|
|
98
|
-
"invalid/alias", # slash
|
|
99
|
-
"invalid\\alias", # backslash
|
|
100
|
-
"invalid<alias>", # angle brackets
|
|
101
|
-
"invalid|alias", # pipe
|
|
102
|
-
"invalid`alias", # backtick
|
|
103
|
-
'invalid"alias', # double quote
|
|
104
|
-
"invalid'alias" # single quote
|
|
105
|
-
]
|
|
106
|
-
|
|
107
|
-
# Ensure each invalid alias raises the expected exception and message
|
|
108
|
-
for alias in invalid_aliases:
|
|
109
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
110
|
-
IsValidAlias(alias)
|
|
111
|
-
|
|
112
|
-
expected_msg_start = f"Alias '{alias}' contains invalid characters."
|
|
113
|
-
# Check that the exception message starts as expected
|
|
114
|
-
self.assertTrue(str(context.exception).startswith(expected_msg_start))
|
|
115
|
-
# Check that the message contains additional guidance
|
|
116
|
-
self.assertIn("Aliases must not contain whitespace or special symbols", str(context.exception))
|
|
117
|
-
|
|
118
|
-
async def testEmptyAlias(self) -> None:
|
|
119
|
-
"""
|
|
120
|
-
Checks that empty or whitespace-only aliases are rejected.
|
|
121
|
-
|
|
122
|
-
This test verifies that passing an empty string or a string containing
|
|
123
|
-
only whitespace to the IsValidAlias validator raises an
|
|
124
|
-
OrionisContainerTypeError with the correct error message.
|
|
125
|
-
|
|
126
|
-
Returns
|
|
127
|
-
-------
|
|
128
|
-
None
|
|
129
|
-
This method does not return any value. It passes if the expected exception and message are raised.
|
|
130
|
-
"""
|
|
131
|
-
# Empty string should be rejected
|
|
132
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
133
|
-
IsValidAlias("")
|
|
134
|
-
|
|
135
|
-
self.assertEqual(
|
|
136
|
-
str(context.exception),
|
|
137
|
-
"Alias cannot be None, empty, or whitespace only."
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
# Whitespace-only string should also be rejected
|
|
141
|
-
with self.assertRaises(OrionisContainerTypeError) as context:
|
|
142
|
-
IsValidAlias(" ")
|
|
143
|
-
|
|
144
|
-
self.assertEqual(
|
|
145
|
-
str(context.exception),
|
|
146
|
-
"Alias cannot be None, empty, or whitespace only."
|
|
147
|
-
)
|