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.
- orionis/console/base/command.py +57 -50
- orionis/console/base/contracts/command.py +68 -0
- orionis/console/dynamic/contracts/progress_bar.py +3 -3
- orionis/console/dynamic/progress_bar.py +8 -8
- orionis/console/output/console.py +8 -2
- orionis/console/output/contracts/console.py +1 -1
- orionis/container/container.py +2 -2
- orionis/container/context/scope.py +4 -1
- orionis/container/contracts/service_provider.py +2 -2
- orionis/container/entities/binding.py +31 -44
- orionis/container/enums/lifetimes.py +22 -1
- orionis/container/facades/facade.py +1 -2
- orionis/container/providers/service_provider.py +2 -2
- orionis/foundation/application.py +542 -248
- orionis/foundation/config/app/entities/app.py +107 -90
- orionis/foundation/config/auth/entities/auth.py +4 -33
- orionis/foundation/config/cache/entities/cache.py +18 -41
- orionis/foundation/config/cache/entities/file.py +8 -35
- orionis/foundation/config/cache/entities/stores.py +17 -38
- orionis/foundation/config/cors/entities/cors.py +41 -54
- orionis/foundation/config/database/entities/connections.py +40 -56
- orionis/foundation/config/database/entities/database.py +11 -38
- orionis/foundation/config/database/entities/mysql.py +48 -76
- orionis/foundation/config/database/entities/oracle.py +30 -57
- orionis/foundation/config/database/entities/pgsql.py +45 -61
- orionis/foundation/config/database/entities/sqlite.py +26 -53
- orionis/foundation/config/filesystems/entitites/aws.py +28 -49
- orionis/foundation/config/filesystems/entitites/disks.py +27 -47
- orionis/foundation/config/filesystems/entitites/filesystems.py +15 -37
- orionis/foundation/config/filesystems/entitites/local.py +9 -35
- orionis/foundation/config/filesystems/entitites/public.py +14 -41
- orionis/foundation/config/logging/entities/channels.py +56 -86
- orionis/foundation/config/logging/entities/chunked.py +18 -10
- orionis/foundation/config/logging/entities/daily.py +17 -9
- orionis/foundation/config/logging/entities/hourly.py +15 -7
- orionis/foundation/config/logging/entities/logging.py +12 -18
- orionis/foundation/config/logging/entities/monthly.py +16 -8
- orionis/foundation/config/logging/entities/stack.py +15 -7
- orionis/foundation/config/logging/entities/weekly.py +15 -7
- orionis/foundation/config/logging/validators/path.py +6 -0
- orionis/foundation/config/mail/entities/file.py +9 -36
- orionis/foundation/config/mail/entities/mail.py +22 -40
- orionis/foundation/config/mail/entities/mailers.py +29 -44
- orionis/foundation/config/mail/entities/smtp.py +47 -48
- orionis/foundation/config/queue/entities/brokers.py +19 -41
- orionis/foundation/config/queue/entities/database.py +24 -46
- orionis/foundation/config/queue/entities/queue.py +28 -40
- orionis/foundation/config/roots/paths.py +272 -468
- orionis/foundation/config/session/entities/session.py +23 -53
- orionis/foundation/config/startup.py +165 -135
- orionis/foundation/config/testing/entities/testing.py +137 -122
- orionis/foundation/config/testing/enums/__init__.py +6 -2
- orionis/foundation/config/testing/enums/drivers.py +16 -0
- orionis/foundation/config/testing/enums/verbosity.py +18 -0
- orionis/foundation/contracts/application.py +152 -362
- orionis/foundation/providers/console_provider.py +24 -2
- orionis/foundation/providers/dumper_provider.py +24 -2
- orionis/foundation/providers/logger_provider.py +24 -2
- orionis/foundation/providers/path_resolver_provider.py +25 -2
- orionis/foundation/providers/progress_bar_provider.py +24 -2
- orionis/foundation/providers/testing_provider.py +39 -0
- orionis/foundation/providers/workers_provider.py +24 -2
- orionis/metadata/framework.py +1 -1
- orionis/services/environment/helpers/functions.py +1 -2
- orionis/services/environment/key/__init__.py +0 -0
- orionis/services/environment/key/key_generator.py +37 -0
- orionis/services/log/handlers/filename.py +64 -0
- orionis/services/log/handlers/size_rotating.py +9 -40
- orionis/services/log/handlers/timed_rotating.py +9 -41
- orionis/services/log/log_service.py +9 -52
- orionis/support/entities/__init__.py +0 -0
- orionis/support/entities/base.py +104 -0
- orionis/support/facades/testing.py +15 -0
- orionis/support/facades/workers.py +1 -1
- orionis/test/cases/asynchronous.py +0 -11
- orionis/test/cases/synchronous.py +0 -9
- orionis/test/contracts/dumper.py +11 -4
- orionis/test/contracts/kernel.py +5 -110
- orionis/test/contracts/logs.py +27 -65
- orionis/test/contracts/printer.py +16 -128
- orionis/test/contracts/test_result.py +100 -0
- orionis/test/contracts/unit_test.py +87 -150
- orionis/test/core/unit_test.py +608 -554
- orionis/test/entities/result.py +22 -2
- orionis/test/enums/__init__.py +0 -2
- orionis/test/enums/status.py +14 -9
- orionis/test/exceptions/config.py +9 -1
- orionis/test/exceptions/failure.py +34 -11
- orionis/test/exceptions/persistence.py +10 -2
- orionis/test/exceptions/runtime.py +9 -1
- orionis/test/exceptions/value.py +13 -1
- orionis/test/kernel.py +87 -289
- orionis/test/output/dumper.py +82 -18
- orionis/test/output/printer.py +399 -156
- orionis/test/records/logs.py +203 -82
- orionis/test/validators/__init__.py +33 -0
- orionis/test/validators/base_path.py +45 -0
- orionis/test/validators/execution_mode.py +45 -0
- orionis/test/validators/fail_fast.py +37 -0
- orionis/test/validators/folder_path.py +34 -0
- orionis/test/validators/module_name.py +31 -0
- orionis/test/validators/name_pattern.py +40 -0
- orionis/test/validators/pattern.py +36 -0
- orionis/test/validators/persistent.py +42 -0
- orionis/test/validators/persistent_driver.py +43 -0
- orionis/test/validators/print_result.py +37 -0
- orionis/test/validators/tags.py +37 -0
- orionis/test/validators/throw_exception.py +39 -0
- orionis/test/validators/verbosity.py +37 -0
- orionis/test/validators/web_report.py +35 -0
- orionis/test/validators/workers.py +31 -0
- orionis/test/view/render.py +48 -54
- {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/METADATA +1 -1
- {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/RECORD +160 -108
- tests/container/__init__.py +0 -0
- tests/container/context/__init__.py +0 -0
- tests/container/context/test_manager.py +27 -0
- tests/container/context/test_scope.py +23 -0
- tests/container/entities/__init__.py +0 -0
- tests/container/entities/test_binding.py +133 -0
- tests/container/enums/__init__.py +0 -0
- tests/container/enums/test_lifetimes.py +63 -0
- tests/container/facades/__init__.py +0 -0
- tests/container/facades/test_facade.py +61 -0
- tests/container/mocks/__init__.py +0 -0
- tests/container/mocks/mock_complex_classes.py +482 -0
- tests/container/mocks/mock_simple_classes.py +32 -0
- tests/container/providers/__init__.py +0 -0
- tests/container/providers/test_providers.py +48 -0
- tests/container/resolver/__init__.py +0 -0
- tests/container/resolver/test_resolver.py +55 -0
- tests/container/test_container.py +254 -0
- tests/container/test_singleton.py +98 -0
- tests/container/test_thread_safety.py +217 -0
- tests/container/validators/__init__.py +0 -0
- tests/container/validators/test_implements.py +140 -0
- tests/container/validators/test_is_abstract_class.py +99 -0
- tests/container/validators/test_is_callable.py +73 -0
- tests/container/validators/test_is_concrete_class.py +97 -0
- tests/container/validators/test_is_instance.py +105 -0
- tests/container/validators/test_is_not_subclass.py +117 -0
- tests/container/validators/test_is_subclass.py +115 -0
- tests/container/validators/test_is_valid_alias.py +113 -0
- tests/container/validators/test_lifetime.py +75 -0
- tests/foundation/config/logging/test_foundation_config_logging_chunked.py +12 -34
- tests/foundation/config/logging/test_foundation_config_logging_daily.py +11 -11
- tests/foundation/config/logging/test_foundation_config_logging_hourly.py +7 -8
- tests/foundation/config/logging/test_foundation_config_logging_monthly.py +7 -10
- tests/foundation/config/logging/test_foundation_config_logging_stack.py +6 -11
- tests/foundation/config/logging/test_foundation_config_logging_weekly.py +6 -5
- tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
- tests/metadata/test_metadata_framework.py +18 -18
- tests/testing/test_testing_result.py +117 -117
- tests/testing/test_testing_unit.py +209 -209
- orionis/foundation/config/base.py +0 -112
- orionis/test/arguments/parser.py +0 -187
- orionis/test/contracts/parser.py +0 -43
- orionis/test/entities/arguments.py +0 -38
- orionis/test/enums/execution_mode.py +0 -16
- /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
- /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
- {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/WHEEL +0 -0
- {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/top_level.txt +0 -0
- {orionis-0.404.0.dist-info → orionis-0.406.0.dist-info}/zip-safe +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from dataclasses import asdict, fields, is_dataclass, MISSING
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
class BaseEntity:
|
|
5
|
+
|
|
6
|
+
def toDict(self) -> dict:
|
|
7
|
+
"""
|
|
8
|
+
Converts the current instance into a dictionary representation.
|
|
9
|
+
|
|
10
|
+
Returns
|
|
11
|
+
-------
|
|
12
|
+
dict
|
|
13
|
+
Dictionary representation of the current instance.
|
|
14
|
+
"""
|
|
15
|
+
return asdict(self)
|
|
16
|
+
|
|
17
|
+
def getFields(self):
|
|
18
|
+
"""
|
|
19
|
+
Retrieves a list of field information for the current dataclass instance.
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
list
|
|
24
|
+
A list of dictionaries, each containing details about a field:
|
|
25
|
+
- name (str): The name of the field.
|
|
26
|
+
- type (type): The type of the field.
|
|
27
|
+
- default: The default value of the field, if specified; otherwise, the value from metadata or None.
|
|
28
|
+
- metadata (mapping): The metadata associated with the field.
|
|
29
|
+
"""
|
|
30
|
+
# Dictionary to hold field information
|
|
31
|
+
__fields = []
|
|
32
|
+
|
|
33
|
+
# Iterate over the fields of the dataclass and extract relevant information
|
|
34
|
+
for field in fields(self):
|
|
35
|
+
|
|
36
|
+
# Get the field name
|
|
37
|
+
__name = field.name
|
|
38
|
+
|
|
39
|
+
# Get the field type with better handling for complex types
|
|
40
|
+
__type = getattr(field.type, '__name__', None)
|
|
41
|
+
|
|
42
|
+
# If the type is None, handle it
|
|
43
|
+
if __type is None:
|
|
44
|
+
|
|
45
|
+
# Handle Union types or other complex types
|
|
46
|
+
type_lst = []
|
|
47
|
+
type_str = str(field.type).split('|')
|
|
48
|
+
for itype in type_str:
|
|
49
|
+
type_lst.append(itype.strip())
|
|
50
|
+
__type = type_lst
|
|
51
|
+
|
|
52
|
+
# Ensure __type is a list for consistency
|
|
53
|
+
__type = type_lst if isinstance(__type, list) else [__type]
|
|
54
|
+
|
|
55
|
+
# Extract metadata, default value, and type
|
|
56
|
+
metadata = dict(field.metadata) if field.metadata else {}
|
|
57
|
+
|
|
58
|
+
# If metadata contains a default value, normalize it
|
|
59
|
+
if 'default' in metadata:
|
|
60
|
+
metadata_default = metadata['default']
|
|
61
|
+
if callable(metadata_default):
|
|
62
|
+
metadata_default = metadata_default()
|
|
63
|
+
if is_dataclass(metadata_default):
|
|
64
|
+
metadata_default = asdict(metadata_default)
|
|
65
|
+
elif isinstance(metadata_default, Enum):
|
|
66
|
+
metadata_default = metadata_default.value
|
|
67
|
+
metadata['default'] = metadata_default
|
|
68
|
+
|
|
69
|
+
# Add the field information to the list
|
|
70
|
+
__metadata = metadata
|
|
71
|
+
|
|
72
|
+
# Extract the default value, if specified
|
|
73
|
+
__default = None
|
|
74
|
+
|
|
75
|
+
# Field has a direct default value
|
|
76
|
+
if field.default is not MISSING:
|
|
77
|
+
__default = field.default() if callable(field.default) else field.default
|
|
78
|
+
if is_dataclass(__default):
|
|
79
|
+
__default = asdict(__default)
|
|
80
|
+
elif isinstance(__default, Enum):
|
|
81
|
+
__default = __default.value
|
|
82
|
+
|
|
83
|
+
# Field has a default factory (like list, dict, etc.)
|
|
84
|
+
elif field.default_factory is not MISSING:
|
|
85
|
+
__default = field.default_factory() if callable(field.default_factory) else field.default_factory
|
|
86
|
+
if is_dataclass(__default):
|
|
87
|
+
__default = asdict(__default)
|
|
88
|
+
elif isinstance(__default, Enum):
|
|
89
|
+
__default = __default.value
|
|
90
|
+
|
|
91
|
+
# No default found, check metadata for custom default
|
|
92
|
+
else:
|
|
93
|
+
__default = __metadata.get('default', None)
|
|
94
|
+
|
|
95
|
+
# Append the field information to the list
|
|
96
|
+
__fields.append({
|
|
97
|
+
"name": __name,
|
|
98
|
+
"types": __type,
|
|
99
|
+
"default": __default,
|
|
100
|
+
"metadata": __metadata
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
# Return the list of field information
|
|
104
|
+
return __fields
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from orionis.container.facades.facade import Facade
|
|
2
|
+
|
|
3
|
+
class Test(Facade):
|
|
4
|
+
|
|
5
|
+
@classmethod
|
|
6
|
+
def getFacadeAccessor(cls) -> str:
|
|
7
|
+
"""
|
|
8
|
+
Get the service container binding key for the dumper component.
|
|
9
|
+
|
|
10
|
+
Returns
|
|
11
|
+
-------
|
|
12
|
+
str
|
|
13
|
+
The service container binding key.
|
|
14
|
+
"""
|
|
15
|
+
return "core.orionis.testing"
|
|
@@ -30,17 +30,6 @@ class AsyncTestCase(unittest.IsolatedAsyncioTestCase, TestDumper):
|
|
|
30
30
|
Hook method for subclass-specific async setup logic.
|
|
31
31
|
onAsyncTeardown()
|
|
32
32
|
Hook method for subclass-specific async teardown logic.
|
|
33
|
-
|
|
34
|
-
Examples
|
|
35
|
-
--------
|
|
36
|
-
>>> class MyAsyncTest(AsyncTestCase):
|
|
37
|
-
... async def onAsyncSetup(self):
|
|
38
|
-
... self.client = AsyncHttpClient()
|
|
39
|
-
... await self.client.connect()
|
|
40
|
-
...
|
|
41
|
-
... async def testAsyncOperation(self):
|
|
42
|
-
... result = await self.client.get('/api/data')
|
|
43
|
-
... self.assertEqual(result.status, 200)
|
|
44
33
|
"""
|
|
45
34
|
|
|
46
35
|
async def asyncSetUp(self):
|
|
@@ -27,15 +27,6 @@ class SyncTestCase(unittest.TestCase, TestDumper):
|
|
|
27
27
|
Hook method for subclass-specific setup logic.
|
|
28
28
|
onTeardown()
|
|
29
29
|
Hook method for subclass-specific teardown logic.
|
|
30
|
-
|
|
31
|
-
Examples
|
|
32
|
-
--------
|
|
33
|
-
>>> class MyTest(SyncTestCase):
|
|
34
|
-
... def onSetup(self):
|
|
35
|
-
... self.data = [1, 2, 3]
|
|
36
|
-
...
|
|
37
|
-
... def testExample(self):
|
|
38
|
-
... self.assertEqual(len(self.data), 3)
|
|
39
30
|
"""
|
|
40
31
|
|
|
41
32
|
def setUp(self):
|
orionis/test/contracts/dumper.py
CHANGED
|
@@ -17,15 +17,22 @@ class ITestDumper(ABC):
|
|
|
17
17
|
@abstractmethod
|
|
18
18
|
def dd(self, *args) -> None:
|
|
19
19
|
"""
|
|
20
|
-
|
|
20
|
+
Outputs debugging information using the Debug class.
|
|
21
21
|
|
|
22
|
-
This method captures the caller's file and line number,
|
|
23
|
-
|
|
22
|
+
This method captures the caller's file and line number, then
|
|
23
|
+
utilizes the Debug class to display or log the provided arguments
|
|
24
|
+
for debugging purposes.
|
|
24
25
|
|
|
25
26
|
Parameters
|
|
26
27
|
----------
|
|
27
28
|
*args : tuple
|
|
28
|
-
Variable length argument list to be dumped.
|
|
29
|
+
Variable length argument list containing the data to be dumped.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
None
|
|
34
|
+
This method does not return any value. Its purpose is to output
|
|
35
|
+
or log the debugging information.
|
|
29
36
|
"""
|
|
30
37
|
pass
|
|
31
38
|
|
orionis/test/contracts/kernel.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from
|
|
3
|
-
from orionis.foundation.config.testing.entities.testing import Testing as Configuration
|
|
4
|
-
from orionis.test.core.unit_test import UnitTest
|
|
2
|
+
from orionis.test.contracts.unit_test import IUnitTest
|
|
5
3
|
|
|
6
4
|
class ITestKernel(ABC):
|
|
7
5
|
"""
|
|
@@ -19,116 +17,13 @@ class ITestKernel(ABC):
|
|
|
19
17
|
"""
|
|
20
18
|
|
|
21
19
|
@abstractmethod
|
|
22
|
-
def handle(
|
|
23
|
-
self,
|
|
24
|
-
config: Configuration = None,
|
|
25
|
-
**kwargs: Any
|
|
26
|
-
) -> UnitTest:
|
|
20
|
+
def handle(self) -> IUnitTest:
|
|
27
21
|
"""
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
This is the main entry point for running tests. Implementations must:
|
|
31
|
-
1. Validate the provided configuration
|
|
32
|
-
2. Discover test files based on configuration
|
|
33
|
-
3. Configure and execute the test suite
|
|
34
|
-
4. Return the test results
|
|
35
|
-
|
|
36
|
-
Parameters
|
|
37
|
-
----------
|
|
38
|
-
config : Configuration, optional
|
|
39
|
-
A pre-configured Testing configuration instance. If None,
|
|
40
|
-
implementations should create one from kwargs.
|
|
41
|
-
**kwargs : Any
|
|
42
|
-
Keyword arguments to create a Configuration instance if config is None.
|
|
43
|
-
Common parameters include:
|
|
44
|
-
- base_path : str, base directory for test discovery
|
|
45
|
-
- folder_path : str or list, specific folders to search
|
|
46
|
-
- pattern : str, file pattern for test discovery
|
|
47
|
-
- verbosity : int, output verbosity level
|
|
48
|
-
- execution_mode : str, test execution mode
|
|
49
|
-
- max_workers : int, maximum number of worker threads
|
|
50
|
-
- fail_fast : bool, stop on first failure
|
|
51
|
-
|
|
52
|
-
Returns
|
|
53
|
-
-------
|
|
54
|
-
UnitTest
|
|
55
|
-
The configured and executed test suite instance containing all results.
|
|
56
|
-
|
|
57
|
-
Raises
|
|
58
|
-
------
|
|
59
|
-
OrionisTestConfigException
|
|
60
|
-
If the configuration validation fails.
|
|
61
|
-
"""
|
|
62
|
-
pass
|
|
63
|
-
|
|
64
|
-
@abstractmethod
|
|
65
|
-
def handleCLI(
|
|
66
|
-
self,
|
|
67
|
-
sys_argv: list[str]
|
|
68
|
-
) -> UnitTest:
|
|
69
|
-
"""
|
|
70
|
-
Process command line arguments for test execution.
|
|
71
|
-
|
|
72
|
-
This method configures and runs tests based on command line arguments. It parses
|
|
73
|
-
the provided sys_argv list into a TestArguments object, extracts configuration
|
|
74
|
-
values, executes the tests, and handles output generation.
|
|
75
|
-
|
|
76
|
-
Parameters
|
|
77
|
-
----------
|
|
78
|
-
sys_argv : list[str]
|
|
79
|
-
Command line arguments list including script name. The script name
|
|
80
|
-
(first element) will be automatically removed before parsing.
|
|
22
|
+
Configure and execute the unit tests based on the current configuration.
|
|
81
23
|
|
|
82
24
|
Returns
|
|
83
25
|
-------
|
|
84
|
-
|
|
85
|
-
The
|
|
86
|
-
|
|
87
|
-
Raises
|
|
88
|
-
------
|
|
89
|
-
OrionisTestConfigException
|
|
90
|
-
If the provided sys_argv is not a valid list or if argument parsing fails.
|
|
91
|
-
|
|
92
|
-
Notes
|
|
93
|
-
-----
|
|
94
|
-
The method supports various test execution options including parallel/sequential
|
|
95
|
-
execution mode, fail fast behavior, result output configuration, and web reporting.
|
|
26
|
+
IUnitTest
|
|
27
|
+
The configured and executed unit test instance.
|
|
96
28
|
"""
|
|
97
29
|
pass
|
|
98
|
-
|
|
99
|
-
@abstractmethod
|
|
100
|
-
def exit(
|
|
101
|
-
self,
|
|
102
|
-
code: int = 0
|
|
103
|
-
) -> None:
|
|
104
|
-
"""
|
|
105
|
-
Terminate the test execution process and free associated resources.
|
|
106
|
-
|
|
107
|
-
This method performs a clean shutdown of the test kernel by explicitly
|
|
108
|
-
triggering garbage collection to release memory resources and then
|
|
109
|
-
terminating the process with the provided exit code. It ensures that any
|
|
110
|
-
remaining file handles, threads, or other resources are properly released.
|
|
111
|
-
|
|
112
|
-
Parameters
|
|
113
|
-
----------
|
|
114
|
-
code : int
|
|
115
|
-
The exit code to return to the operating system. Should be 0 for
|
|
116
|
-
successful execution or a non-zero value to indicate an error.
|
|
117
|
-
|
|
118
|
-
Returns
|
|
119
|
-
-------
|
|
120
|
-
None
|
|
121
|
-
This method does not return as it terminates the process.
|
|
122
|
-
|
|
123
|
-
Raises
|
|
124
|
-
------
|
|
125
|
-
ValueError
|
|
126
|
-
If the provided code is not a valid integer or outside the allowed range.
|
|
127
|
-
|
|
128
|
-
Notes
|
|
129
|
-
-----
|
|
130
|
-
Using os._exit() bypasses normal Python cleanup mechanisms and
|
|
131
|
-
immediately terminates the process. This can be necessary when
|
|
132
|
-
normal sys.exit() would be caught by exception handlers.
|
|
133
|
-
"""
|
|
134
|
-
pass
|
orionis/test/contracts/logs.py
CHANGED
|
@@ -3,79 +3,56 @@ from typing import Dict, List, Optional, Tuple
|
|
|
3
3
|
|
|
4
4
|
class ITestLogs(ABC):
|
|
5
5
|
"""
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
31
|
+
True if the report was stored successfully.
|
|
46
32
|
|
|
47
33
|
Raises
|
|
48
34
|
------
|
|
49
35
|
OrionisTestValueError
|
|
50
|
-
If
|
|
36
|
+
If required fields are missing or invalid.
|
|
51
37
|
OrionisTestPersistenceError
|
|
52
|
-
If
|
|
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
|
-
|
|
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
|
|
50
|
+
True if the table was dropped or did not exist.
|
|
69
51
|
|
|
70
52
|
Raises
|
|
71
53
|
------
|
|
72
54
|
OrionisTestPersistenceError
|
|
73
|
-
If
|
|
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
|
|
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]
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|