orionis 0.405.0__py3-none-any.whl → 0.407.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 +9 -9
- orionis/foundation/config/logging/entities/daily.py +8 -8
- orionis/foundation/config/logging/entities/hourly.py +6 -6
- orionis/foundation/config/logging/entities/logging.py +12 -18
- orionis/foundation/config/logging/entities/monthly.py +7 -7
- orionis/foundation/config/logging/entities/stack.py +5 -5
- orionis/foundation/config/logging/entities/weekly.py +6 -6
- 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/asynchrony/contracts/coroutines.py +13 -5
- orionis/services/asynchrony/coroutines.py +33 -29
- orionis/services/asynchrony/exceptions/exception.py +9 -1
- orionis/services/environment/core/dot_env.py +46 -34
- orionis/services/environment/enums/__init__.py +0 -0
- orionis/services/environment/enums/cast_type.py +42 -0
- 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/environment/serializer/__init__.py +0 -0
- orionis/services/environment/serializer/values.py +21 -0
- orionis/services/environment/validators/__init__.py +0 -0
- orionis/services/environment/validators/key_name.py +46 -0
- orionis/services/environment/validators/types.py +45 -0
- orionis/services/system/contracts/imports.py +38 -18
- orionis/services/system/contracts/workers.py +29 -12
- orionis/services/system/imports.py +65 -25
- orionis/services/system/runtime/imports.py +18 -9
- orionis/services/system/workers.py +49 -16
- 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 +83 -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.405.0.dist-info → orionis-0.407.0.dist-info}/METADATA +1 -1
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/RECORD +170 -112
- 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/example/test_example.py +2 -2
- tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
- tests/metadata/test_metadata_framework.py +89 -24
- tests/metadata/test_metadata_package.py +55 -10
- tests/services/asynchrony/test_services_asynchrony_coroutine.py +52 -7
- tests/services/system/test_services_system_imports.py +119 -16
- tests/services/system/test_services_system_workers.py +71 -30
- 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.405.0.dist-info → orionis-0.407.0.dist-info}/WHEEL +0 -0
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/top_level.txt +0 -0
- {orionis-0.405.0.dist-info → orionis-0.407.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()
|
orionis/test/view/render.py
CHANGED
|
@@ -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
|
|
14
|
-
persist=False
|
|
12
|
+
storage_path: str,
|
|
13
|
+
persist: bool = False
|
|
15
14
|
) -> None:
|
|
16
15
|
"""
|
|
17
|
-
Initialize
|
|
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
|
|
23
|
-
storage_path : str
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
31
|
+
If True, enables persistent storage for test reports (default is False).
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
#
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
#
|
|
61
|
-
|
|
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 = '
|
|
102
|
-
test_results_json = json.dumps(
|
|
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
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
131
|
-
|
|
124
|
+
# Return the absolute path to the generated report
|
|
125
|
+
return str(self.__report_path)
|