orionis 0.546.0__py3-none-any.whl → 0.548.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.548.0.dist-info}/METADATA +1 -1
  11. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/RECORD +14 -159
  12. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/top_level.txt +0 -1
  13. orionis-0.546.0.dist-info/zip-safe +0 -1
  14. tests/container/__init__.py +0 -0
  15. tests/container/context/__init__.py +0 -0
  16. tests/container/context/test_manager.py +0 -38
  17. tests/container/context/test_scope.py +0 -32
  18. tests/container/core/__init__.py +0 -0
  19. tests/container/core/test_advanced_async.py +0 -234
  20. tests/container/core/test_async_optimizations.py +0 -268
  21. tests/container/core/test_container.py +0 -453
  22. tests/container/core/test_singleton.py +0 -122
  23. tests/container/core/test_thread_safety.py +0 -90
  24. tests/container/entities/__init__.py +0 -0
  25. tests/container/entities/test_binding.py +0 -242
  26. tests/container/enums/__init__.py +0 -0
  27. tests/container/enums/test_lifetimes.py +0 -97
  28. tests/container/facades/__init__.py +0 -0
  29. tests/container/facades/test_facade.py +0 -78
  30. tests/container/mocks/__init__.py +0 -0
  31. tests/container/mocks/mock_advanced_async.py +0 -332
  32. tests/container/mocks/mock_async_optimizations.py +0 -407
  33. tests/container/mocks/mock_auto_resolution.py +0 -192
  34. tests/container/mocks/mock_complex_classes.py +0 -792
  35. tests/container/mocks/mock_simple_classes.py +0 -98
  36. tests/container/providers/__init__.py +0 -0
  37. tests/container/providers/test_providers.py +0 -55
  38. tests/container/validators/__init__.py +0 -0
  39. tests/container/validators/test_implements.py +0 -186
  40. tests/container/validators/test_is_abstract_class.py +0 -147
  41. tests/container/validators/test_is_callable.py +0 -102
  42. tests/container/validators/test_is_concrete_class.py +0 -160
  43. tests/container/validators/test_is_instance.py +0 -150
  44. tests/container/validators/test_is_not_subclass.py +0 -49
  45. tests/container/validators/test_is_subclass.py +0 -178
  46. tests/container/validators/test_is_valid_alias.py +0 -147
  47. tests/container/validators/test_lifetime.py +0 -106
  48. tests/example/__init__.py +0 -0
  49. tests/example/test_example.py +0 -725
  50. tests/foundation/__init__.py +0 -0
  51. tests/foundation/config/__init__.py +0 -0
  52. tests/foundation/config/app/__init__.py +0 -0
  53. tests/foundation/config/app/test_foundation_config_app.py +0 -262
  54. tests/foundation/config/auth/__init__.py +0 -0
  55. tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
  56. tests/foundation/config/cache/__init__.py +0 -0
  57. tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
  58. tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
  59. tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
  60. tests/foundation/config/cors/__init__.py +0 -0
  61. tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
  62. tests/foundation/config/database/__init__.py +0 -0
  63. tests/foundation/config/database/test_foundation_config_database.py +0 -158
  64. tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
  65. tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
  66. tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
  67. tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
  68. tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
  69. tests/foundation/config/filesystems/__init__.py +0 -0
  70. tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
  71. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
  72. tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
  73. tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
  74. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
  75. tests/foundation/config/logging/__init__.py +0 -0
  76. tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
  77. tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
  78. tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
  79. tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
  80. tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
  81. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
  82. tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
  83. tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
  84. tests/foundation/config/mail/__init__.py +0 -0
  85. tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
  86. tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
  87. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
  88. tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
  89. tests/foundation/config/queue/__init__.py +0 -0
  90. tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
  91. tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
  92. tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
  93. tests/foundation/config/root/__init__.py +0 -0
  94. tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
  95. tests/foundation/config/session/__init__.py +0 -0
  96. tests/foundation/config/session/test_foundation_config_session.py +0 -213
  97. tests/foundation/config/startup/__init__.py +0 -0
  98. tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
  99. tests/foundation/config/testing/__init__.py +0 -0
  100. tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
  101. tests/metadata/__init__.py +0 -0
  102. tests/metadata/test_metadata_framework.py +0 -140
  103. tests/metadata/test_metadata_package.py +0 -139
  104. tests/services/__init__.py +0 -0
  105. tests/services/asynchrony/__init__.py +0 -0
  106. tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
  107. tests/services/environment/__init__.py +0 -0
  108. tests/services/environment/test_services_environment.py +0 -226
  109. tests/services/introspection/__init__.py +0 -0
  110. tests/services/introspection/dependencies/__init__.py +0 -0
  111. tests/services/introspection/dependencies/mocks/__init__.py +0 -0
  112. tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
  113. tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
  114. tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
  115. tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
  116. tests/services/introspection/reflection/__init__.py +0 -0
  117. tests/services/introspection/reflection/mock/__init__.py +0 -0
  118. tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
  119. tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
  120. tests/services/introspection/reflection/test_reflection_callable.py +0 -206
  121. tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
  122. tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
  123. tests/services/introspection/reflection/test_reflection_module.py +0 -567
  124. tests/services/introspection/test_reflection.py +0 -462
  125. tests/services/log/__init__.py +0 -0
  126. tests/services/log/test_log.py +0 -97
  127. tests/services/system/__init__.py +0 -0
  128. tests/services/system/test_services_system_imports.py +0 -204
  129. tests/services/system/test_services_system_workers.py +0 -131
  130. tests/support/__init__.py +0 -0
  131. tests/support/entities/__init__.py +0 -0
  132. tests/support/entities/mock_dataclass.py +0 -40
  133. tests/support/entities/test_base.py +0 -64
  134. tests/support/patterns/__init__.py +0 -0
  135. tests/support/patterns/singleton/__init__.py +0 -0
  136. tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
  137. tests/support/standard/__init__.py +0 -0
  138. tests/support/standard/test_services_std.py +0 -226
  139. tests/support/wrapper/__init__.py +0 -0
  140. tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
  141. tests/testing/__init__.py +0 -0
  142. tests/testing/cases/__init__.py +0 -0
  143. tests/testing/cases/test_testing_asynchronous.py +0 -63
  144. tests/testing/cases/test_testing_synchronous.py +0 -57
  145. tests/testing/entities/__init__.py +0 -0
  146. tests/testing/entities/test_testing_result.py +0 -146
  147. tests/testing/enums/__init__.py +0 -0
  148. tests/testing/enums/test_testing_status.py +0 -63
  149. tests/testing/output/__init__.py +0 -0
  150. tests/testing/output/test_testing_dumper.py +0 -29
  151. tests/testing/output/test_testing_printer.py +0 -42
  152. tests/testing/records/__init__.py +0 -0
  153. tests/testing/records/test_testing_records.py +0 -171
  154. tests/testing/test_testing_unit.py +0 -164
  155. tests/testing/validators/__init__.py +0 -0
  156. tests/testing/validators/test_testing_validators.py +0 -392
  157. tests/testing/view/__init__.py +0 -0
  158. tests/testing/view/test_render.py +0 -30
  159. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/WHEEL +0 -0
  160. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/licenses/LICENCE +0 -0
