orionis 0.404.0__py3-none-any.whl → 0.406.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 (165) hide show
  1. orionis/console/base/command.py +57 -50
  2. orionis/console/base/contracts/command.py +68 -0
  3. orionis/console/dynamic/contracts/progress_bar.py +3 -3
  4. orionis/console/dynamic/progress_bar.py +8 -8
  5. orionis/console/output/console.py +8 -2
  6. orionis/console/output/contracts/console.py +1 -1
  7. orionis/container/container.py +2 -2
  8. orionis/container/context/scope.py +4 -1
  9. orionis/container/contracts/service_provider.py +2 -2
  10. orionis/container/entities/binding.py +31 -44
  11. orionis/container/enums/lifetimes.py +22 -1
  12. orionis/container/facades/facade.py +1 -2
  13. orionis/container/providers/service_provider.py +2 -2
  14. orionis/foundation/application.py +542 -248
  15. orionis/foundation/config/app/entities/app.py +107 -90
  16. orionis/foundation/config/auth/entities/auth.py +4 -33
  17. orionis/foundation/config/cache/entities/cache.py +18 -41
  18. orionis/foundation/config/cache/entities/file.py +8 -35
  19. orionis/foundation/config/cache/entities/stores.py +17 -38
  20. orionis/foundation/config/cors/entities/cors.py +41 -54
  21. orionis/foundation/config/database/entities/connections.py +40 -56
  22. orionis/foundation/config/database/entities/database.py +11 -38
  23. orionis/foundation/config/database/entities/mysql.py +48 -76
  24. orionis/foundation/config/database/entities/oracle.py +30 -57
  25. orionis/foundation/config/database/entities/pgsql.py +45 -61
  26. orionis/foundation/config/database/entities/sqlite.py +26 -53
  27. orionis/foundation/config/filesystems/entitites/aws.py +28 -49
  28. orionis/foundation/config/filesystems/entitites/disks.py +27 -47
  29. orionis/foundation/config/filesystems/entitites/filesystems.py +15 -37
  30. orionis/foundation/config/filesystems/entitites/local.py +9 -35
  31. orionis/foundation/config/filesystems/entitites/public.py +14 -41
  32. orionis/foundation/config/logging/entities/channels.py +56 -86
  33. orionis/foundation/config/logging/entities/chunked.py +18 -10
  34. orionis/foundation/config/logging/entities/daily.py +17 -9
  35. orionis/foundation/config/logging/entities/hourly.py +15 -7
  36. orionis/foundation/config/logging/entities/logging.py +12 -18
  37. orionis/foundation/config/logging/entities/monthly.py +16 -8
  38. orionis/foundation/config/logging/entities/stack.py +15 -7
  39. orionis/foundation/config/logging/entities/weekly.py +15 -7
  40. orionis/foundation/config/logging/validators/path.py +6 -0
  41. orionis/foundation/config/mail/entities/file.py +9 -36
  42. orionis/foundation/config/mail/entities/mail.py +22 -40
  43. orionis/foundation/config/mail/entities/mailers.py +29 -44
  44. orionis/foundation/config/mail/entities/smtp.py +47 -48
  45. orionis/foundation/config/queue/entities/brokers.py +19 -41
  46. orionis/foundation/config/queue/entities/database.py +24 -46
  47. orionis/foundation/config/queue/entities/queue.py +28 -40
  48. orionis/foundation/config/roots/paths.py +272 -468
  49. orionis/foundation/config/session/entities/session.py +23 -53
  50. orionis/foundation/config/startup.py +165 -135
  51. orionis/foundation/config/testing/entities/testing.py +137 -122
  52. orionis/foundation/config/testing/enums/__init__.py +6 -2
  53. orionis/foundation/config/testing/enums/drivers.py +16 -0
  54. orionis/foundation/config/testing/enums/verbosity.py +18 -0
  55. orionis/foundation/contracts/application.py +152 -362
  56. orionis/foundation/providers/console_provider.py +24 -2
  57. orionis/foundation/providers/dumper_provider.py +24 -2
  58. orionis/foundation/providers/logger_provider.py +24 -2
  59. orionis/foundation/providers/path_resolver_provider.py +25 -2
  60. orionis/foundation/providers/progress_bar_provider.py +24 -2
  61. orionis/foundation/providers/testing_provider.py +39 -0
  62. orionis/foundation/providers/workers_provider.py +24 -2
  63. orionis/metadata/framework.py +1 -1
  64. orionis/services/environment/helpers/functions.py +1 -2
  65. orionis/services/environment/key/__init__.py +0 -0
  66. orionis/services/environment/key/key_generator.py +37 -0
  67. orionis/services/log/handlers/filename.py +64 -0
  68. orionis/services/log/handlers/size_rotating.py +9 -40
  69. orionis/services/log/handlers/timed_rotating.py +9 -41
  70. orionis/services/log/log_service.py +9 -52
  71. orionis/support/entities/__init__.py +0 -0
  72. orionis/support/entities/base.py +104 -0
  73. orionis/support/facades/testing.py +15 -0
  74. orionis/support/facades/workers.py +1 -1
  75. orionis/test/cases/asynchronous.py +0 -11
  76. orionis/test/cases/synchronous.py +0 -9
  77. orionis/test/contracts/dumper.py +11 -4
  78. orionis/test/contracts/kernel.py +5 -110
  79. orionis/test/contracts/logs.py +27 -65
  80. orionis/test/contracts/printer.py +16 -128
  81. orionis/test/contracts/test_result.py +100 -0
  82. orionis/test/contracts/unit_test.py +87 -150
  83. orionis/test/core/unit_test.py +608 -554
  84. orionis/test/entities/result.py +22 -2
  85. orionis/test/enums/__init__.py +0 -2
  86. orionis/test/enums/status.py +14 -9
  87. orionis/test/exceptions/config.py +9 -1
  88. orionis/test/exceptions/failure.py +34 -11
  89. orionis/test/exceptions/persistence.py +10 -2
  90. orionis/test/exceptions/runtime.py +9 -1
  91. orionis/test/exceptions/value.py +13 -1
  92. orionis/test/kernel.py +87 -289
  93. orionis/test/output/dumper.py +82 -18
  94. orionis/test/output/printer.py +399 -156
  95. orionis/test/records/logs.py +203 -82
  96. orionis/test/validators/__init__.py +33 -0
  97. orionis/test/validators/base_path.py +45 -0
  98. orionis/test/validators/execution_mode.py +45 -0
  99. orionis/test/validators/fail_fast.py +37 -0
  100. orionis/test/validators/folder_path.py +34 -0
  101. orionis/test/validators/module_name.py +31 -0
  102. orionis/test/validators/name_pattern.py +40 -0
  103. orionis/test/validators/pattern.py +36 -0
  104. orionis/test/validators/persistent.py +42 -0
  105. orionis/test/validators/persistent_driver.py +43 -0
  106. orionis/test/validators/print_result.py +37 -0
  107. orionis/test/validators/tags.py +37 -0
  108. orionis/test/validators/throw_exception.py +39 -0
  109. orionis/test/validators/verbosity.py +37 -0
  110. orionis/test/validators/web_report.py +35 -0
  111. orionis/test/validators/workers.py +31 -0
  112. orionis/test/view/render.py +48 -54
  113. {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/METADATA +1 -1
  114. {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/RECORD +160 -108
  115. tests/container/__init__.py +0 -0
  116. tests/container/context/__init__.py +0 -0
  117. tests/container/context/test_manager.py +27 -0
  118. tests/container/context/test_scope.py +23 -0
  119. tests/container/entities/__init__.py +0 -0
  120. tests/container/entities/test_binding.py +133 -0
  121. tests/container/enums/__init__.py +0 -0
  122. tests/container/enums/test_lifetimes.py +63 -0
  123. tests/container/facades/__init__.py +0 -0
  124. tests/container/facades/test_facade.py +61 -0
  125. tests/container/mocks/__init__.py +0 -0
  126. tests/container/mocks/mock_complex_classes.py +482 -0
  127. tests/container/mocks/mock_simple_classes.py +32 -0
  128. tests/container/providers/__init__.py +0 -0
  129. tests/container/providers/test_providers.py +48 -0
  130. tests/container/resolver/__init__.py +0 -0
  131. tests/container/resolver/test_resolver.py +55 -0
  132. tests/container/test_container.py +254 -0
  133. tests/container/test_singleton.py +98 -0
  134. tests/container/test_thread_safety.py +217 -0
  135. tests/container/validators/__init__.py +0 -0
  136. tests/container/validators/test_implements.py +140 -0
  137. tests/container/validators/test_is_abstract_class.py +99 -0
  138. tests/container/validators/test_is_callable.py +73 -0
  139. tests/container/validators/test_is_concrete_class.py +97 -0
  140. tests/container/validators/test_is_instance.py +105 -0
  141. tests/container/validators/test_is_not_subclass.py +117 -0
  142. tests/container/validators/test_is_subclass.py +115 -0
  143. tests/container/validators/test_is_valid_alias.py +113 -0
  144. tests/container/validators/test_lifetime.py +75 -0
  145. tests/foundation/config/logging/test_foundation_config_logging_chunked.py +12 -34
  146. tests/foundation/config/logging/test_foundation_config_logging_daily.py +11 -11
  147. tests/foundation/config/logging/test_foundation_config_logging_hourly.py +7 -8
  148. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +7 -10
  149. tests/foundation/config/logging/test_foundation_config_logging_stack.py +6 -11
  150. tests/foundation/config/logging/test_foundation_config_logging_weekly.py +6 -5
  151. tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
  152. tests/metadata/test_metadata_framework.py +18 -18
  153. tests/testing/test_testing_result.py +117 -117
  154. tests/testing/test_testing_unit.py +209 -209
  155. orionis/foundation/config/base.py +0 -112
  156. orionis/test/arguments/parser.py +0 -187
  157. orionis/test/contracts/parser.py +0 -43
  158. orionis/test/entities/arguments.py +0 -38
  159. orionis/test/enums/execution_mode.py +0 -16
  160. /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
  161. /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
  162. {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/WHEEL +0 -0
  163. {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/licenses/LICENCE +0 -0
  164. {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/top_level.txt +0 -0
  165. {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/zip-safe +0 -0
@@ -0,0 +1,37 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidFailFast:
4
+
5
+ def __call__(self, fail_fast) -> bool:
6
+ """
7
+ Validator that ensures the `fail_fast` parameter is a boolean.
8
+
9
+ This class is intended to be used as a callable validator to check that the
10
+ provided `fail_fast` argument is of type `bool`. If the value is not a boolean,
11
+ an `OrionisTestValueError` is raised with a descriptive error message.
12
+
13
+ Parameters
14
+ ----------
15
+ fail_fast : Any
16
+ The value to be validated as a boolean.
17
+
18
+ Returns
19
+ -------
20
+ bool
21
+ The validated boolean value of `fail_fast`.
22
+
23
+ Raises
24
+ ------
25
+ OrionisTestValueError
26
+ If `fail_fast` is not of type `bool`.
27
+ """
28
+
29
+ if not isinstance(fail_fast, bool):
30
+ raise OrionisTestValueError(
31
+ f"Invalid fail_fast: Expected a boolean, got '{fail_fast}' ({type(fail_fast).__name__})."
32
+ )
33
+
34
+ return fail_fast
35
+
36
+ # Exported singleton instance
37
+ ValidFailFast = __ValidFailFast()
@@ -0,0 +1,34 @@
1
+ from pathlib import Path
2
+ from orionis.test.exceptions import OrionisTestValueError
3
+
4
+ class __ValidFolderPath:
5
+
6
+ def __call__(self, folder_path: str) -> str:
7
+ """
8
+ Validate and clean a folder path string.
9
+
10
+ Parameters
11
+ ----------
12
+ folder_path : str
13
+ The folder path to validate.
14
+
15
+ Returns
16
+ -------
17
+ str
18
+ The cleaned folder path string.
19
+
20
+ Raises
21
+ ------
22
+ OrionisTestValueError
23
+ If the folder_path is not a non-empty string.
24
+ """
25
+
26
+ if not isinstance(folder_path, str) or not folder_path.strip():
27
+ raise OrionisTestValueError(
28
+ f"Invalid folder_path: Expected a non-empty string, got '{str(folder_path)}' ({type(folder_path).__name__})."
29
+ )
30
+
31
+ return folder_path.strip()
32
+
33
+ # Exported singleton instance
34
+ ValidFolderPath = __ValidFolderPath()
@@ -0,0 +1,31 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidModuleName:
4
+
5
+ def __call__(self, module_name) -> str:
6
+ """
7
+ Validator that ensures the `module_name` parameter is a non-empty string.
8
+
9
+ Parameters
10
+ ----------
11
+ module_name : Any
12
+ The value to be validated as a non-empty string.
13
+
14
+ Returns
15
+ -------
16
+ str
17
+ The validated and stripped string value of `module_name`.
18
+
19
+ Raises
20
+ ------
21
+ OrionisTestValueError
22
+ If `module_name` is not a non-empty string.
23
+ """
24
+ if not module_name or not isinstance(module_name, str):
25
+ raise OrionisTestValueError(
26
+ f"Invalid module_name: Expected a non-empty string, got '{module_name}' ({type(module_name).__name__})."
27
+ )
28
+ return module_name
29
+
30
+ # Exported singleton instance
31
+ ValidModuleName = __ValidModuleName()
@@ -0,0 +1,40 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidNamePattern:
4
+
5
+ def __call__(self, test_name_pattern) -> str:
6
+ """
7
+ Validator that ensures the `test_name_pattern` parameter is a non-empty string.
8
+
9
+ This class is intended to be used as a callable validator to check that the
10
+ provided `test_name_pattern` argument is a non-empty string. If the value is not a valid
11
+ string, an `OrionisTestValueError` is raised with a descriptive error message.
12
+
13
+ Parameters
14
+ ----------
15
+ test_name_pattern : Any
16
+ The value to be validated as a non-empty string.
17
+
18
+ Returns
19
+ -------
20
+ str
21
+ The validated and stripped string value of `test_name_pattern`.
22
+
23
+ Raises
24
+ ------
25
+ OrionisTestValueError
26
+ If `test_name_pattern` is not a non-empty string.
27
+ """
28
+
29
+ if test_name_pattern is not None:
30
+
31
+ if not isinstance(test_name_pattern, str) or not test_name_pattern.strip():
32
+ raise OrionisTestValueError(
33
+ f"Invalid test_name_pattern: Expected a non-empty string, got '{str(test_name_pattern)}' ({type(test_name_pattern).__name__})."
34
+ )
35
+ return test_name_pattern.strip()
36
+
37
+ return test_name_pattern
38
+
39
+ # Exported singleton instance
40
+ ValidNamePattern = __ValidNamePattern()
@@ -0,0 +1,36 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidPattern:
4
+
5
+ def __call__(self, pattern) -> str:
6
+ """
7
+ Validator that ensures the `pattern` parameter is a non-empty string.
8
+
9
+ This class is intended to be used as a callable validator to check that the
10
+ provided `pattern` argument is a non-empty string. If the value is not a valid
11
+ string, an `OrionisTestValueError` is raised with a descriptive error message.
12
+
13
+ Parameters
14
+ ----------
15
+ pattern : Any
16
+ The value to be validated as a non-empty string.
17
+
18
+ Returns
19
+ -------
20
+ str
21
+ The validated and stripped string value of `pattern`.
22
+
23
+ Raises
24
+ ------
25
+ OrionisTestValueError
26
+ If `pattern` is not a non-empty string.
27
+ """
28
+
29
+ if not isinstance(pattern, str) or not pattern.strip():
30
+ raise OrionisTestValueError(
31
+ f"Invalid pattern: Expected a non-empty string, got '{str(pattern)}' ({type(pattern).__name__})."
32
+ )
33
+ return pattern.strip()
34
+
35
+ # Exported singleton instance
36
+ ValidPattern = __ValidPattern()
@@ -0,0 +1,42 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidPersistent:
4
+
5
+ def __call__(self, persistent) -> bool:
6
+ """
7
+ Validator that ensures the `persistent` parameter is a boolean.
8
+
9
+ This class is intended to be used as a callable validator to check if the
10
+ provided value for `persistent` is of type `bool`. If the value is not a
11
+ boolean, an `OrionisTestValueError` is raised.
12
+
13
+ Methods
14
+ -------
15
+ __call__(persistent) -> bool
16
+ Validates that `persistent` is a boolean.
17
+
18
+ Parameters
19
+ ----------
20
+ persistent : Any
21
+ The value to be validated as a boolean.
22
+
23
+ Returns
24
+ -------
25
+ bool
26
+ Returns the value of `persistent` if it is a boolean.
27
+
28
+ Raises
29
+ ------
30
+ OrionisTestValueError
31
+ If `persistent` is not a boolean.
32
+ """
33
+
34
+ if not isinstance(persistent, bool):
35
+ raise OrionisTestValueError(
36
+ f"Invalid persistent: Expected a boolean, got '{persistent}' ({type(persistent).__name__})."
37
+ )
38
+
39
+ return persistent
40
+
41
+ # Exported singleton instance
42
+ ValidPersistent = __ValidPersistent()
@@ -0,0 +1,43 @@
1
+ from orionis.foundation.config.testing.enums.drivers import PersistentDrivers
2
+ from orionis.test.exceptions import OrionisTestValueError
3
+
4
+ class __ValidPersistentDriver:
5
+
6
+ def __call__(self, persistent_driver) -> str:
7
+ """
8
+ Validator class for persistent driver types.
9
+ This class is intended to validate the value of a persistent driver, ensuring
10
+ that it is a string or PersistentDrivers enum and one of the accepted values.
11
+ Methods
12
+ -------
13
+ __call__(persistent_driver: str | PersistentDrivers) -> str
14
+ Validates the given persistent driver. Raises an OrionisTestValueError if
15
+ the input is not a string or enum or not one of the accepted values.
16
+ Parameters
17
+ ----------
18
+ persistent_driver : str | PersistentDrivers
19
+ The persistent driver to validate. Must be either 'sqlite', 'json', or the corresponding enum.
20
+ Returns
21
+ -------
22
+ str
23
+ The validated persistent driver as a string.
24
+ Raises
25
+ ------
26
+ OrionisTestValueError
27
+ If the input is not a string/enum or not one of the accepted values.
28
+ """
29
+
30
+ if not isinstance(persistent_driver, (str, PersistentDrivers)):
31
+ raise OrionisTestValueError(
32
+ f"Invalid type for persistent_driver: Expected str or PersistentDrivers, got {type(persistent_driver).__name__}."
33
+ )
34
+ if isinstance(persistent_driver, PersistentDrivers):
35
+ return persistent_driver.value
36
+ if persistent_driver in [e.value for e in PersistentDrivers]:
37
+ return persistent_driver
38
+ raise OrionisTestValueError(
39
+ f"Invalid persistent_driver: Expected one of {[e.value for e in PersistentDrivers]}, got '{persistent_driver}'."
40
+ )
41
+
42
+ # Export the validator instance singleton
43
+ ValidPersistentDriver = __ValidPersistentDriver()
@@ -0,0 +1,37 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidPrintResult:
4
+
5
+ def __call__(self, print_result) -> bool:
6
+ """
7
+ Validator that ensures the `print_result` parameter is a boolean.
8
+
9
+ This class is intended to be used as a callable validator to check that the
10
+ provided `print_result` argument is of type `bool`. If the validation fails,
11
+ an `OrionisTestValueError` is raised.
12
+
13
+ Parameters
14
+ ----------
15
+ print_result : Any
16
+ The value to be validated as a boolean.
17
+
18
+ Returns
19
+ -------
20
+ bool
21
+ Returns the validated boolean value of `print_result`.
22
+
23
+ Raises
24
+ ------
25
+ OrionisTestValueError
26
+ If `print_result` is not of type `bool`.
27
+ """
28
+
29
+ if not isinstance(print_result, bool):
30
+ raise OrionisTestValueError(
31
+ f"Invalid print_result: Expected a boolean, got '{print_result}' ({type(print_result).__name__})."
32
+ )
33
+
34
+ return print_result
35
+
36
+ # Exported singleton instance
37
+ ValidPrintResult = __ValidPrintResult()
@@ -0,0 +1,37 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidTags:
4
+
5
+ def __call__(self, tags):
6
+ """
7
+ Validator that ensures the `tags` parameter is a non-empty list of non-empty strings.
8
+
9
+ Parameters
10
+ ----------
11
+ tags : Any
12
+ The value to be validated as a list of non-empty strings.
13
+
14
+ Returns
15
+ -------
16
+ list
17
+ The validated and stripped list of tags.
18
+
19
+ Raises
20
+ ------
21
+ OrionisTestValueError
22
+ If `tags` is not a non-empty list of non-empty strings.
23
+ """
24
+
25
+ if tags is not None:
26
+
27
+ if (not isinstance(tags, list) or not tags or not all(isinstance(tag, str) and tag.strip() for tag in tags)):
28
+ raise OrionisTestValueError(
29
+ f"Invalid tags: Expected a non-empty list of non-empty strings, got '{tags}' ({type(tags).__name__})."
30
+ )
31
+
32
+ return [str(tag).strip() for tag in tags]
33
+
34
+ return None
35
+
36
+ # Exported singleton instance
37
+ ValidTags = __ValidTags()
@@ -0,0 +1,39 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidThrowException:
4
+
5
+ def __call__(self, throw_exception) -> bool:
6
+ """
7
+ __ValidThrowException is a validator class that ensures the `throw_exception` parameter is a boolean.
8
+
9
+ Methods
10
+ -------
11
+ __call__(throw_exception) -> bool
12
+ Validates that the input `throw_exception` is of type `bool`. If not, raises an OrionisTestValueError
13
+ with a descriptive message. Returns the validated boolean value.
14
+
15
+ Parameters
16
+ ----------
17
+ throw_exception : Any
18
+ The value to be validated as a boolean.
19
+
20
+ Raises
21
+ ------
22
+ OrionisTestValueError
23
+ If `throw_exception` is not a boolean.
24
+
25
+ Returns
26
+ -------
27
+ bool
28
+ The validated boolean value of `throw_exception`.
29
+ """
30
+
31
+ if not isinstance(throw_exception, bool):
32
+ raise OrionisTestValueError(
33
+ f"Invalid throw_exception: Expected a boolean, got '{throw_exception}' ({type(throw_exception).__name__})."
34
+ )
35
+
36
+ return throw_exception
37
+
38
+ # Exported singleton instance
39
+ ValidThrowException = __ValidThrowException()
@@ -0,0 +1,37 @@
1
+ from orionis.foundation.config.testing.enums.verbosity import VerbosityMode
2
+ from orionis.test.exceptions import OrionisTestValueError
3
+
4
+ class __ValidVerbosity:
5
+ """
6
+ Validator that ensures the verbosity level is a non-negative integer or a valid VerbosityMode.
7
+ """
8
+
9
+ def __call__(self, verbosity) -> int:
10
+ """
11
+ Ensures that the provided verbosity is a non-negative integer or a valid VerbosityMode.
12
+
13
+ Parameters
14
+ ----------
15
+ verbosity : int or VerbosityMode
16
+ The verbosity level to validate.
17
+
18
+ Raises
19
+ ------
20
+ OrionisTestValueError
21
+ If the verbosity is not a non-negative integer or a valid VerbosityMode.
22
+ """
23
+ if isinstance(verbosity, VerbosityMode):
24
+ return verbosity.value
25
+ if isinstance(verbosity, int) and verbosity >= 0:
26
+ if verbosity in [mode.value for mode in VerbosityMode]:
27
+ return verbosity
28
+ else:
29
+ raise OrionisTestValueError(
30
+ f"Invalid verbosity level: {verbosity} is not a valid VerbosityMode value."
31
+ )
32
+ raise OrionisTestValueError(
33
+ f"Invalid verbosity level: Expected a non-negative integer or VerbosityMode, got '{verbosity}' ({type(verbosity).__name__})."
34
+ )
35
+
36
+ # Exported singleton instance
37
+ ValidVerbosity = __ValidVerbosity()
@@ -0,0 +1,35 @@
1
+ from orionis.test.exceptions import OrionisTestValueError
2
+
3
+ class __ValidWebReport:
4
+
5
+ def __call__(self, web_report) -> bool:
6
+ """
7
+ Validator class to check if the input is a boolean value.
8
+ This class is intended to be used as a callable to validate whether the provided
9
+ `web_report` argument is of type `bool`. If the input is not a boolean, an
10
+ `OrionisTestValueError` is raised with a descriptive error message.
11
+
12
+ Parameters
13
+ ----------
14
+ None
15
+
16
+ Methods
17
+ -------
18
+ __call__(web_report)
19
+ Validates that `web_report` is a boolean value.
20
+
21
+ Raises
22
+ ------
23
+ OrionisTestValueError
24
+ If `web_report` is not of type `bool`.
25
+ """
26
+
27
+ if not isinstance(web_report, bool):
28
+ raise OrionisTestValueError(
29
+ f"Invalid web_report: Expected a boolean, got '{web_report}' ({type(web_report).__name__})."
30
+ )
31
+
32
+ return web_report
33
+
34
+ # Exported singleton instance
35
+ ValidWebReport = __ValidWebReport()
@@ -0,0 +1,31 @@
1
+ from orionis.support.facades.workers import Workers
2
+ from orionis.test.exceptions import OrionisTestValueError
3
+
4
+ class __ValidWorkers:
5
+ """
6
+ Validator that ensures max_workers is a positive integer within allowed range.
7
+ """
8
+
9
+ def __call__(self, max_workers: int) -> int:
10
+ """
11
+ Ensures that the provided max_workers is a positive integer within allowed range.
12
+
13
+ Parameters
14
+ ----------
15
+ max_workers : int
16
+ The max_workers value to validate.
17
+
18
+ Raises
19
+ ------
20
+ OrionisTestValueError
21
+ If max_workers is not a positive integer within allowed range.
22
+ """
23
+ max_allowed = Workers.calculate()
24
+ if not isinstance(max_workers, int) or max_workers < 1 or max_workers > max_allowed:
25
+ raise OrionisTestValueError(
26
+ f"Invalid max_workers: Expected a positive integer between 1 and {max_allowed}, got '{max_workers}' ({type(max_workers).__name__})."
27
+ )
28
+ return max_workers
29
+
30
+ # Exported singleton instance
31
+ ValidWorkers = __ValidWorkers()
@@ -1,7 +1,6 @@
1
1
  import json
2
2
  import os
3
3
  from pathlib import Path
4
- from orionis.services.environment.env import Env
5
4
  from orionis.test.contracts.render import ITestingResultRender
6
5
  from orionis.test.records.logs import TestLogs
7
6
 
@@ -10,56 +9,44 @@ class TestingResultRender(ITestingResultRender):
10
9
  def __init__(
11
10
  self,
12
11
  result,
13
- storage_path:str = None,
14
- persist=False
12
+ storage_path: str,
13
+ persist: bool = False
15
14
  ) -> None:
16
15
  """
17
- Initialize the TestingResultRender object.
16
+ Initialize a TestingResultRender instance for rendering test results.
17
+
18
+ This constructor sets up the renderer with the provided test result data,
19
+ determines the storage location for the generated report, and configures
20
+ whether persistent storage (e.g., SQLite) should be used for storing and
21
+ retrieving test reports.
18
22
 
19
23
  Parameters
20
24
  ----------
21
25
  result : Any
22
- The test result data to be processed or stored.
23
- storage_path : str, optional
24
- Custom path to store the test report. If not provided, uses the environment variable
25
- 'TEST_REPORT_PATH' or defaults to a local storage path.
26
+ The test result data to be rendered and included in the report.
27
+ storage_path : str
28
+ The directory path where the HTML report will be saved. If the directory
29
+ does not exist, it will be created automatically.
26
30
  persist : bool, optional
27
- Whether to persist the report. Defaults to False.
31
+ If True, enables persistent storage for test reports (default is False).
28
32
 
29
- Notes
30
- -----
31
- - Determines the file path for the test report based on the provided storage_path, environment variable,
32
- or a default location.
33
- - Ensures the parent directory for the report exists.
34
- - Stores the resolved report path in the environment variable 'TEST_REPORT_PATH'.
33
+ Returns
34
+ -------
35
+ None
36
+ This constructor does not return a value. It initializes internal state
37
+ and prepares the report path for future rendering.
35
38
  """
36
-
37
- # Initialize instance variables
38
- self.__filename = 'test-results.html'
39
+ self.__filename = 'orionis-test-results.html'
39
40
  self.__result = result
40
41
  self.__persist = persist
42
+ self.__storage_path = storage_path
41
43
 
42
- # Determine file path
43
- db_path = None
44
- if storage_path:
45
- db_path = Path(storage_path).expanduser().resolve()
46
- if db_path.is_dir():
47
- db_path = db_path / self.__filename
48
- else:
49
- env_path = Env.get("TEST_REPORT_PATH", None)
50
- if env_path:
51
- db_path = Path(env_path).expanduser().resolve()
52
- if db_path.is_dir():
53
- db_path = db_path / self.__filename
54
- else:
55
- db_path = Path.cwd() / 'storage/framework/testing' / self.__filename
56
-
57
- # Ensure parent directory exists
58
- db_path.parent.mkdir(parents=True, exist_ok=True)
44
+ # Ensure storage_path is a Path object and create the directory if it doesn't exist
45
+ storage_dir = Path(storage_path)
46
+ storage_dir.mkdir(parents=True, exist_ok=True)
59
47
 
60
- # Store path in environment
61
- Env.set("TEST_REPORT_PATH", str(db_path), 'path')
62
- self.__report_path = db_path
48
+ # Set the absolute path for the report file
49
+ self.__report_path = (storage_dir / self.__filename).resolve()
63
50
 
64
51
  def render(
65
52
  self
@@ -88,18 +75,26 @@ class TestingResultRender(ITestingResultRender):
88
75
 
89
76
  # Determine the source of test results based on persistence mode
90
77
  if self.__persist:
78
+
91
79
  # If persistence is enabled, fetch the last 10 reports from SQLite
92
- logs = TestLogs()
80
+ logs = TestLogs(self.__storage_path)
93
81
  reports = logs.get(last=10)
82
+
94
83
  # Parse each report's JSON data into a list
95
84
  results_list = [json.loads(report[1]) for report in reports]
85
+
96
86
  else:
87
+
97
88
  # If not persistent, use only the current in-memory result
98
89
  results_list = [self.__result]
99
90
 
100
91
  # Set placeholder values for the template
101
- persistence_mode = 'SQLite' if self.__persist else 'Static'
102
- test_results_json = json.dumps(results_list, ensure_ascii=False, indent=None)
92
+ persistence_mode = 'Database' if self.__persist else 'Memory'
93
+ test_results_json = json.dumps(
94
+ results_list,
95
+ ensure_ascii=False,
96
+ indent=None
97
+ )
103
98
 
104
99
  # Locate the HTML template file
105
100
  template_path = Path(__file__).parent / 'report.stub'
@@ -109,23 +104,22 @@ class TestingResultRender(ITestingResultRender):
109
104
  template_content = template_file.read()
110
105
 
111
106
  # Replace placeholders with actual values
112
- rendered_content = template_content.replace(
113
- '{{orionis-testing-result}}',
114
- test_results_json
115
- ).replace(
116
- '{{orionis-testing-persistent}}',
117
- persistence_mode
118
- )
107
+ rendered_content = template_content.replace('{{orionis-testing-result}}', test_results_json)\
108
+ .replace('{{orionis-testing-persistent}}', persistence_mode)
119
109
 
120
110
  # Write the rendered HTML report to the specified path
121
111
  with open(self.__report_path, 'w', encoding='utf-8') as report_file:
122
112
  report_file.write(rendered_content)
123
113
 
124
114
  # Open the generated report in the default web browser if running on Windows or macOS.
125
- # This provides immediate feedback to the user after report generation.
126
- if os.name == 'nt' or os.name == 'posix' and sys.platform == 'darwin':
127
- import webbrowser
128
- webbrowser.open(self.__report_path.as_uri())
115
+ try:
116
+
117
+ # Check the operating system and open the report in a web browser if applicable
118
+ if ((os.name == 'nt') or (os.name == 'posix' and sys.platform == 'darwin')):
119
+ import webbrowser
120
+ webbrowser.open(self.__report_path.as_uri())
121
+
122
+ finally:
129
123
 
130
- # Return the absolute path to the generated report
131
- return str(self.__report_path)
124
+ # Return the absolute path to the generated report
125
+ return str(self.__report_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orionis
3
- Version: 0.404.0
3
+ Version: 0.406.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro