orionis 0.245.0__py3-none-any.whl → 0.247.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 (108) hide show
  1. orionis/framework.py +1 -1
  2. orionis/luminate/config/app/__init__.py +10 -0
  3. orionis/luminate/config/app/entities/app.py +205 -0
  4. orionis/luminate/config/app/enums/ciphers.py +34 -0
  5. orionis/luminate/config/app/enums/environments.py +15 -0
  6. orionis/luminate/config/auth/__init__.py +7 -0
  7. orionis/luminate/config/auth/entities/auth.py +11 -0
  8. orionis/luminate/config/cache/__init__.py +9 -0
  9. orionis/luminate/config/cache/entities/cache.py +58 -0
  10. orionis/luminate/config/cache/entities/file.py +29 -0
  11. orionis/luminate/config/cache/entities/stores.py +35 -0
  12. orionis/luminate/config/cache/enums/drivers.py +12 -0
  13. orionis/luminate/config/contracts/config.py +27 -0
  14. orionis/luminate/config/entities/testing.py +215 -0
  15. orionis/luminate/config/exceptions/integrity_exception.py +30 -0
  16. orionis/luminate/console/dumper/dump_die.py +418 -0
  17. orionis/luminate/contracts/facades/commands/scheduler_facade.py +1 -1
  18. orionis/luminate/facades/files/path_facade.py +1 -1
  19. orionis/luminate/patterns/__init__.py +4 -0
  20. orionis/luminate/patterns/singleton/__init__.py +10 -0
  21. orionis/luminate/patterns/singleton/meta_class.py +56 -0
  22. orionis/luminate/providers/commands/reactor_commands_service_provider.py +3 -3
  23. orionis/luminate/providers/commands/scheduler_provider.py +1 -1
  24. orionis/luminate/providers/config/config_service_provider.py +1 -1
  25. orionis/luminate/providers/environment/environment__service_provider.py +2 -2
  26. orionis/luminate/providers/files/paths_provider.py +1 -1
  27. orionis/luminate/providers/log/log_service_provider.py +2 -2
  28. orionis/luminate/services/environment/__init__.py +10 -0
  29. orionis/luminate/services/environment/contracts/__init__.py +5 -0
  30. orionis/luminate/services/environment/contracts/env.py +93 -0
  31. orionis/luminate/services/environment/dot_env.py +293 -0
  32. orionis/luminate/services/environment/env.py +77 -0
  33. orionis/luminate/services/paths/__init__.py +9 -0
  34. orionis/luminate/services/paths/contracts/__init__.py +0 -0
  35. orionis/luminate/services/paths/contracts/resolver.py +67 -0
  36. orionis/luminate/services/paths/resolver.py +83 -0
  37. orionis/luminate/services/workers/__init__.py +10 -0
  38. orionis/luminate/services/workers/maximum_workers.py +36 -0
  39. orionis/luminate/services_/__init__.py +0 -0
  40. orionis/luminate/services_/commands/__init__.py +0 -0
  41. orionis/luminate/services_/config/__init__.py +0 -0
  42. orionis/luminate/services_/log/__init__.py +0 -0
  43. orionis/luminate/support/introspection/abstracts/entities/__init__.py +0 -0
  44. orionis/luminate/support/introspection/abstracts/entities/abstract_class_attributes.py +11 -0
  45. orionis/luminate/support/introspection/abstracts/reflect_abstract.py +154 -16
  46. orionis/luminate/support/introspection/instances/reflection_instance.py +2 -2
  47. orionis/luminate/test/__init__.py +11 -1
  48. orionis/luminate/test/cases/test_async.py +1 -10
  49. orionis/luminate/test/cases/test_case.py +8 -3
  50. orionis/luminate/test/cases/test_sync.py +1 -0
  51. orionis/luminate/test/core/contracts/test_suite.py +19 -31
  52. orionis/luminate/test/core/contracts/test_unit.py +103 -59
  53. orionis/luminate/test/core/test_suite.py +50 -42
  54. orionis/luminate/test/core/test_unit.py +756 -196
  55. orionis/luminate/test/entities/test_result.py +19 -18
  56. orionis/luminate/test/enums/test_mode.py +16 -0
  57. orionis/luminate/test/exceptions/test_config_exception.py +28 -0
  58. orionis/luminate/test/exceptions/test_exception.py +41 -34
  59. orionis/luminate/test/output/contracts/test_std_out.py +22 -11
  60. orionis/luminate/test/output/test_std_out.py +79 -48
  61. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/METADATA +4 -1
  62. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/RECORD +98 -61
  63. tests/config/__init__.py +0 -0
  64. tests/config/test_app.py +122 -0
  65. tests/config/test_auth.py +21 -0
  66. tests/config/test_cache.py +20 -0
  67. tests/patterns/__init__.py +0 -0
  68. tests/patterns/singleton/__init__.py +0 -0
  69. tests/patterns/singleton/test_singleton.py +18 -0
  70. tests/services/__init__.py +0 -0
  71. tests/services/environment/__init__.py +0 -0
  72. tests/services/environment/test_env.py +33 -0
  73. tests/support/inspection/fakes/fake_reflect_abstract.py +61 -5
  74. tests/support/inspection/test_reflect_abstract.py +62 -1
  75. tests/support/inspection/test_reflect_instance.py +0 -1
  76. orionis/luminate/config/app.py +0 -47
  77. orionis/luminate/config/auth.py +0 -15
  78. orionis/luminate/config/cache.py +0 -51
  79. orionis/luminate/support/environment/contracts/env.py +0 -68
  80. orionis/luminate/support/environment/env.py +0 -138
  81. orionis/luminate/support/environment/functions.py +0 -49
  82. orionis/luminate/support/environment/helper.py +0 -26
  83. orionis/luminate/support/patterns/singleton.py +0 -44
  84. tests/support/environment/test_env.py +0 -91
  85. tests/support/patterns/test_singleton.py +0 -18
  86. /orionis/luminate/{services/commands → config/app/entities}/__init__.py +0 -0
  87. /orionis/luminate/{services/config → config/app/enums}/__init__.py +0 -0
  88. /orionis/luminate/{services/log → config/auth/entities}/__init__.py +0 -0
  89. /orionis/luminate/{support/environment → config/cache/entities}/__init__.py +0 -0
  90. /orionis/luminate/{support/environment/contracts → config/cache/enums}/__init__.py +0 -0
  91. /orionis/luminate/{support/patterns → config/contracts}/__init__.py +0 -0
  92. /orionis/luminate/config/{cors.py → entities/cors.py} +0 -0
  93. /orionis/luminate/config/{database.py → entities/database.py} +0 -0
  94. /orionis/luminate/config/{filesystems.py → entities/filesystems.py} +0 -0
  95. /orionis/luminate/config/{logging.py → entities/logging.py} +0 -0
  96. /orionis/luminate/config/{mail.py → entities/mail.py} +0 -0
  97. /orionis/luminate/config/{queue.py → entities/queue.py} +0 -0
  98. /orionis/luminate/config/{session.py → entities/session.py} +0 -0
  99. {tests/support/environment → orionis/luminate/config/exceptions}/__init__.py +0 -0
  100. {tests/support/patterns → orionis/luminate/console/dumper}/__init__.py +0 -0
  101. /orionis/luminate/{services → services_}/commands/reactor_commands_service.py +0 -0
  102. /orionis/luminate/{services → services_}/commands/scheduler_service.py +0 -0
  103. /orionis/luminate/{services → services_}/config/config_service.py +0 -0
  104. /orionis/luminate/{services → services_}/log/log_service.py +0 -0
  105. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/LICENCE +0 -0
  106. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/WHEEL +0 -0
  107. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/entry_points.txt +0 -0
  108. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/top_level.txt +0 -0
@@ -1,82 +1,126 @@
1
- from typing import Any, Dict, Optional
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Dict, List, Optional
3
+ from orionis.luminate.test.enums.test_mode import ExecutionMode
2
4
 
3
- class IUnitTest:
5
+ class IUnitTest(ABC):
4
6
  """
5
- Advanced unit testing utility for discovering, executing, and reporting test results
6
- with support for folder-based discovery, regex filtering, and customizable output.
7
-
8
- Attributes
9
- ----------
10
- loader : unittest.TestLoader
11
- Internal loader for test discovery.
12
- suite : unittest.TestSuite
13
- The aggregated test suite to be executed.
14
- test_results : List[TestResult]
15
- List of captured results per test, including status and errors.
16
- start_time : float
17
- Timestamp when the test execution started.
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.
18
9
  """
19
10
 
11
+ @abstractmethod
12
+ def configure(
13
+ self,
14
+ verbosity: int = None,
15
+ execution_mode: ExecutionMode = None,
16
+ max_workers: int = None,
17
+ fail_fast: bool = None,
18
+ print_result: bool = None
19
+ ):
20
+ """
21
+ Configures the UnitTest instance with the specified parameters.
22
+
23
+ Parameters:
24
+ verbosity (int, optional): The verbosity level for test output. Defaults to None.
25
+ execution_mode (ExecutionMode, optional): The mode in which the tests will be executed. Defaults to None.
26
+ max_workers (int, optional): The maximum number of workers to use for parallel execution. Defaults to None.
27
+ fail_fast (bool, optional): Whether to stop execution upon the first failure. Defaults to None.
28
+ print_result (bool, optional): Whether to print the test results after execution. Defaults to None.
29
+
30
+ Returns:
31
+ UnitTest: The configured UnitTest instance.
32
+ """
33
+ pass
34
+
35
+ @abstractmethod
20
36
  def discoverTestsInFolder(
21
37
  self,
22
38
  folder_path: str,
23
39
  base_path: str = "tests",
24
40
  pattern: str = "test_*.py",
25
- test_name_pattern: Optional[str] = None
41
+ test_name_pattern: Optional[str] = None,
42
+ tags: Optional[List[str]] = None
26
43
  ):
27
44
  """
28
- Discover and add test cases from a given folder to the test suite.
45
+ Discovers and loads unit tests from a specified folder.
46
+ Args:
47
+ folder_path (str): The relative path to the folder containing the tests.
48
+ base_path (str, optional): The base directory where the test folder is located. Defaults to "tests".
49
+ pattern (str, optional): The filename pattern to match test files. Defaults to "test_*.py".
50
+ test_name_pattern (Optional[str], optional): A pattern to filter test names. Defaults to None.
51
+ tags (Optional[List[str]], optional): A list of tags to filter tests. Defaults to None.
52
+ Returns:
53
+ UnitTest: The current instance of the UnitTest class with the discovered tests added.
54
+ Raises:
55
+ ValueError: If the test folder does not exist, no tests are found, or an error occurs during test discovery.
56
+ """
57
+ pass
58
+
59
+ @abstractmethod
60
+ def discoverTestsInModule(self, module_name: str, test_name_pattern: Optional[str] = None):
61
+ """
62
+ Discovers and loads tests from a specified module, optionally filtering them
63
+ by a test name pattern, and adds them to the test suite.
64
+ Args:
65
+ module_name (str): The name of the module to discover tests from.
66
+ test_name_pattern (Optional[str]): A pattern to filter test names. Only
67
+ tests matching this pattern will be included. Defaults to None.
68
+ Returns:
69
+ UnitTest: The current instance of the UnitTest class, allowing method chaining.
70
+ Raises:
71
+ ValueError: If the specified module cannot be imported.
72
+ """
73
+ pass
29
74
 
30
- Parameters
31
- ----------
32
- folder_path : str
33
- Relative path to the folder containing test files.
34
- base_path : str, default="tests"
35
- Base path used to resolve full path to test modules.
36
- pattern : str, default="test_*.py"
37
- Glob pattern to match test filenames.
38
- test_name_pattern : Optional[str], optional
39
- Regex pattern to filter discovered test method names.
75
+ @abstractmethod
76
+ def run(self, print_result: bool = None, throw_exception: bool = False) -> Dict[str, Any]:
77
+ """
78
+ Executes the test suite and processes the results.
79
+ Args:
80
+ print_result (bool, optional): If provided, overrides the instance's
81
+ `print_result` attribute to determine whether to print the test results.
82
+ throw_exception (bool, optional): If True, raises an exception if any
83
+ test failures or errors are detected.
84
+ Returns:
85
+ Dict[str, Any]: A summary of the test execution, including details such as
86
+ execution time, test results, and a timestamp.
87
+ Raises:
88
+ OrionisTestFailureException: If `throw_exception` is True and there are
89
+ test failures or errors.
90
+ """
91
+ pass
40
92
 
41
- Returns
42
- -------
43
- UnitTest
44
- Self instance for chaining.
93
+ @abstractmethod
94
+ def getTestNames(self) -> List[str]:
95
+ """
96
+ Retrieves a list of test names from the test suite.
45
97
 
46
- Raises
47
- ------
48
- ValueError
49
- If folder is invalid or no tests are found.
98
+ This method flattens the test suite and extracts the unique identifier
99
+ (`id`) of each test case.
100
+
101
+ Returns:
102
+ List[str]: A list of test names (unique identifiers) from the test suite.
50
103
  """
51
104
  pass
52
105
 
53
- def run(self, print_result:bool = True, throw_exception:bool = False) -> Dict[str, Any]:
106
+ @abstractmethod
107
+ def getTestCount(self) -> int:
54
108
  """
55
- Run all added tests and return a summary of the results.
109
+ Calculate the total number of tests in the test suite.
56
110
 
57
- Parameters
58
- ----------
59
- print_result : bool, default=True
60
- Whether to print a formatted report to the console.
61
- throw_exception : bool, default=False
62
- Raise an exception if there are failures or errors.
111
+ This method flattens the test suite structure and counts the total
112
+ number of individual test cases.
63
113
 
64
- Returns
65
- -------
66
- Dict[str, Any]
67
- Summary including:
68
- - total_tests : int
69
- - passed : int
70
- - failed : int
71
- - errors : int
72
- - skipped : int
73
- - total_time : str (e.g., '1.234 seconds')
74
- - success_rate : str (e.g., '87.5%')
75
- - test_details : List[Dict[str, Any]]
114
+ Returns:
115
+ int: The total number of test cases in the test suite.
116
+ """
117
+ pass
118
+
119
+ @abstractmethod
120
+ def clearTests(self) -> None:
121
+ """
122
+ Clears the current test suite by reinitializing it to an empty `unittest.TestSuite`.
76
123
 
77
- Raises
78
- ------
79
- OrionisTestFailureException
80
- If any test fails or errors occur and `throw_exception=True`.
124
+ This method is used to reset the test suite, removing any previously added tests.
81
125
  """
82
126
  pass
@@ -1,53 +1,62 @@
1
1
  import re
2
2
  from os import walk
3
+ from orionis.luminate.config.entities.testing import Testing
3
4
  from orionis.luminate.test.core.contracts.test_suite import ITestSuite
4
- from orionis.luminate.test.core.test_unit import UnitTest as UnitTestClass
5
+ from orionis.luminate.test.core.test_unit import UnitTest
6
+ from orionis.luminate.test.exceptions.test_config_exception import OrionisTestConfigException
5
7
 
6
8
  class TestSuite(ITestSuite):
7
9
  """
8
- A class containing test utility methods.
10
+ TestSuite provides static configuration and initialization of a unit test suite based on a given Testing configuration.
11
+ Methods:
12
+ config(config: Testing) -> UnitTest
13
+ Configures and initializes a test suite using the provided Testing configuration.
14
+ - Validates the type of the configuration object.
15
+ - Sets up the UnitTest suite with parameters such as verbosity, execution mode, worker count, and error handling.
16
+ - Discovers test folders based on base path, folder path(s), and filename pattern, supporting wildcards.
17
+ - Adds discovered test folders to the suite, optionally filtering by test name pattern and tags.
18
+ OrionisTestConfigException: If the provided config is not an instance of the Testing class.
9
19
  """
10
20
 
11
21
  @staticmethod
