orionis 0.405.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 (154) 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 +9 -9
  34. orionis/foundation/config/logging/entities/daily.py +8 -8
  35. orionis/foundation/config/logging/entities/hourly.py +6 -6
  36. orionis/foundation/config/logging/entities/logging.py +12 -18
  37. orionis/foundation/config/logging/entities/monthly.py +7 -7
  38. orionis/foundation/config/logging/entities/stack.py +5 -5
  39. orionis/foundation/config/logging/entities/weekly.py +6 -6
  40. orionis/foundation/config/mail/entities/file.py +9 -36
  41. orionis/foundation/config/mail/entities/mail.py +22 -40
  42. orionis/foundation/config/mail/entities/mailers.py +29 -44
  43. orionis/foundation/config/mail/entities/smtp.py +47 -48
  44. orionis/foundation/config/queue/entities/brokers.py +19 -41
  45. orionis/foundation/config/queue/entities/database.py +24 -46
  46. orionis/foundation/config/queue/entities/queue.py +28 -40
  47. orionis/foundation/config/roots/paths.py +272 -468
  48. orionis/foundation/config/session/entities/session.py +23 -53
  49. orionis/foundation/config/startup.py +165 -135
  50. orionis/foundation/config/testing/entities/testing.py +137 -122
  51. orionis/foundation/config/testing/enums/__init__.py +6 -2
  52. orionis/foundation/config/testing/enums/drivers.py +16 -0
  53. orionis/foundation/config/testing/enums/verbosity.py +18 -0
  54. orionis/foundation/contracts/application.py +152 -362
  55. orionis/foundation/providers/console_provider.py +24 -2
  56. orionis/foundation/providers/dumper_provider.py +24 -2
  57. orionis/foundation/providers/logger_provider.py +24 -2
  58. orionis/foundation/providers/path_resolver_provider.py +25 -2
  59. orionis/foundation/providers/progress_bar_provider.py +24 -2
  60. orionis/foundation/providers/testing_provider.py +39 -0
  61. orionis/foundation/providers/workers_provider.py +24 -2
  62. orionis/metadata/framework.py +1 -1
  63. orionis/services/environment/helpers/functions.py +1 -2
  64. orionis/services/environment/key/__init__.py +0 -0
  65. orionis/services/environment/key/key_generator.py +37 -0
  66. orionis/support/entities/__init__.py +0 -0
  67. orionis/support/entities/base.py +104 -0
  68. orionis/support/facades/testing.py +15 -0
  69. orionis/support/facades/workers.py +1 -1
  70. orionis/test/cases/asynchronous.py +0 -11
  71. orionis/test/cases/synchronous.py +0 -9
  72. orionis/test/contracts/dumper.py +11 -4
  73. orionis/test/contracts/kernel.py +5 -110
  74. orionis/test/contracts/logs.py +27 -65
  75. orionis/test/contracts/printer.py +16 -128
  76. orionis/test/contracts/test_result.py +100 -0
  77. orionis/test/contracts/unit_test.py +87 -150
  78. orionis/test/core/unit_test.py +608 -554
  79. orionis/test/entities/result.py +22 -2
  80. orionis/test/enums/__init__.py +0 -2
  81. orionis/test/enums/status.py +14 -9
  82. orionis/test/exceptions/config.py +9 -1
  83. orionis/test/exceptions/failure.py +34 -11
  84. orionis/test/exceptions/persistence.py +10 -2
  85. orionis/test/exceptions/runtime.py +9 -1
  86. orionis/test/exceptions/value.py +13 -1
  87. orionis/test/kernel.py +87 -289
  88. orionis/test/output/dumper.py +82 -18
  89. orionis/test/output/printer.py +399 -156
  90. orionis/test/records/logs.py +203 -82
  91. orionis/test/validators/__init__.py +33 -0
  92. orionis/test/validators/base_path.py +45 -0
  93. orionis/test/validators/execution_mode.py +45 -0
  94. orionis/test/validators/fail_fast.py +37 -0
  95. orionis/test/validators/folder_path.py +34 -0
  96. orionis/test/validators/module_name.py +31 -0
  97. orionis/test/validators/name_pattern.py +40 -0
  98. orionis/test/validators/pattern.py +36 -0
  99. orionis/test/validators/persistent.py +42 -0
  100. orionis/test/validators/persistent_driver.py +43 -0
  101. orionis/test/validators/print_result.py +37 -0
  102. orionis/test/validators/tags.py +37 -0
  103. orionis/test/validators/throw_exception.py +39 -0
  104. orionis/test/validators/verbosity.py +37 -0
  105. orionis/test/validators/web_report.py +35 -0
  106. orionis/test/validators/workers.py +31 -0
  107. orionis/test/view/render.py +48 -54
  108. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/METADATA +1 -1
  109. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/RECORD +149 -98
  110. tests/container/__init__.py +0 -0
  111. tests/container/context/__init__.py +0 -0
  112. tests/container/context/test_manager.py +27 -0
  113. tests/container/context/test_scope.py +23 -0
  114. tests/container/entities/__init__.py +0 -0
  115. tests/container/entities/test_binding.py +133 -0
  116. tests/container/enums/__init__.py +0 -0
  117. tests/container/enums/test_lifetimes.py +63 -0
  118. tests/container/facades/__init__.py +0 -0
  119. tests/container/facades/test_facade.py +61 -0
  120. tests/container/mocks/__init__.py +0 -0
  121. tests/container/mocks/mock_complex_classes.py +482 -0
  122. tests/container/mocks/mock_simple_classes.py +32 -0
  123. tests/container/providers/__init__.py +0 -0
  124. tests/container/providers/test_providers.py +48 -0
  125. tests/container/resolver/__init__.py +0 -0
  126. tests/container/resolver/test_resolver.py +55 -0
  127. tests/container/test_container.py +254 -0
  128. tests/container/test_singleton.py +98 -0
  129. tests/container/test_thread_safety.py +217 -0
  130. tests/container/validators/__init__.py +0 -0
  131. tests/container/validators/test_implements.py +140 -0
  132. tests/container/validators/test_is_abstract_class.py +99 -0
  133. tests/container/validators/test_is_callable.py +73 -0
  134. tests/container/validators/test_is_concrete_class.py +97 -0
  135. tests/container/validators/test_is_instance.py +105 -0
  136. tests/container/validators/test_is_not_subclass.py +117 -0
  137. tests/container/validators/test_is_subclass.py +115 -0
  138. tests/container/validators/test_is_valid_alias.py +113 -0
  139. tests/container/validators/test_lifetime.py +75 -0
  140. tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
  141. tests/metadata/test_metadata_framework.py +18 -18
  142. tests/testing/test_testing_result.py +117 -117
  143. tests/testing/test_testing_unit.py +209 -209
  144. orionis/foundation/config/base.py +0 -112
  145. orionis/test/arguments/parser.py +0 -187
  146. orionis/test/contracts/parser.py +0 -43
  147. orionis/test/entities/arguments.py +0 -38
  148. orionis/test/enums/execution_mode.py +0 -16
  149. /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
  150. /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
  151. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/WHEEL +0 -0
  152. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/licenses/LICENCE +0 -0
  153. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/top_level.txt +0 -0
  154. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/zip-safe +0 -0