@@ -1,156 +0,0 @@
1
- from orionis.foundation.config.cache.entities.stores import Stores
2
- from orionis.foundation.config.cache.entities.file import File
3
- from orionis.foundation.exceptions.integrity import OrionisIntegrityException
4
- from orionis.test.cases.asynchronous import AsyncTestCase
5
-
6
- class TestFoundationConfigCacheStores(AsyncTestCase):
7
- """
8
- Test cases for the Stores cache configuration entity.
9
-
10
- This class contains asynchronous unit tests for the `Stores` entity,
11
- validating its initialization, type enforcement, dictionary conversion,
12
- hashability, and keyword-only argument enforcement.
13
-
14
- Attributes
15
- ----------
16
- None
17
- """
18
-
19
- async def testDefaultFileStore(self):
20
- """
21
- Test initialization with default File instance.
22
-
23
- Ensures that `Stores` initializes with a default `File` instance and
24
- that the `file` attribute is properly set with the default configuration.
25
-
26
- Returns
27
- -------
28
- None
29
- """
30
- stores = Stores()
31
- self.assertIsInstance(stores.file, File)
32
- self.assertEqual(stores.file.path, 'storage/framework/cache/data')
33
-
34
- async def testCustomFileStore(self):
35
- """
36
- Test initialization with a custom File configuration.
37
-
38
- Ensures that a custom `File` instance or dict can be provided during
39
- initialization and is correctly assigned to the `file` attribute.
40
-
41
- Returns
42
- -------
43
- None
44
- """
45
- custom_file = File(path='custom/cache/path')
46
- stores = Stores(file=custom_file)
47
- self.assertIsInstance(stores.file, File)
48
- self.assertEqual(stores.file.path, 'custom/cache/path')
49
-
50
- stores_dict = Stores(file={'path': 'dict/cache/path'})
51
- self.assertIsInstance(stores_dict.file, File)
52
- self.assertEqual(stores_dict.file.path, 'dict/cache/path')
53
-
54
- async def testFileTypeValidation(self):
55
- """
56
- Test type validation for the file attribute.
57
-
58
- Ensures that providing a non-`File` instance or dict to the `file` attribute
59
- raises an `OrionisIntegrityException`.
60
-
61
- Returns
62
- -------
63
- None
64
-
65
- Raises
66
- ------
67
- OrionisIntegrityException
68
- If the `file` attribute is not a `File` instance or dict.
69
- """
70
- with self.assertRaises(OrionisIntegrityException):
71
- Stores(file="not_a_file_instance")
72
-
73
- with self.assertRaises(OrionisIntegrityException):
74
- Stores(file=123)
75
-
76
- with self.assertRaises(OrionisIntegrityException):
77
- Stores(file=None)
78
-
79
- async def testToDictMethodWithDefaults(self):
80
- """
81
- Test dictionary representation with default values.
82
-
83
- Ensures that `toDict` returns a dictionary with the correct default
84
- file path.
85
-
86
- Returns
87
- -------
88
- None
89
- """
90
- stores = Stores()
91
- stores_dict = stores.toDict()
92
-
93
- self.assertIsInstance(stores_dict, dict)
94
- self.assertIsInstance(stores_dict['file'], dict)
95
- self.assertEqual(stores_dict['file']['path'], 'storage/framework/cache/data')
96
-
97
- async def testToDictMethodWithCustomFile(self):
98
- """
99
- Test dictionary representation with custom file configuration.
100
-
101
- Ensures that `toDict` reflects custom file paths in its dictionary
102
- representation.
103
-
104
- Returns
105
- -------
106
- None
107
- """
108
- custom_file = File(path='alternate/cache/location')
109
- stores = Stores(file=custom_file)
110
- stores_dict = stores.toDict()
111
-
112
- self.assertEqual(stores_dict['file']['path'], 'alternate/cache/location')
113
-
114
- stores_dict_input = Stores(file={'path': 'dict/location'})
115
- stores_dict2 = stores_dict_input.toDict()
116
- self.assertEqual(stores_dict2['file']['path'], 'dict/location')
117
-
118
- async def testHashability(self):
119
- """
120
- Test hashability of Stores instances.
121
-
122
- Ensures that `Stores` instances are hashable and can be used in sets
123
- and as dictionary keys.
124
-
125
- Returns
126
- -------
127
- None
128
- """
129
- store1 = Stores()
130
- store2 = Stores()
131
- store_set = {store1, store2}
132
-
133
- self.assertEqual(len(store_set), 1)
134
-
135
- custom_store = Stores(file=File(path='custom/path'))
136
- store_set.add(custom_store)
137
- self.assertEqual(len(store_set), 2)
138
-
139
- async def testKwOnlyInitialization(self):
140
- """
141
- Test keyword-only initialization enforcement.
142
-
143
- Ensures that `Stores` enforces keyword-only arguments and does not
144
- allow positional arguments during initialization.
145
-
146
- Returns
147
- -------
148
- None
149
-
150
- Raises
151
- ------
152
- TypeError
153
- If positional arguments are provided during initialization.
154
- """
155
- with self.assertRaises(TypeError):
156
- Stores(File())
File without changes
@@ -1,190 +0,0 @@
1
- from orionis.foundation.config.cors.entities.cors import Cors
2
- from orionis.foundation.exceptions.integrity import OrionisIntegrityException
3
- from orionis.test.cases.asynchronous import AsyncTestCase
4
-
5
- class TestFoundationConfigCors(AsyncTestCase):
6
- """
7
- Unit tests for Cors configuration defaults and validation.
8
-
9
- Notes
10
- -----
11
- These tests verify the default values, custom value assignment, and type validation
12
- for the `Cors` configuration entity.
13
- """
14
-
15
- async def testDefaultValues(self):
16
- """
17
- Test the default values of the Cors configuration.
18
-
19
- Verifies that a newly instantiated Cors object has the expected default settings.
20
-
21
- Expected Defaults
22
- -----------------
23
- allow_origins : list of str
24
- ["*"]
25
- allow_origin_regex : None or str
26
- None
27
- allow_methods : list of str
28
- ["*"]
29
- allow_headers : list of str
30
- ["*"]
31
- expose_headers : list of str
32
- []
33
- allow_credentials : bool
34
- False
35
- max_age : int
36
- 600
37
- """
38
- cors = Cors()
39
- self.assertEqual(cors.allow_origins, ["*"])
40
- self.assertIsNone(cors.allow_origin_regex)
41
- self.assertEqual(cors.allow_methods, ["*"])
42
- self.assertEqual(cors.allow_headers, ["*"])
43
- self.assertEqual(cors.expose_headers, [])
44
- self.assertFalse(cors.allow_credentials)
45
- self.assertEqual(cors.max_age, 600)
46
-
47
- async def testCustomValues(self):
48
- """
49
- Test custom value assignment for all Cors configuration parameters.
50
-
51
- Ensures that the Cors object accurately reflects the provided custom configuration values.
52
-
53
- Parameters
54
- ----------
55
- allow_origins : list of str
56
- Custom list of allowed origins.
57
- allow_origin_regex : str
58
- Custom regex pattern for allowed origins.
59
- allow_methods : list of str
60
- Custom list of allowed HTTP methods.
61
- allow_headers : list of str
62
- Custom list of allowed headers.
63
- expose_headers : list of str
64
- Custom list of exposed headers.
65
- allow_credentials : bool
66
- Whether credentials are allowed.
67
- max_age : int
68
- Custom max age value.
69
- """
70
- cors = Cors(
71
- allow_origins=["https://example.com"],
72
- allow_origin_regex="^https://.*\\.example\\.com$",
73
- allow_methods=["GET", "POST"],
74
- allow_headers=["Authorization", "Content-Type"],
75
- expose_headers=["X-Custom-Header"],
76
- allow_credentials=True,
77
- max_age=3600
78
- )
79
- self.assertEqual(cors.allow_origins, ["https://example.com"])
80
- self.assertEqual(cors.allow_origin_regex, "^https://.*\\.example\\.com$")
81
- self.assertEqual(cors.allow_methods, ["GET", "POST"])
82
- self.assertEqual(cors.allow_headers, ["Authorization", "Content-Type"])
83
- self.assertEqual(cors.expose_headers, ["X-Custom-Header"])
84
- self.assertTrue(cors.allow_credentials)
85
- self.assertEqual(cors.max_age, 3600)
86
-
87
- async def testInvalidAllowOriginsType(self):
88
- """
89
- Test type validation for 'allow_origins' parameter.
90
-
91
- Ensures that passing a string instead of a list to the `allow_origins` parameter
92
- raises an OrionisIntegrityException.
93
-
94
- Raises
95
- ------
96
- OrionisIntegrityException
97
- If `allow_origins` is not a list.
98
- """
99
- with self.assertRaises(OrionisIntegrityException):
100
- Cors(allow_origins="*")
101
-
102
- async def testInvalidAllowOriginRegexType(self):
103
- """
104
- Test type validation for 'allow_origin_regex' parameter.
105
-
106
- Ensures that passing a non-string, non-None value (e.g., integer) to the
107
- `allow_origin_regex` parameter raises an OrionisIntegrityException.
108
-
109
- Raises
110
- ------
111
- OrionisIntegrityException
112
- If `allow_origin_regex` is not a string or None.
113
- """
114
- with self.assertRaises(OrionisIntegrityException):
115
- Cors(allow_origin_regex=123)
116
-
117
- async def testInvalidAllowMethodsType(self):
118
- """
119
- Test type validation for 'allow_methods' parameter.
120
-
121
- Ensures that passing a string instead of a list to the `allow_methods` parameter
122
- raises an OrionisIntegrityException.
123
-
124
- Raises
125
- ------
126
- OrionisIntegrityException
127
- If `allow_methods` is not a list.
128
- """
129
- with self.assertRaises(OrionisIntegrityException):
130
- Cors(allow_methods="GET")
131
-
132
- async def testInvalidAllowHeadersType(self):
133
- """
134
- Test type validation for 'allow_headers' parameter.
135
-
136
- Ensures that passing a string instead of a list to the `allow_headers` parameter
137
- raises an OrionisIntegrityException.
138
-
139
- Raises
140
- ------
141
- OrionisIntegrityException
142
- If `allow_headers` is not a list.
143
- """
144
- with self.assertRaises(OrionisIntegrityException):
145
- Cors(allow_headers="Authorization")
146
-
147
- async def testInvalidExposeHeadersType(self):
148
- """
149
- Test type validation for 'expose_headers' parameter.
150
-
151
- Ensures that passing a string instead of a list to the `expose_headers` parameter
152
- raises an OrionisIntegrityException.
153
-
154
- Raises
155
- ------
156
- OrionisIntegrityException
157
- If `expose_headers` is not a list.
158
- """
159
- with self.assertRaises(OrionisIntegrityException):
160
- Cors(expose_headers="X-Custom-Header")
161
-
162
- async def testInvalidAllowCredentialsType(self):
163
- """
164
- Test type validation for 'allow_credentials' parameter.
165
-
166
- Ensures that passing a non-boolean value to the `allow_credentials` parameter
167
- raises an OrionisIntegrityException.
168
-
169
- Raises
170
- ------
171
- OrionisIntegrityException
172
- If `allow_credentials` is not a boolean.
173
- """
174
- with self.assertRaises(OrionisIntegrityException):
175
- Cors(allow_credentials="yes")
176
-
177
- async def testInvalidMaxAgeType(self):
178
- """
179
- Test type validation for 'max_age' parameter.
180
-
181
- Ensures that passing a non-integer value (e.g., string) to the `max_age` parameter
182
- raises an OrionisIntegrityException.
183
-
184
- Raises
185
- ------
186
- OrionisIntegrityException
187
- If `max_age` is not an integer or None.
188
- """
189
- with self.assertRaises(OrionisIntegrityException):
190
- Cors(max_age="3600")
File without changes
@@ -1,158 +0,0 @@
1
- from orionis.foundation.config.database.entities.database import Database
2
- from orionis.foundation.config.database.entities.connections import Connections
3
- from orionis.foundation.exceptions.integrity import OrionisIntegrityException
4
- from orionis.test.cases.asynchronous import AsyncTestCase
5
-
6
- class TestFoundationConfigDatabase(AsyncTestCase):
7
- """
8
- Unit tests for the Database configuration class.
9
-
10
- This class provides asynchronous test cases to verify the behavior,
11
- validation, and integrity of the `Database` configuration class,
12
- including default values, attribute validation, dictionary conversion,
13
- custom values, hashability, and keyword-only initialization enforcement.
14
- """
15
-
16
- async def testDefaultValues(self):
17
- """
18
- Test that a Database instance initializes with correct default values.
19
-
20
- Ensures that the `default` attribute is set to 'sqlite' and the
21
- `connections` attribute is an instance of Connections.
22
-
23
- Returns
24
- -------
25
- None
26
- """
27
- db = Database()
28
- self.assertEqual(db.default, 'sqlite')
29
- self.assertIsInstance(db.connections, Connections)
30
-
31
- async def testDefaultConnectionValidation(self):
32
- """
33
- Validate the `default` connection attribute for allowed values.
34
-
35
- Checks that only valid connection types are accepted for the `default`
36
- attribute. Verifies that invalid, empty, or non-string values raise
37
- OrionisIntegrityException.
38
-
39
- Returns
40
- -------
41
- None
42
- """
43
- # Test valid connection types
44
- valid_connections = ['sqlite', 'mysql', 'pgsql', 'oracle']
45
- for conn in valid_connections:
46
- try:
47
- Database(default=conn)
48
- except OrionisIntegrityException:
49
- self.fail(f"Valid connection type '{conn}' should not raise exception")
50
-
51
- # Test invalid connection type
52
- with self.assertRaises(OrionisIntegrityException):
53
- Database(default='invalid_connection')
54
-
55
- # Test empty default
56
- with self.assertRaises(OrionisIntegrityException):
57
- Database(default='')
58
-
59
- # Test non-string default
60
- with self.assertRaises(OrionisIntegrityException):
61
- Database(default=123)
62
-
63
- async def testConnectionsValidation(self):
64
- """
65
- Validate the `connections` attribute for correct type.
66
-
67
- Ensures that only instances of Connections are accepted for the
68
- `connections` attribute. Invalid types or None should raise
69
- OrionisIntegrityException.
70
-
71
- Returns
72
- -------
73
- None
74
- """
75
- # Test invalid connections type
76
- with self.assertRaises(OrionisIntegrityException):
77
- Database(connections="not_a_connections_instance")
78
-
79
- # Test None connections
80
- with self.assertRaises(OrionisIntegrityException):
81
- Database(connections=None)
82
-
83
- # Test valid connections
84
- try:
85
- Database(connections=Connections())
86
- except OrionisIntegrityException:
87
- self.fail("Valid Connections instance should not raise exception")
88
-
89
- async def testToDictMethod(self):
90
- """
91
- Test the `toDict` method for dictionary representation.
92
-
93
- Ensures that the `toDict` method returns a dictionary containing
94
- all attributes of the Database instance, including `default` and
95
- `connections`.
96
-
97
- Returns
98
- -------
99
- None
100
- """
101
- db = Database()
102
- db_dict = db.toDict()
103
- self.assertIsInstance(db_dict, dict)
104
- self.assertEqual(db_dict['default'], 'sqlite')
105
- self.assertIsInstance(db_dict['connections'], dict)
106
-
107
- async def testCustomValues(self):
108
- """
109
- Test handling and validation of custom attribute values.
110
-
111
- Ensures that custom values for `default` and `connections` are
112
- correctly stored and validated in the Database instance.
113
-
114
- Returns
115
- -------
116
- None
117
- """
118
- custom_connections = Connections()
119
- custom_db = Database(
120
- default='mysql',
121
- connections=custom_connections
122
- )
123
- self.assertEqual(custom_db.default, 'mysql')
124
- self.assertIs(custom_db.connections, custom_connections)
125
-
126
- async def testHashability(self):
127
- """
128
- Test that Database instances are hashable.
129
-
130
- Verifies that Database instances can be used in sets and as dictionary
131
- keys, and that identical instances are considered equal.
132
-
133
- Returns
134
- -------
135
- None
136
- """
137
- db1 = Database()
138
- db2 = Database()
139
- db_set = {db1, db2}
140
- self.assertEqual(len(db_set), 1)
141
-
142
- custom_db = Database(default='pgsql')
143
- db_set.add(custom_db)
144
- self.assertEqual(len(db_set), 2)
145
-
146
- async def testKwOnlyInitialization(self):
147
- """
148
- Test enforcement of keyword-only initialization.
149
-
150
- Ensures that Database raises TypeError when positional arguments are
151
- used instead of keyword arguments during initialization.
152
-
153
- Returns
154
- -------
155
- None
156
- """
157
- with self.assertRaises(TypeError):
158
- Database('sqlite', Connections())