12
- def load(
13
- base_path: str = 'tests',
14
- folder_path: list | str = '*',
15
- pattern: str = 'test_*.py'
16
- ) -> UnitTestClass:
22
+ def config(config:Testing) -> UnitTest:
23
+ """
24
+ Configures and initializes a UnitTest suite based on the provided Testing configuration.
25
+ Args:
26
+ config (Testing): An instance of the Testing class containing configuration options for the test suite.
27
+ Returns:
28
+ UnitTest: An initialized UnitTest suite configured according to the provided settings.
29
+ Raises:
30
+ OrionisTestConfigException: If the config parameter is not an instance of the Testing class.
31
+ The function performs the following steps:
32
+ - Validates the type of the config parameter.
33
+ - Initializes a UnitTest suite and applies configuration values from the Testing instance.
34
+ - Discovers folders containing test files based on the specified base path, folder path(s), and filename pattern.
35
+ - Adds discovered test folders to the UnitTest suite, applying optional test name patterns and tags.
36
+ - Returns the configured UnitTest suite ready for execution.
17
37
  """
18
- Discover and initialize a test suite from the specified folder(s).
19
38
 
20
- This method scans the provided folder(s) for test files matching the given pattern
21
- and initializes a test suite with the discovered files.
39
+ # Check if the config is an instance of Testing
40
+ if not isinstance(config, Testing):
41
+ raise OrionisTestConfigException("The config parameter must be an instance of the Testing class.")
22
42
 
23
- Parameters
24
- ----------
25
- base_path : str, optional
26
- The base path for the tests. Defaults to 'tests'.
27
- folder_path : str or list of str, optional
28
- Path(s) to the folder(s) containing test files. Use '*' to scan all folders
29
- under the base path. Defaults to '*'.
30
- pattern : str, optional
31
- File pattern to match test files. Defaults to 'test_*.py'.
43
+ # Initialize the test suite
44
+ tests = UnitTest()
32
45
 
33
- Returns
34
- -------
35
- UnitTestClass
36
- An initialized test suite containing the discovered test files.
46
+ # Assign config values to the test suite
47
+ tests.configure(
48
+ verbosity=config.verbosity,
49
+ execution_mode=config.execution_mode,
50
+ max_workers=config.max_workers,
51
+ fail_fast=config.fail_fast,
52
+ print_result=config.print_result,
53
+ throw_exception=config.throw_exception
54
+ )
37
55
 
38
- Raises
39
- ------
40
- TypeError
41
- If `base_path` is not a string, `folder_path` is not a string or list, or
42
- `pattern` is not a string.
43
- """
44
- # Validate parameters
45
- if not isinstance(base_path, str):
46
- raise TypeError("base_path must be a string")
47
- if not isinstance(folder_path, (str, list)):
48
- raise TypeError("folder_path must be a string or a list")
49
- if not isinstance(pattern, str):
50
- raise TypeError("pattern must be a string")
56
+ # Extract configuration values
57
+ base_path = config.base_path
58
+ folder_path = config.folder_path
59
+ pattern = config.pattern
51
60
 
52
61
  # Helper function to list folders matching the pattern
53
62
  def list_matching_folders(custom_path: str, pattern: str):
@@ -66,19 +75,18 @@ class TestSuite(ITestSuite):
66
75
  discovered_folders.extend(list_matching_folders(base_path, pattern))
67
76
  elif isinstance(folder_path, list):
68
77
  for custom_path in folder_path:
69
- discovered_folders.extend(list_matching_folders(custom_path, pattern))
78
+ discovered_folders.extend(list_matching_folders(f"{base_path}/{custom_path}", pattern))
70
79
  else:
71
80
  discovered_folders.extend(list_matching_folders(folder_path, pattern))
72
81
 
73
- # Initialize the test suite
74
- tests = UnitTestClass()
75
-
76
82
  # Add discovered folders to the test suite
77
83
  for folder in discovered_folders:
78
84
  tests.discoverTestsInFolder(
79
- base_path=base_path,
80
85
  folder_path=folder,
81
- pattern=pattern
86
+ base_path=base_path,
87
+ pattern=pattern,
88
+ test_name_pattern=config.test_name_pattern if config.test_name_pattern else None,
89
+ tags=config.tags if config.tags else None
82
90
  )
83
91
 
84
92
  # Return the initialized test suite