@@ -3,79 +3,56 @@ from typing import Dict, List, Optional, Tuple
3
3
 
4
4
  class ITestLogs(ABC):
5
5
  """
6
- Abstract base class for test logging and report persistence.
7
-
8
- This interface defines the contract for managing test reports in a persistent
9
- storage system. Implementations should provide functionality to create, retrieve,
10
- and reset test report data while maintaining proper data validation and error
11
- handling.
12
-
13
- The interface supports chronological retrieval of reports and provides methods
14
- for database management operations.
15
-
16
- Methods
17
- -------
18
- create(report)
19
- Create and store a new test report in the persistence layer.
20
- reset()
21
- Reset the storage by clearing all existing test reports.
22
- get(first, last)
23
- Retrieve test reports with optional chronological filtering.
6
+ Interface for test logs persistence using a relational database.
24
7
  """
25
8
 
26
9
  @abstractmethod
27
10
  def create(self, report: Dict) -> bool:
28
11
  """
29
- Create a new test report in the history database.
30
-
31
- This method persists a test report containing execution results and
32
- metadata to the underlying storage system. The report should include
33
- all necessary fields for proper tracking and analysis.
12
+ Store a new test report in the database.
34
13
 
35
14
  Parameters
36
15
  ----------
37
16
  report : Dict
38
- A dictionary containing the test report data. Must include fields
39
- such as total_tests, passed, failed, errors, skipped, total_time,
40
- success_rate, and timestamp.
17
+ Must include the following keys:
18
+ - json (str): JSON-serialized report.
19
+ - total_tests (int)
20
+ - passed (int)
21
+ - failed (int)
22
+ - errors (int)
23
+ - skipped (int)
24
+ - total_time (float)
25
+ - success_rate (float)
26
+ - timestamp (str)
41
27
 
42
28
  Returns
43
29
  -------
44
30
  bool
45
- True if the report was successfully created and stored, False otherwise.
31
+ True if the report was stored successfully.
46
32
 
47
33
  Raises
48
34
  ------
49
35
  OrionisTestValueError
50
- If the report structure is invalid or missing required fields.
36
+ If required fields are missing or invalid.
51
37
  OrionisTestPersistenceError
52
- If there is an error during the storage operation.
38
+ If a database error occurs.
53
39
  """
54
40
  pass
55
41
 
56
42
  @abstractmethod
57
43
  def reset(self) -> bool:
58
44
  """
59
- Reset the history database by dropping the existing table.
60
-
61
- This method clears all stored test reports and resets the storage
62
- system to its initial state. Use with caution as this operation
63
- is irreversible and will result in permanent data loss.
45
+ Drop the reports table, removing all test history.
64
46
 
65
47
  Returns
66
48
  -------
67
49
  bool
68
- True if the database was successfully reset, False otherwise.
50
+ True if the table was dropped or did not exist.
69
51
 
70
52
  Raises
71
53
  ------
72
54
  OrionisTestPersistenceError
73
- If there is an error during the reset operation.
74
-
75
- Notes
76
- -----
77
- This operation is destructive and cannot be undone. Ensure that
78
- any important historical data is backed up before calling this method.
55
+ If a database error occurs.
79
56
  """
80
57
  pass
81
58
 
@@ -86,40 +63,25 @@ class ITestLogs(ABC):
86
63
  last: Optional[int] = None
87
64
  ) -> List[Tuple]:
88
65
  """
89
- Retrieve test reports from the history database.
90
-
91
- This method allows for chronological retrieval of test reports with
92
- optional filtering. You can retrieve either the earliest or most recent
93
- reports, but not both in a single call.
66
+ Retrieve test reports from the database.
94
67
 
95
68
  Parameters
96
69
  ----------
97
- first : Optional[int], default=None
98
- The number of earliest reports to retrieve, ordered ascending by ID.
99
- Must be a positive integer if specified.
100
- last : Optional[int], default=None
101
- The number of latest reports to retrieve, ordered descending by ID.
102
- Must be a positive integer if specified.
70
+ first : Optional[int]
71
+ Number of earliest reports (ascending by id).
72
+ last : Optional[int]
73
+ Number of latest reports (descending by id).
103
74
 
104
75
  Returns
105
76
  -------
106
77
  List[Tuple]
107
- A list of tuples representing the retrieved reports. Each tuple
108
- contains the report data in the order: (id, json, total_tests,
109
- passed, failed, errors, skipped, total_time, success_rate, timestamp).
78
+ Each tuple: (id, json, total_tests, passed, failed, errors, skipped, total_time, success_rate, timestamp)
110
79
 
111
80
  Raises
112
81
  ------
113
82
  OrionisTestValueError
114
- If both 'first' and 'last' are specified, or if either parameter
115
- is not a positive integer when provided.
83
+ If both 'first' and 'last' are specified, or if either is not a positive integer.
116
84
  OrionisTestPersistenceError
117
- If there is an error retrieving reports from the storage system.
118
-
119
- Notes
120
- -----
121
- Only one of 'first' or 'last' parameters can be specified in a single
122
- call. The returned results are ordered chronologically based on the
123
- selected parameter.
85
+ If a database error occurs.
124
86
  """
125
- pass
87
+ pass
@@ -1,5 +1,6 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from typing import Any, Dict
3
+ from orionis.test.entities.result import TestResult
3
4
 
4
5
  class ITestPrinter(ABC):
5
6
 
@@ -8,106 +9,37 @@ class ITestPrinter(ABC):
8
9
  self,
9
10
  value: Any
10
11
  ) -> None:
11
- """
12
- Prints a value to the console using the rich console.
13
- Parameters
14
- ----------
15
- value : Any
16
- The value to be printed. It can be a string, object, or any other type.
17
- Notes
18
- -----
19
- - If the value is a string, it is printed directly.
20
- - If the value is an object, its string representation is printed.
21
- - If the value is a list, each item is printed on a new line.
22
- """
12
+ """Prints a value to the console using the rich console."""
23
13
  pass
24
14
 
25
15
  @abstractmethod
