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,146 +0,0 @@
1
- from orionis.foundation.config.mail.entities.smtp import Smtp
2
- from orionis.foundation.exceptions.integrity import OrionisIntegrityException
3
- from orionis.test.cases.asynchronous import AsyncTestCase
4
-
5
- class TestFoundationConfigMailSmtp(AsyncTestCase):
6
- """
7
- Unit tests for the Smtp configuration entity.
8
-
9
- This test suite validates the default initialization, type validation,
10
- attribute-specific validation, custom initialization, dictionary conversion,
11
- and keyword-only enforcement for the Smtp class.
12
- """
13
-
14
- async def testDefaultInitialization(self):
15
- """
16
- Test default initialization of Smtp.
17
-
18
- Ensures that an Smtp instance is initialized with the correct default values.
19
-
20
- Returns
21
- -------
22
- None
23
- """
24
- smtp = Smtp()
25
- self.assertEqual(smtp.url, "smtp.mailtrap.io")
26
- self.assertEqual(smtp.host, "smtp.mailtrap.io")
27
- self.assertEqual(smtp.port, 587)
28
- self.assertEqual(smtp.encryption, "TLS")
29
- self.assertEqual(smtp.username, "")
30
- self.assertEqual(smtp.password, "")
31
- self.assertIsNone(smtp.timeout)
32
-
33
- async def testTypeValidation(self):
34
- """
35
- Test type validation for Smtp attributes.
36
-
37
- Ensures that providing invalid types for Smtp attributes raises
38
- OrionisIntegrityException.
39
-
40
- Returns
41
- -------
42
- None
43
- """
44
- with self.assertRaises(OrionisIntegrityException):
45
- Smtp(url=123)
46
- with self.assertRaises(OrionisIntegrityException):
47
- Smtp(host=456)
48
- with self.assertRaises(OrionisIntegrityException):
49
- Smtp(port="invalid")
50
- with self.assertRaises(OrionisIntegrityException):
51
- Smtp(encryption=123)
52
- with self.assertRaises(OrionisIntegrityException):
53
- Smtp(username=123)
54
- with self.assertRaises(OrionisIntegrityException):
55
- Smtp(password=123)
56
- with self.assertRaises(OrionisIntegrityException):
57
- Smtp(timeout="invalid")
58
-
59
- async def testPortValidation(self):
60
- """
61
- Test validation for the port attribute.
62
-
63
- Ensures that negative port numbers raise OrionisIntegrityException.
64
-
65
- Returns
66
- -------
67
- None
68
- """
69
- with self.assertRaises(OrionisIntegrityException):
70
- Smtp(port=-1)
71
-
72
- async def testTimeoutValidation(self):
73
- """
74
- Test validation for the timeout attribute.
75
-
76
- Ensures that negative timeout values raise OrionisIntegrityException.
77
-
78
- Returns
79
- -------
80
- None
81
- """
82
- with self.assertRaises(OrionisIntegrityException):
83
- Smtp(timeout=-1)
84
-
85
- async def testValidCustomInitialization(self):
86
- """
87
- Test custom initialization with valid parameters.
88
-
89
- Ensures that valid custom values are accepted and stored correctly.
90
-
91
- Returns
92
- -------
93
- None
94
- """
95
- custom_config = Smtp(
96
- url="smtp.example.com",
97
- host="mail.example.com",
98
- port=465,
99
- encryption="SSL",
100
- username="user",
101
- password="pass",
102
- timeout=30
103
- )
104
- self.assertEqual(custom_config.url, "smtp.example.com")
105
- self.assertEqual(custom_config.host, "mail.example.com")
106
- self.assertEqual(custom_config.port, 465)
107
- self.assertEqual(custom_config.encryption, "SSL")
108
- self.assertEqual(custom_config.username, "user")
109
- self.assertEqual(custom_config.password, "pass")
110
- self.assertEqual(custom_config.timeout, 30)
111
-
112
- async def testToDictMethod(self):
113
- """
114
- Test the toDict method of Smtp.
115
-
116
- Ensures that the toDict method returns a dictionary containing all fields
117
- with correct values.
118
-
119
- Returns
120
- -------
121
- None
122
- """
123
- smtp = Smtp()
124
- result = smtp.toDict()
125
- self.assertIsInstance(result, dict)
126
- self.assertEqual(result["url"], "smtp.mailtrap.io")
127
- self.assertEqual(result["host"], "smtp.mailtrap.io")
128
- self.assertEqual(result["port"], 587)
129
- self.assertEqual(result["encryption"], "TLS")
130
- self.assertEqual(result["username"], "")
131
- self.assertEqual(result["password"], "")
132
- self.assertIsNone(result["timeout"])
133
-
134
- async def testKwOnlyInitialization(self):
135
- """
136
- Test keyword-only initialization enforcement.
137
-
138
- Ensures that Smtp requires keyword arguments for initialization and
139
- enforces kw_only=True in its dataclass decorator.
140
-
141
- Returns
142
- -------
143
- None
144
- """
145
- with self.assertRaises(TypeError):
146
- Smtp("smtp.mailtrap.io", "smtp.mailtrap.io", 587, "TLS", "", "", None)
File without changes
@@ -1,88 +0,0 @@
1
- from orionis.foundation.config.queue.entities.queue import Queue
2
- from orionis.foundation.config.queue.entities.brokers import Brokers
3
- from orionis.foundation.exceptions.integrity import OrionisIntegrityException
4
- from orionis.test.cases.asynchronous import AsyncTestCase
5
-
6
- class TestFoundationConfigQueue(AsyncTestCase):
7
-
8
- async def testDefaultInitialization(self):
9
- """
10
- Test default initialization of Queue.
11
-
12
- Ensures that a Queue instance is initialized with the correct default values.
13
-
14
- Returns
15
- -------
16
- None
17
-
18
- Raises
19
- ------
20
- AssertionError
21
- If the default value or brokers instance is incorrect.
22
- """
23
- queue = Queue()
24
- self.assertEqual(queue.default, "sync")
25
- self.assertIsInstance(queue.brokers, Brokers)
26
-
27
- async def testDefaultValidation(self):
28
- """
29
- Test validation of the `default` attribute.
30
-
31
- Checks that invalid values for the `default` attribute raise an OrionisIntegrityException.
32
-
33
- Returns
34
- -------
35
- None
36
-
37
- Raises
38
- ------
39
- OrionisIntegrityException
40
- If an invalid default value is provided.
41
- """
42
- invalid_options = ["invalid", "", 123, None]
43
- for option in invalid_options:
44
- with self.assertRaises(OrionisIntegrityException):
45
- Queue(default=option)
46
-
47
- async def testValidCustomInitialization(self):
48
- """
49
- Test custom initialization with valid parameters.
50
-
51
- Verifies that a Queue instance can be initialized with a valid default value and a Brokers instance.
52
-
53
- Returns
54
- -------
55
- None
56
-
57
- Raises
58
- ------
59
- AssertionError
60
- If the custom initialization does not set the attributes correctly.
61
- """
62
- custom_brokers = Brokers(sync=False)
63
- queue = Queue(default="sync", brokers=custom_brokers)
64
- self.assertEqual(queue.default, "sync")
65
- self.assertIs(queue.brokers, custom_brokers)
66
- self.assertFalse(queue.brokers.sync)
67
-
68
- async def testToDictMethod(self):
69
- """
70
- Test the `toDict` method.
71
-
72
- Ensures that the `toDict` method returns a dictionary representation of the Queue instance with all fields and correct values.
73
-
74
- Returns
75
- -------
76
- None
77
-
78
- Raises
79
- ------
80
- AssertionError
81
- If the dictionary representation is incorrect.
82
- """
83
- queue = Queue()
84
- result = queue.toDict()
85
- self.assertIsInstance(result, dict)
86
- self.assertEqual(result["default"], "sync")
87
- self.assertIsInstance(result["brokers"], dict)
88
- self.assertTrue(result["brokers"]["sync"])
@@ -1,72 +0,0 @@
1
- from orionis.foundation.config.queue.entities.brokers import Brokers
2
- from orionis.foundation.config.queue.entities.database import Database
3
- from orionis.foundation.exceptions.integrity import OrionisIntegrityException
4
- from orionis.test.cases.asynchronous import AsyncTestCase
5
-
6
- class TestFoundationConfigQueueBrokers(AsyncTestCase):
7
-
8
- async def testDefaultInitialization(self):
9
- """
10
- Test that Brokers instance is initialized with correct default values.
11
-
12
- Notes
13
- -----
14
- Verifies that `sync` is `True` by default and `database` is a `Database` instance.
15
- """
16
- brokers = Brokers()
17
- self.assertTrue(brokers.sync)
18
- self.assertIsInstance(brokers.database, Database)
19
-
20
- async def testSyncValidation(self):
21
- """
22
- Test validation for the `sync` attribute.
23
-
24
- Notes
25
- -----
26
- Verifies that non-boolean values for `sync` raise `OrionisIntegrityException`.
27
- """
28
- with self.assertRaises(OrionisIntegrityException):
29
- Brokers(sync="true")
30
- with self.assertRaises(OrionisIntegrityException):
31
- Brokers(sync=1)
32
-
33
- async def testCustomInitialization(self):
34
- """
35
- Test custom initialization with valid parameters.
36
-
37
- Notes
38
- -----
39
- Verifies that valid boolean and `Database` instances are accepted for initialization.
40
- """
41
- custom_db = Database(table="custom_queue")
42
- brokers = Brokers(sync=False, database=custom_db)
43
- self.assertFalse(brokers.sync)
44
- self.assertIs(brokers.database, custom_db)
45
- self.assertEqual(brokers.database.table, "custom_queue")
46
-
47
- async def testToDictMethod(self):
48
- """
49
- Test the `toDict` method returns proper dictionary representation.
50
-
51
- Notes
52
- -----
53
- Verifies all fields are included with correct values in the returned dictionary.
54
- """
55
- brokers = Brokers()
56
- result = brokers.toDict()
57
- self.assertIsInstance(result, dict)
58
- self.assertIn("sync", result)
59
- self.assertIn("database", result)
60
- self.assertTrue(result["sync"])
61
- self.assertIsInstance(result["database"], dict)
62
-
63
- async def testKwOnlyInitialization(self):
64
- """
65
- Test that Brokers requires keyword arguments for initialization.
66
-
67
- Notes
68
- -----
69
- Verifies the class enforces `kw_only=True` in its dataclass decorator.
70
- """
71
- with self.assertRaises(TypeError):
72
- Brokers(True, Database())
@@ -1,134 +0,0 @@
1
- from orionis.foundation.config.queue.entities.database import Database
2
- from orionis.foundation.config.queue.enums.strategy import Strategy
3
- from orionis.foundation.exceptions.integrity import OrionisIntegrityException
4
- from orionis.test.cases.asynchronous import AsyncTestCase
5
-
6
- class TestFoundationConfigQueueDatabase(AsyncTestCase):
7
-
8
- async def testDefaultInitialization(self):
9
- """
10
- Test default initialization of Database.
11
-
12
- Ensures that a Database instance is initialized with the correct default values for
13
- table name, queue name, retry_after, and strategy.
14
-
15
- Returns
16
- -------
17
- None
18
- """
19
- db_queue = Database()
20
- self.assertEqual(db_queue.table, "jobs")
21
- self.assertEqual(db_queue.queue, "default")
22
- self.assertEqual(db_queue.retry_after, 90)
23
- self.assertEqual(db_queue.strategy, Strategy.FIFO.value)
24
-
25
- async def testTableNameValidation(self):
26
- """
27
- Test validation of the table name attribute.
28
-
29
- Checks that invalid table names raise an OrionisIntegrityException.
30
-
31
- Returns
32
- -------
33
- None
34
- """
35
- with self.assertRaises(OrionisIntegrityException):
36
- Database(table="1jobs") # Starts with number
37
- with self.assertRaises(OrionisIntegrityException):
38
- Database(table="Jobs") # Uppercase letter
39
- with self.assertRaises(OrionisIntegrityException):
40
- Database(table="jobs-table") # Invalid character
41
- with self.assertRaises(OrionisIntegrityException):
42
- Database(table=123) # Non-string value
43
-
44
- async def testQueueNameValidation(self):
45
- """
46
- Test validation of the queue name attribute.
47
-
48
- Checks that non-ASCII queue names and non-string values raise an OrionisIntegrityException.
49
-
50
- Returns
51
- -------
52
- None
53
- """
54
- with self.assertRaises(OrionisIntegrityException):
55
- Database(queue="café") # Non-ASCII character
56
- with self.assertRaises(OrionisIntegrityException):
57
- Database(queue=123) # Non-string value
58
-
59
- async def testRetryAfterValidation(self):
60
- """
61
- Test validation of the retry_after attribute.
62
-
63
- Ensures that non-positive integers and non-integer values raise an OrionisIntegrityException.
64
-
65
- Returns
66
- -------
67
- None
68
- """
69
- with self.assertRaises(OrionisIntegrityException):
70
- Database(retry_after=0)
71
- with self.assertRaises(OrionisIntegrityException):
72
- Database(retry_after=-1)
73
- with self.assertRaises(OrionisIntegrityException):
74
- Database(retry_after="90") # String instead of int
75
-
76
- async def testStrategyValidation(self):
77
- """
78
- Test validation and normalization of the strategy attribute.
79
-
80
- Verifies that both string and Strategy enum inputs are handled properly, and that
81
- invalid inputs raise an OrionisIntegrityException.
82
-
83
- Returns
84
- -------
85
- None
86
- """
87
- # Test string inputs (case-insensitive)
88
- db1 = Database(strategy="fifo")
89
- self.assertEqual(db1.strategy, Strategy.FIFO.value)
90
- db2 = Database(strategy="LIFO")
91
- self.assertEqual(db2.strategy, Strategy.LIFO.value)
92
-
93
- # Test enum inputs
94
- db3 = Database(strategy=Strategy.PRIORITY)
95
- self.assertEqual(db3.strategy, Strategy.PRIORITY.value)
96
-
97
- # Test invalid inputs
98
- with self.assertRaises(OrionisIntegrityException):
99
- Database(strategy="invalid_strategy")
100
- with self.assertRaises(OrionisIntegrityException):
101
- Database(strategy=123)
102
-
103
- async def testToDictMethod(self):
104
- """
105
- Test the toDict method.
106
-
107
- Ensures that the toDict method returns a dictionary representation of the Database
108
- instance with all fields included and correct values.
109
-
110
- Returns
111
- -------
112
- None
113
- """
114
- db_queue = Database()
115
- result = db_queue.toDict()
116
- self.assertIsInstance(result, dict)
117
- self.assertEqual(result["table"], "jobs")
118
- self.assertEqual(result["queue"], "default")
119
- self.assertEqual(result["retry_after"], 90)
120
- self.assertEqual(result["strategy"], Strategy.FIFO.value)
121
-
122
- async def testKwOnlyInitialization(self):
123
- """
124
- Test keyword-only initialization enforcement.
125
-
126
- Ensures that the Database class requires keyword arguments for initialization,
127
- enforcing kw_only=True in its dataclass decorator.
128
-
129
- Returns
130
- -------
131
- None
132
- """
133
- with self.assertRaises(TypeError):
134
- Database("jobs", "default", 90, Strategy.FIFO)
File without changes
@@ -1,112 +0,0 @@
1
- from orionis.foundation.exceptions import OrionisIntegrityException
2
- from orionis.foundation.config.roots.paths import Paths
3
- from orionis.test.cases.asynchronous import AsyncTestCase
4
-
5
- class TestFoundationConfigRootPaths(AsyncTestCase):
6
- """
7
- Test suite for the `Paths` dataclass, which defines the project directory structure.
8
-
9
- This class contains asynchronous unit tests to verify the integrity, default values,
10
- type constraints, immutability, and metadata accessibility of the `Paths` dataclass.
11
- """
12
-
13
- def testDefaultPathsInstantiation(self):
14
- """
15
- Test instantiation of `Paths` with default values.
16
-
17
- Ensures that a `Paths` instance can be created using default arguments and
18
- that the resulting object is an instance of `Paths`.
19
-
20
- Returns
21
- -------
22
- None
23
- """
24
- paths = Paths()
25
- self.assertIsInstance(paths, Paths)
26
-
27
- def testAllPathsAreStrings(self):
28
- """
29
- Verify that all attributes of `Paths` are strings.
30
-
31
- Iterates through all fields of the `Paths` dataclass and asserts that each
32
- attribute is a non-empty string.
33
-
34
- Returns
35
- -------
36
- None
37
- """
38
- paths = Paths()
39
- for field_name in paths.__dataclass_fields__:
40
- value = getattr(paths, field_name)
41
- self.assertIsInstance(value, str)
42
- self.assertTrue(len(value) > 0)
43
-
44
- def testPathValidationRejectsNonStringValues(self):
45
- """
46
- Ensure non-string path values raise `OrionisIntegrityException`.
47
-
48
- Attempts to instantiate `Paths` with a non-string value for a path field
49
- and asserts that an `OrionisIntegrityException` is raised.
50
-
51
- Returns
52
- -------
53
- None
54
- """
55
- with self.assertRaises(OrionisIntegrityException):
56
- Paths(console=123)
57
-
58
- def testToDictReturnsCompleteDictionary(self):
59
- """
60
- Test that `toDict()` returns a complete dictionary of all path fields.
61
-
62
- Asserts that the dictionary returned by `toDict()` contains all fields
63
- defined in the `Paths` dataclass and that the dictionary has the correct length.
64
-
65
- Returns
66
- -------
67
- None
68
- """
69
- paths = Paths()
70
- path_dict = paths.toDict()
71
- self.assertIsInstance(path_dict, dict)
72
- self.assertEqual(len(path_dict), len(paths.__dataclass_fields__))
73
- for field in paths.__dataclass_fields__:
74
- self.assertIn(field, path_dict)
75
-
76
- def testFrozenDataclassBehavior(self):
77
- """
78
- Verify that the `Paths` dataclass is immutable (frozen).
79
-
80
- Attempts to modify an attribute of a `Paths` instance after creation and
81
- asserts that an exception is raised due to immutability.
82
-
83
- Returns
84
- -------
85
- None
86
- """
87
- paths = Paths()
88
- with self.assertRaises(Exception):
89
- paths.console_scheduler = 'new/path' # type: ignore
90
-
91
- def testPathMetadataIsAccessible(self):
92
- """
93
- Check accessibility and structure of path field metadata.
94
-
95
- Iterates through all fields of the `Paths` dataclass and asserts that each
96
- field's metadata contains both 'description' and 'default' keys, and that
97
- their values are of the expected types.
98
-
99
- Returns
100
- -------
101
- None
102
- """
103
- paths = Paths()
104
- for field in paths.__dataclass_fields__.values():
105
- metadata = field.metadata
106
- self.assertIn('description', metadata)
107
- self.assertIn('default', metadata)
108
- self.assertIsInstance(metadata['description'], str)
109
- default_value = metadata['default']
110
- if callable(default_value):
111
- default_value = default_value()
112
- self.assertIsInstance(default_value, str)
File without changes