orionis 0.282.0__py3-none-any.whl → 0.284.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/application.py +2 -7
- orionis/foundation/config/testing/entities/testing.py +25 -0
- orionis/metadata/framework.py +1 -1
- orionis/services/asynchrony/{async_io.py → coroutines.py} +2 -1
- orionis/services/asynchrony/exceptions/__init__.py +0 -0
- orionis/services/asynchrony/exceptions/coroutine_exception.py +26 -0
- orionis/services/environment/dot_env.py +44 -14
- orionis/services/environment/env.py +60 -12
- orionis/services/environment/exceptions/__init__.py +0 -0
- orionis/services/environment/exceptions/value_exception.py +27 -0
- orionis/services/introspection/exceptions/__init__.py +0 -0
- orionis/services/introspection/exceptions/types.py +0 -0
- orionis/services/introspection/helpers/__init__.py +0 -0
- orionis/services/introspection/helpers/functions.py +285 -0
- orionis/services/introspection/reflection.py +216 -0
- orionis/services/parsers/exceptions/__init__.py +0 -0
- orionis/services/parsers/serializer.py +1 -1
- orionis/services/paths/exceptions/__init__.py +0 -0
- orionis/services/paths/exceptions/not_found_exceptions.py +28 -0
- orionis/services/paths/exceptions/path_value_exceptions.py +28 -0
- orionis/services/paths/resolver.py +6 -4
- orionis/services/standard/exceptions/__init__.py +0 -0
- orionis/services/standard/exceptions/path_value_exceptions.py +28 -0
- orionis/services/standard/std.py +4 -3
- orionis/test/entities/test_result.py +14 -1
- orionis/test/exceptions/test_persistence_error.py +34 -0
- orionis/test/exceptions/test_runtime_error.py +26 -0
- orionis/test/exceptions/test_value_error.py +26 -0
- orionis/test/logs/contracts/__init__.py +0 -0
- orionis/test/logs/contracts/history.py +54 -0
- orionis/test/logs/history.py +372 -0
- orionis/test/output/contracts/dumper.py +24 -8
- orionis/test/output/dumper.py +52 -21
- orionis/test/suites/contracts/test_suite.py +27 -13
- orionis/test/suites/contracts/test_unit.py +101 -61
- orionis/test/suites/test_suite.py +57 -25
- orionis/test/suites/test_unit.py +559 -290
- orionis/unittesting.py +13 -1
- {orionis-0.282.0.dist-info → orionis-0.284.0.dist-info}/METADATA +1 -1
- {orionis-0.282.0.dist-info → orionis-0.284.0.dist-info}/RECORD +47 -27
- tests/services/asynchrony/test_async_io.py +3 -2
- tests/services/environment/test_env.py +3 -3
- orionis/test/logs/log_test.py +0 -211
- /orionis/services/parsers/{exception.py → exceptions/exception_parser.py} +0 -0
- {orionis-0.282.0.dist-info → orionis-0.284.0.dist-info}/WHEEL +0 -0
- {orionis-0.282.0.dist-info → orionis-0.284.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.282.0.dist-info → orionis-0.284.0.dist-info}/top_level.txt +0 -0
- {orionis-0.282.0.dist-info → orionis-0.284.0.dist-info}/zip-safe +0 -0
@@ -1,23 +1,37 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
|
-
from orionis.foundation.config.testing.entities.testing import Testing as Configuration
|
3
2
|
from orionis.test.suites.test_unit import UnitTest
|
4
3
|
|
5
4
|
class ITestSuite(ABC):
|
6
|
-
"""
|
7
|
-
Interface for configuring and running a UnitTest suite using a provided Configuration.
|
8
|
-
Methods:
|
9
|
-
run(config: Configuration = None) -> UnitTest
|
10
|
-
"""
|
11
5
|
|
12
6
|
@abstractmethod
|
13
|
-
def run(self
|
7
|
+
def run(self) -> UnitTest:
|
14
8
|
"""
|
15
9
|
Runs the test suite based on the provided configuration.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
|
11
|
+
Initializes a UnitTest suite, configures it with parameters from the Configuration object,
|
12
|
+
discovers test folders matching the specified pattern, adds the discovered tests to the suite,
|
13
|
+
executes the test suite, and returns the results.
|
14
|
+
|
15
|
+
Returns
|
16
|
+
-------
|
17
|
+
UnitTest
|
18
|
+
The result of the executed test suite.
|
19
|
+
|
20
|
+
Raises
|
21
|
+
------
|
22
|
+
OrionisTestConfigException
|
23
|
+
If the provided configuration is not an instance of Configuration.
|
22
24
|
"""
|
23
25
|
pass
|
26
|
+
|
27
|
+
@abstractmethod
|
28
|
+
def getResult(self) -> UnitTest:
|
29
|
+
"""
|
30
|
+
Returns the results of the executed test suite.
|
31
|
+
|
32
|
+
Returns
|
33
|
+
-------
|
34
|
+
UnitTest
|
35
|
+
The result of the executed test suite.
|
36
|
+
"""
|
37
|
+
pass
|
@@ -3,32 +3,45 @@ from typing import Any, Dict, List, Optional
|
|
3
3
|
from orionis.test.enums.test_mode import ExecutionMode
|
4
4
|
|
5
5
|
class IUnitTest(ABC):
|
6
|
-
"""
|
7
|
-
IUnitTest is an abstract base class that defines the contract for a unit testing interface within the Orionis framework.
|
8
|
-
This interface provides methods for configuring the test runner, discovering tests in folders or modules, executing tests, retrieving test information, and managing the test suite. Implementations of this interface are expected to provide mechanisms for flexible test discovery, execution, and result handling, supporting features such as verbosity control, parallel execution, test filtering, and result reporting.
|
9
|
-
"""
|
10
6
|
|
11
7
|
@abstractmethod
|
12
8
|
def configure(
|
13
9
|
self,
|
14
10
|
verbosity: int = None,
|
15
|
-
execution_mode: ExecutionMode = None,
|
11
|
+
execution_mode: str | ExecutionMode = None,
|
16
12
|
max_workers: int = None,
|
17
13
|
fail_fast: bool = None,
|
18
|
-
print_result: bool = None
|
14
|
+
print_result: bool = None,
|
15
|
+
throw_exception: bool = False,
|
16
|
+
persistent: bool = False,
|
17
|
+
persistent_driver: str = 'sqlite'
|
19
18
|
):
|
20
19
|
"""
|
21
20
|
Configures the UnitTest instance with the specified parameters.
|
22
21
|
|
23
|
-
Parameters
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
Parameters
|
23
|
+
----------
|
24
|
+
verbosity : int, optional
|
25
|
+
The verbosity level for test output. If None, the current setting is retained.
|
26
|
+
execution_mode : str or ExecutionMode, optional
|
27
|
+
The mode in which the tests will be executed ('SEQUENTIAL' or 'PARALLEL'). If None, the current setting is retained.
|
28
|
+
max_workers : int, optional
|
29
|
+
The maximum number of workers to use for parallel execution. If None, the current setting is retained.
|
30
|
+
fail_fast : bool, optional
|
31
|
+
Whether to stop execution upon the first failure. If None, the current setting is retained.
|
32
|
+
print_result : bool, optional
|
33
|
+
Whether to print the test results after execution. If None, the current setting is retained.
|
34
|
+
throw_exception : bool, optional
|
35
|
+
Whether to throw an exception if any test fails. Defaults to False.
|
36
|
+
persistent : bool, optional
|
37
|
+
Whether to persist the test results in a database. Defaults to False.
|
38
|
+
persistent_driver : str, optional
|
39
|
+
The driver to use for persistent storage. Defaults to 'sqlite'.
|
29
40
|
|
30
|
-
Returns
|
31
|
-
|
41
|
+
Returns
|
42
|
+
-------
|
43
|
+
UnitTest
|
44
|
+
The configured UnitTest instance.
|
32
45
|
"""
|
33
46
|
pass
|
34
47
|
|
@@ -42,85 +55,112 @@ class IUnitTest(ABC):
|
|
42
55
|
tags: Optional[List[str]] = None
|
43
56
|
):
|
44
57
|
"""
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
Parameters
|
59
|
+
----------
|
60
|
+
folder_path : str
|
61
|
+
The relative path to the folder containing the tests.
|
62
|
+
base_path : str, optional
|
63
|
+
The base directory where the test folder is located. Defaults to "tests".
|
64
|
+
pattern : str, optional
|
65
|
+
The filename pattern to match test files. Defaults to "test_*.py".
|
66
|
+
test_name_pattern : str or None, optional
|
67
|
+
A pattern to filter test names. Defaults to None.
|
68
|
+
tags : list of str or None, optional
|
69
|
+
A list of tags to filter tests. Defaults to None.
|
70
|
+
|
71
|
+
Returns
|
72
|
+
-------
|
73
|
+
UnitTest
|
74
|
+
The current instance of the UnitTest class with the discovered tests added.
|
75
|
+
|
76
|
+
Raises
|
77
|
+
------
|
78
|
+
OrionisTestValueError
|
79
|
+
If the test folder does not exist, no tests are found, or an error occurs during test discovery.
|
80
|
+
|
81
|
+
Notes
|
82
|
+
-----
|
83
|
+
This method updates the internal test suite with the discovered tests and tracks the number of tests found.
|
56
84
|
"""
|
57
85
|
pass
|
58
86
|
|
59
87
|
@abstractmethod
|
60
88
|
def discoverTestsInModule(self, module_name: str, test_name_pattern: Optional[str] = None):
|
61
89
|
"""
|
62
|
-
Discovers and loads tests from a specified module, optionally filtering them
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
90
|
+
Discovers and loads tests from a specified module, optionally filtering by a test name pattern, and adds them to the test suite.
|
91
|
+
|
92
|
+
Parameters
|
93
|
+
----------
|
94
|
+
module_name : str
|
95
|
+
Name of the module from which to discover tests.
|
96
|
+
test_name_pattern : str, optional
|
97
|
+
Pattern to filter test names. Only tests matching this pattern will be included. Defaults to None.
|
98
|
+
|
99
|
+
Returns
|
100
|
+
-------
|
101
|
+
UnitTest
|
102
|
+
The current instance of the UnitTest class, allowing method chaining.
|
103
|
+
|
104
|
+
Exceptions
|
105
|
+
----------
|
106
|
+
OrionisTestValueError
|
107
|
+
If the specified module cannot be imported.
|
72
108
|
"""
|
73
109
|
pass
|
74
110
|
|
75
111
|
@abstractmethod
|
76
|
-
def run(self, print_result: bool = None, throw_exception: bool =
|
112
|
+
def run(self, print_result: bool = None, throw_exception: bool = None) -> Dict[str, Any]:
|
77
113
|
"""
|
78
114
|
Executes the test suite and processes the results.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
115
|
+
|
116
|
+
Parameters
|
117
|
+
----------
|
118
|
+
print_result : bool, optional
|
119
|
+
If provided, overrides the instance's `print_result` attribute to determine whether to print results.
|
120
|
+
throw_exception : bool, optional
|
121
|
+
If True, raises an exception if any test failures or errors are detected.
|
122
|
+
|
123
|
+
Returns
|
124
|
+
-------
|
125
|
+
dict
|
126
|
+
A summary of the test execution, including details such as execution time, results, and timestamp.
|
127
|
+
|
128
|
+
Raises
|
129
|
+
------
|
130
|
+
OrionisTestFailureException
|
131
|
+
If `throw_exception` is True and there are test failures or errors.
|
90
132
|
"""
|
91
133
|
pass
|
92
134
|
|
93
135
|
@abstractmethod
|
94
136
|
def getTestNames(self) -> List[str]:
|
95
137
|
"""
|
96
|
-
|
138
|
+
Get a list of test names (unique identifiers) from the test suite.
|
97
139
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
List[str]: A list of test names (unique identifiers) from the test suite.
|
140
|
+
Returns
|
141
|
+
-------
|
142
|
+
List[str]
|
143
|
+
List of test names (unique identifiers) from the test suite.
|
103
144
|
"""
|
104
145
|
pass
|
105
146
|
|
106
147
|
@abstractmethod
|
107
148
|
def getTestCount(self) -> int:
|
108
149
|
"""
|
109
|
-
|
110
|
-
|
111
|
-
This method flattens the test suite structure and counts the total
|
112
|
-
number of individual test cases.
|
150
|
+
Returns the total number of test cases in the test suite.
|
113
151
|
|
114
|
-
Returns
|
115
|
-
|
152
|
+
Returns
|
153
|
+
-------
|
154
|
+
int
|
155
|
+
The total number of individual test cases in the suite.
|
116
156
|
"""
|
117
157
|
pass
|
118
158
|
|
119
159
|
@abstractmethod
|
120
160
|
def clearTests(self) -> None:
|
121
161
|
"""
|
122
|
-
|
162
|
+
Clear all tests from the current test suite.
|
123
163
|
|
124
|
-
|
164
|
+
Resets the internal test suite to an empty `unittest.TestSuite`, removing any previously added tests.
|
125
165
|
"""
|
126
166
|
pass
|
@@ -1,48 +1,67 @@
|
|
1
1
|
import re
|
2
2
|
from os import walk
|
3
3
|
from orionis.foundation.config.testing.entities.testing import Testing as Configuration
|
4
|
+
from orionis.test.exceptions.test_config_exception import OrionisTestConfigException
|
4
5
|
from orionis.test.suites.contracts.test_suite import ITestSuite
|
5
6
|
from orionis.test.suites.test_unit import UnitTest
|
6
|
-
from orionis.test.exceptions.test_config_exception import OrionisTestConfigException
|
7
7
|
|
8
8
|
class TestSuite(ITestSuite):
|
9
9
|
"""
|
10
|
-
TestSuite
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
TestSuite manages and executes a suite of unit tests based on a configurable set of parameters.
|
11
|
+
|
12
|
+
Parameters
|
13
|
+
----------
|
14
|
+
config : Configuration, optional
|
15
|
+
Configuration object specifying parameters for test suite execution. If not provided, a new Configuration instance is created.
|
16
|
+
|
17
|
+
Attributes
|
18
|
+
----------
|
19
|
+
_config : Configuration
|
20
|
+
The configuration object controlling test suite behavior, such as verbosity, execution mode, worker count, and test discovery patterns.
|
21
|
+
|
22
|
+
Methods
|
23
|
+
-------
|
24
|
+
__init__(config=None)
|
25
|
+
Initializes the TestSuite with the provided configuration or a default one.
|
26
|
+
run()
|
27
|
+
Executes the test suite according to the configuration. Discovers test folders matching the specified pattern, adds discovered tests to the suite, and runs them.
|
28
|
+
getResult()
|
29
|
+
Returns the results of the executed test suite.
|
18
30
|
"""
|
19
31
|
|
20
32
|
def __init__(self, config:Configuration = None):
|
21
33
|
"""
|
22
|
-
Initializes the
|
23
|
-
|
24
|
-
Args:
|
25
|
-
config (Configuration, optional): An optional Configuration object to initialize with. Defaults to None.
|
34
|
+
Initializes the TestSuite with the provided configuration.
|
26
35
|
|
27
|
-
|
28
|
-
|
36
|
+
Parameters
|
37
|
+
----------
|
38
|
+
config : Configuration, optional
|
39
|
+
Configuration object specifying parameters for test suite execution. If not provided, a new Configuration instance is created.
|
29
40
|
"""
|
30
|
-
self.
|
41
|
+
self.__config = config or Configuration()
|
42
|
+
self.__result = None
|
31
43
|
|
32
44
|
def run(self) -> UnitTest:
|
33
45
|
"""
|
34
46
|
Runs the test suite based on the provided configuration.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
|
48
|
+
Initializes a UnitTest suite, configures it with parameters from the Configuration object,
|
49
|
+
discovers test folders matching the specified pattern, adds the discovered tests to the suite,
|
50
|
+
executes the test suite, and returns the results.
|
51
|
+
|
52
|
+
Returns
|
53
|
+
-------
|
54
|
+
UnitTest
|
55
|
+
The result of the executed test suite.
|
56
|
+
|
57
|
+
Raises
|
58
|
+
------
|
59
|
+
OrionisTestConfigException
|
60
|
+
If the provided configuration is not an instance of Configuration.
|
42
61
|
"""
|
43
62
|
|
44
63
|
# Check if the config is provided
|
45
|
-
config = self.
|
64
|
+
config = self.__config
|
46
65
|
|
47
66
|
# Check if the config is an instance of Configuration
|
48
67
|
if not isinstance(config, Configuration):
|
@@ -60,6 +79,7 @@ class TestSuite(ITestSuite):
|
|
60
79
|
print_result=config.print_result,
|
61
80
|
throw_exception=config.throw_exception,
|
62
81
|
persistent=config.persistent,
|
82
|
+
persistent_driver=config.persistent_driver,
|
63
83
|
)
|
64
84
|
|
65
85
|
# Extract configuration values
|
@@ -99,4 +119,16 @@ class TestSuite(ITestSuite):
|
|
99
119
|
)
|
100
120
|
|
101
121
|
# Return the initialized test suite
|
102
|
-
|
122
|
+
self.__result = tests.run()
|
123
|
+
return self
|
124
|
+
|
125
|
+
def getResult(self) -> UnitTest:
|
126
|
+
"""
|
127
|
+
Returns the results of the executed test suite.
|
128
|
+
|
129
|
+
Returns
|
130
|
+
-------
|
131
|
+
UnitTest
|
132
|
+
The result of the executed test suite.
|
133
|
+
"""
|
134
|
+
return self.__result
|