26
16
  def startMessage(
27
17
  self,
28
18
  *,
29
- print_result: bool,
30
19
  length_tests: int,
31
20
  execution_mode: str,
32
21
  max_workers: int
33
22
  ):
34
- """
35
- Displays a formatted start message for the test execution session.
36
-
37
- Parameters
38
- ----------
39
- print_result : bool
40
- Whether to print the start message.
41
- length_tests : int
42
- The total number of tests to be executed.
43
- execution_mode : str
44
- The mode of execution, either "parallel" or "sequential".
45
- max_workers : int
46
- The number of worker threads/processes for parallel execution.
47
-
48
- Side Effects
49
- ------------
50
- Prints a styled panel with test session information to the console if `print_result` is True.
51
- """
23
+ """Displays a formatted start message for the test execution session."""
52
24
  pass
53
25
 
54
26
  @abstractmethod
55
27
  def finishMessage(
56
28
  self,
57
29
  *,
58
- print_result: bool,
59
30
  summary: Dict[str, Any]
60
31
  ) -> None:
61
- """
62
- Display a summary message for the test suite execution.
63
-
64
- Parameters
65
- ----------
66
- summary : dict
67
- Dictionary containing the test suite summary, including keys such as
68
- 'failed', 'errors', and 'total_time'.
69
-
70
- Notes
71
- -----
72
- - If `self.print_result` is False, the method returns without displaying anything.
73
- - Shows a status icon (✅ for success, ❌ for failure) based on the presence of
74
- failures or errors in the test suite.
75
- - Formats and prints the message within a styled panel using the `rich` library.
76
- """
32
+ """Display a summary message for the test suite execution."""
77
33
  pass
78
34
 
79
35
  @abstractmethod
80
36
  def executePanel(
81
37
  self,
82
38
  *,
83
- print_result: bool,
84
39
  flatten_test_suite: list,
85
40
  callable: callable
86
41
  ):
87
- """
88
- Executes a test suite panel with optional live console output.
89
-
90
- Parameters
91
- ----------
92
- print_result : bool
93
- If True, displays a running message panel while executing the test suite.
94
- flatten_test_suite : list
95
- The flattened list of test cases or test suite items to be executed.
96
- callable : callable
97
- The function or method to execute the test suite.
98
-
99
- Returns
100
- -------
101
- Any
102
- The result returned by the provided callable after execution.
103
-
104
- Notes
105
- -----
106
- This method manages the display of a running message panel using the Rich library,
107
- depending on whether debugging is enabled in the test suite and whether results should be printed.
108
- If debugging or dump calls are detected in the test code, a live console is used to display
109
- real-time updates. Otherwise, a static panel is shown before executing the test suite.
110
- """
42
+ """Executes a test suite panel with optional live console output."""
111
43
  pass
112
44
 
113
45
  @abstractmethod
@@ -115,14 +47,7 @@ class ITestPrinter(ABC):
115
47
  self,
116
48
  path: str
117
49
  ):
118
- """
119
- Prints an elegant invitation to view the test results, with an underlined path.
120
-
121
- Parameters
122
- ----------
123
- path : str or Path
124
- The path to the test results report.
125
- """
50
+ """Prints an invitation to view the test results, with an underlined path."""
126
51
  pass
127
52
 
128
53
  @abstractmethod
@@ -130,59 +55,22 @@ class ITestPrinter(ABC):
130
55
  self,
131
56
  summary: Dict[str, Any]
132
57
  ) -> None:
133
- """
134
- Prints a summary table of test results using the Rich library.
135
-
136
- Parameters
137
- ----------
138
- summary : dict
139
- Dictionary with the test summary data. Must contain the following keys:
140
- total_tests : int
141
- Total number of tests executed.
142
- passed : int
143
- Number of tests that passed.
144
- failed : int
145
- Number of tests that failed.
146
- errors : int
147
- Number of tests that had errors.
148
- skipped : int
149
- Number of tests that were skipped.
150
- total_time : float
151
- Total duration of the test execution in seconds.
152
- success_rate : float
153
- Percentage of tests that passed.
154
-
155
- Returns
156
- -------
157
- None
158
- """
58
+ """Prints a summary table of test results using the Rich library."""
159
59
  pass
160
60
 
161
61
  @abstractmethod
162
62
  def displayResults(
163
63
  self,
164
64
  *,
165
- print_result: bool,
166
65
  summary: Dict[str, Any]
167
66
  ) -> None:
168
- """
169
- Display the results of the test execution, including a summary table and detailed
170
- information about failed or errored tests grouped by their test classes.
171
-
172
- Parameters
173
- ----------
174
- summary : dict
175
- Dictionary containing the summary of the test execution, including test details,
176
- statuses, and execution times.
67
+ """Display the results of the test execution, including a summary table and details."""
68
+ pass
177
69
 
178
- Notes
179
- -----
180
- - Prints a summary table of the test results.
181
- - Groups failed and errored tests by their test class and displays them in a structured
182
- format using panels.
183
- - For each failed or errored test, displays the traceback in a syntax-highlighted panel
184
- with additional metadata such as the test method name and execution time.
185
- - Uses different icons and border colors to distinguish between failed and errored tests.
186
- - Calls a finishing message method after displaying all results.
187
- """
188
- pass
70
+ @abstractmethod
71
+ def unittestResult(
72
+ self,
73
+ test_result: TestResult
74
+ ) -> None:
75
+ """Display the result of a single unit test in a formatted manner."""
76
+ pass
@@ -0,0 +1,100 @@
1
+ import unittest
2
+ from abc import ABC, abstractmethod
3
+ from typing import List, Dict, Optional, Tuple
4
+ from orionis.test.entities.result import TestResult
5
+
6
+ class IOrionisTestResult(ABC):
7
+ """
8
+ Interface for OrionisTestResult, a custom test result collector that extends
9
+ unittest's TextTestResult to include rich execution metadata such as
10
+ execution time, error tracebacks, and reflection-based information.
11
+
12
+ Classes implementing this interface are responsible for capturing detailed
13
+ information about each test case execution, including success, failure,
14
+ error, and skip states.
15
+ """
16
+
17
+ @property
18
+ @abstractmethod
19
+ def test_results(self) -> List[TestResult]:
20
+ """
21
+ A list containing the detailed results of each executed test case.
22
+
23
+ Each entry is an instance of `TestResult`, storing metadata such as
24
+ status, execution time, method name, module, file, and optional error info.
25
+ """
26
+ pass
27
+
28
+ @property
29
+ @abstractmethod
30
+ def _test_timings(self) -> Dict[unittest.case.TestCase, float]:
31
+ """
32
+ Internal mapping from each test case to its execution duration in seconds.
33
+ Used to compute elapsed time between `startTest()` and `stopTest()`.
34
+ """
35
+ pass
36
+
37
+ @property
38
+ @abstractmethod
39
+ def _current_test_start(self) -> Optional[float]:
40
+ """
41
+ Timestamp (in seconds) marking the beginning of the currently running test.
42
+ Used internally to calculate duration.
43
+ """
44
+ pass
45
+
46
+ @abstractmethod
47
+ def startTest(self, test: unittest.case.TestCase) -> None:
48
+ """
49
+ Called before the test is run.
50
+
51
+ Records the current start time for the test case in `_current_test_start`.
52
+ """
53
+ pass
54
+
55
+ @abstractmethod
56
+ def stopTest(self, test: unittest.case.TestCase) -> None:
57
+ """
58
+ Called after the test has run.
59
+
60
+ Calculates and stores the execution time for the test in `_test_timings`.
61
+ """
62
+ pass
63
+
64
+ @abstractmethod
65
+ def addSuccess(self, test: unittest.case.TestCase) -> None:
66
+ """
67
+ Called when a test case completes successfully.
68
+
69
+ Appends a `TestResult` instance with status `PASSED` to `test_results`.
70
+ """
71
+ pass
72
+
73
+ @abstractmethod
74
+ def addFailure(self, test: unittest.case.TestCase, err: Tuple[BaseException, BaseException, object]) -> None:
75
+ """
76
+ Called when a test case fails due to an assertion failure.
77
+
78
+ Captures and appends a `TestResult` instance with status `FAILED`, along
79
+ with traceback and error message.
80
+ """
81
+ pass
82
+
83
+ @abstractmethod
84
+ def addError(self, test: unittest.case.TestCase, err: Tuple[BaseException, BaseException, object]) -> None:
85
+ """
86
+ Called when a test case encounters an unexpected error or exception.
87
+
88
+ Captures and appends a `TestResult` instance with status `ERRORED`, along
89
+ with traceback and error message.
90
+ """
91
+ pass
92
+
93
+ @abstractmethod
94
+ def addSkip(self, test: unittest.case.TestCase, reason: str) -> None:
95
+ """
96
+ Called when a test case is skipped.
97
+
98
+ Appends a `TestResult` instance with status `SKIPPED` and reason to `test_results`.
99
+ """
100
+ pass