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,30 +1,31 @@
1
1
  from dataclasses import dataclass
2
- from typing import Optional
2
+ from typing import Any, Optional
3
3
  from orionis.luminate.test.enums.test_status import TestStatus
4
4
 
5
- @dataclass(frozen=True)
5
+ @dataclass(frozen=True, kw_only=True)
6
6
  class TestResult:
7
7
  """
8
- Data class containing detailed information about a test result.
8
+ Represents the result of a test execution.
9
9
 
10
- Attributes
11
- ----------
12
- name : str
13
- The name of the test.
14
- status : TestStatus
15
- The status of the test, indicating whether it passed, failed, or was skipped.
16
- execution_time : float
17
- The time taken to execute the test, in seconds.
18
- error_message : str, optional
19
- The error message if the test failed, by default None.
20
- traceback : str, optional
21
- The traceback information if the test failed, by default None.
22
- file_path : str, optional
23
- The file path where the test is located, by default None.
10
+ Attributes:
11
+ id (Any): Unique identifier for the test result.
12
+ name (str): Name of the test.
13
+ status (TestStatus): Status of the test execution (e.g., passed, failed).
14
+ execution_time (float): Time taken to execute the test, in seconds.
15
+ error_message (Optional[str]): Error message if the test failed, otherwise None.
16
+ traceback (Optional[str]): Traceback information if an error occurred, otherwise None.
17
+ class_name (Optional[str]): Name of the class containing the test, if applicable.
18
+ method (Optional[str]): Name of the method representing the test, if applicable.
19
+ module (Optional[str]): Name of the module containing the test, if applicable.
20
+ file_path (Optional[str]): Path to the file containing the test, if applicable.
24
21
  """
22
+ id: Any
25
23
  name: str
26
24
  status: TestStatus
27
25
  execution_time: float
28
26
  error_message: Optional[str] = None
29
27
  traceback: Optional[str] = None
30
- file_path: Optional[str] = None
28
+ class_name : Optional[str] = None
29
+ method : Optional[str] = None
30
+ module : Optional[str] = None
31
+ file_path: Optional[str] = None
@@ -0,0 +1,16 @@
1
+ from enum import Enum
2
+
3
+ class ExecutionMode(Enum):
4
+ """
5
+ ExecutionMode is an enumeration that defines the modes of execution
6
+ for a process or task.
7
+
8
+ Attributes
9
+ ----------
10
+ SEQUENTIAL : str
11
+ Represents sequential execution mode, where tasks are executed one after another.
12
+ PARALLEL : str
13
+ Represents parallel execution mode, where tasks are executed concurrently.
14
+ """
15
+ SEQUENTIAL = "sequential"
16
+ PARALLEL = "parallel"
@@ -0,0 +1,28 @@
1
+ class OrionisTestConfigException(Exception):
2
+ """
3
+ Custom exception for test configuration errors in the Orionis framework.
4
+
5
+ This exception is raised when there is an issue with the test configuration,
6
+ providing a clear and descriptive error message to aid in debugging.
7
+ """
8
+
9
+ def __init__(self, msg: str):
10
+ """
11
+ Initializes the OrionisTestConfigException with a specific error message.
12
+
13
+ Args:
14
+ msg (str): A descriptive error message explaining the cause of the exception.
15
+ """
16
+ super().__init__(msg)
17
+
18
+ def __str__(self) -> str:
19
+ """
20
+ Returns a formatted string representation of the exception.
21
+
22
+ The string includes the exception name and the error message, providing
23
+ a clear and concise description of the issue.
24
+
25
+ Returns:
26
+ str: A formatted string describing the exception.
27
+ """
28
+ return f"{self.__class__.__name__}: {self.args[0]}"
@@ -1,45 +1,52 @@
1
+ import unittest
2
+
1
3
  class OrionisTestFailureException(Exception):
2
4
  """
3
- Custom exception raised when test execution results in one or more failures.
4
-
5
- This exception is used to indicate that a test suite run has encountered failures.
6
- It stores a response message detailing the number of failed tests or other relevant
7
- error information.
8
-
9
- Parameters
10
- ----------
11
- response : str
12
- A message describing the reason for the test failure.
13
-
14
- Attributes
15
- ----------
16
- response : str
17
- Stores the response message describing the failure.
18
-
19
- Methods
20
- -------
21
- __str__() -> str
22
- Returns a string representation of the exception, including the response message.
5
+ OrionisTestFailureException is a custom exception class used to handle test failures and errors
6
+ in a structured manner. It provides detailed information about the failed and errored tests,
7
+ including their IDs and formatted error messages.
8
+ Methods:
9
+ __init__(result: unittest.TestResult):
10
+ __str__() -> str:
23
11
  """
24
12
 
25
- def __init__(self, response: str):
13
+ def __init__(self, result: unittest.TestResult):
26
14
  """
27
- Initializes the exception with a response message.
28
-
29
- Parameters
30
- ----------
31
- response : str
32
- The message describing the test failure.
15
+ Initializes the exception with details about failed and errored tests.
16
+ Args:
17
+ result (unittest.TestResult): The test result object containing information
18
+ about test failures and errors.
19
+ Attributes:
20
+ failed_tests (list): A list of IDs for tests that failed.
21
+ errored_tests (list): A list of IDs for tests that encountered errors.
22
+ error_messages (list): A list of formatted error messages for failed and errored tests.
23
+ text (str): A formatted string summarizing the test failures and errors.
24
+ Raises:
25
+ Exception: An exception with a message summarizing the number of failed
26
+ and errored tests along with their details.
33
27
  """
34
- super().__init__(response)
28
+ failed_tests = [test.id() for test, _ in result.failures]
29
+ errored_tests = [test.id() for test, _ in result.errors]
30
+
31
+ error_messages = []
32
+ for test in failed_tests:
33
+ error_messages.append(f"Test Fail: {test}")
34
+ for test in errored_tests:
35
+ error_messages.append(f"Test Error: {test}")
36
+
37
+ text = "\n".join(error_messages)
38
+
39
+ super().__init__(f"{len(failed_tests) + len(errored_tests)} test(s) failed or errored:\n{text}")
35
40
 
36
41
  def __str__(self) -> str:
37
42
  """
38
- Returns a human-readable string representation of the exception.
43
+ Returns a string representation of the exception.
44
+
45
+ The string includes the exception name and the first argument
46
+ passed to the exception, providing a clear description of the
47
+ test failure.
39
48
 
40
- Returns
41
- -------
42
- str
43
- A formatted string containing the exception name and response message.
49
+ Returns:
50
+ str: A formatted string describing the exception.
44
51
  """
45
- return f"OrionisTestFailureException: {self.args[0]}"
52
+ return f"{self.__class__.__name__}: {self.args[0]}"
@@ -1,17 +1,28 @@
1
- from typing import Any
2
-
3
- class ITestStdOut:
1
+ from abc import ABC, abstractmethod
2
+ class ITestStdOut(ABC):
4
3
  """
5
- Utility for printing debug info during tests, including caller context (file, line, method).
4
+ Interface for standard output debugging utilities.
5
+ This interface defines methods for dumping debugging information, capturing the caller's file, method, and line number, and utilizing a Debug class to output the information. Implementations should provide mechanisms to output or log the provided arguments for debugging purposes
6
6
  """
7
7
 
8
- @staticmethod
9
- def print(*args: Any) -> None:
8
+ @abstractmethod
9
+ def dd(self, *args):
10
+ """
11
+ Dumps debugging information using the Debug class.
12
+ This method captures the caller's file, method, and line number,
13
+ and uses the Debug class to output debugging information.
14
+ Args:
15
+ *args: Variable length argument list to be dumped.
10
16
  """
11
- Print arguments to the console with file, line, and method of the caller.
17
+ pass
12
18
 
13
- Parameters
14
- ----------
15
- *args : Any
16
- Any values to print. The first argument is ignored (typically the class or context).
19
+ @abstractmethod
20
+ def dump(self, *args):
21
+ """
22
+ Dumps debugging information using the Debug class.
23
+ This method captures the caller's file, method, and line number,
24
+ and uses the Debug class to output debugging information.
25
+ Args:
26
+ *args: Variable length argument list to be dumped.
17
27
  """
28
+ pass
@@ -1,66 +1,97 @@
1
1
  import os
2
2
  import sys
3
- from orionis.luminate.console.output.console import Console
4
3
  from orionis.luminate.test.output.contracts.test_std_out import ITestStdOut
4
+ from orionis.luminate.console.dumper.dump_die import Debug
5
5
 
6
6
  class TestStdOut(ITestStdOut):
7
7
  """
8
- A utility class for printing debug information during testing. This class temporarily
9
- redirects the standard output and error streams to their original states to ensure
10
- proper console output, and provides contextual information about the file and line
11
- number where the print call was made.
12
- Methods
13
- -------
14
- print(*args)
15
- Prints the provided arguments to the console with contextual information
16
- about the file and line number of the caller. If no arguments are provided,
17
- the method does nothing.
8
+ TestStdOut provides utility methods for debugging and outputting information during test execution.
9
+ This class implements methods to determine if an object is a test case instance and to output debugging
10
+ information using the Debug class. It ensures that standard output and error streams are properly managed
11
+ during debugging dumps, and captures the caller's file and line number for context.
18
12
  """
19
13
 
20
- def print(*args):
14
+ def __isTestCaseClass(self, value):
21
15
  """
22
- Prints the provided arguments to the console with contextual information
23
- about the file and line number of the caller. The output is formatted with
24
- muted text decorations for better readability.
25
- Parameters
26
- ----------
27
- *args : tuple
28
- The arguments to be printed. The first argument is ignored, and the
29
- remaining arguments are printed. If no arguments are provided, the
30
- method does nothing.
31
- Notes
32
- -----
33
- - The method temporarily redirects `sys.stdout` and `sys.stderr` to their
34
- original states (`sys.__stdout__` and `sys.__stderr__`) to ensure proper
35
- console output.
36
- - The contextual information includes the file path and line number of the
37
- caller, which is displayed in a muted text format.
38
- - After printing, the method restores the original `sys.stdout` and
39
- `sys.stderr` streams.
16
+ Determines if the given value is an instance of a test case class.
17
+ This method checks whether the provided value is an instance of one of the
18
+ predefined test case classes: AsyncTestCase, TestCase, or SyncTestCase.
19
+ If the value is None or an ImportError occurs during the import of the
20
+ test case classes, the method returns False.
21
+ Args:
22
+ value: The object to be checked.
23
+ Returns:
24
+ bool: True if the value is an instance of AsyncTestCase, TestCase,
25
+ or SyncTestCase; False otherwise.
40
26
  """
27
+ try:
28
+ if value is None:
29
+ return False
30
+ from orionis.luminate.test.cases.test_async import AsyncTestCase
31
+ from orionis.luminate.test.cases.test_case import TestCase
32
+ from orionis.luminate.test.cases.test_sync import SyncTestCase
33
+ return isinstance(value, (AsyncTestCase, TestCase, SyncTestCase))
34
+ except Exception:
35
+ return False
41
36
 
42
- # Check if the first argument is a string and remove it from the args tuple
43
- if len(args) == 0:
37
+ def dd(self, *args):
38
+ """
39
+ Dumps debugging information using the Debug class.
40
+ This method captures the caller's file, method, and line number,
41
+ and uses the Debug class to output debugging information.
42
+ Args:
43
+ *args: Variable length argument list to be dumped.
44
+ """
45
+ if not args:
46
+ return
47
+
48
+ original_stdout = sys.stdout
49
+ original_stderr = sys.stderr
50
+
51
+ try:
52
+ sys.stdout = sys.__stdout__
53
+ sys.stderr = sys.__stderr__
54
+
55
+ caller_frame = sys._getframe(1)
56
+ _file = os.path.abspath(caller_frame.f_code.co_filename)
57
+ _line = caller_frame.f_lineno
58
+
59
+ dumper = Debug(f"{_file}:{_line}")
60
+ if self.__isTestCaseClass(args[0]):
61
+ dumper.dd(*args[1:])
62
+ else:
63
+ dumper.dd(*args)
64
+ finally:
65
+ sys.stdout = original_stdout
66
+ sys.stderr = original_stderr
67
+
68
+ def dump(self, *args):
69
+ """
70
+ Dumps debugging information using the Debug class.
71
+ This method captures the caller's file, method, and line number,
72
+ and uses the Debug class to output debugging information.
73
+ Args:
74
+ *args: Variable length argument list to be dumped.
75
+ """
76
+ if not args:
44
77
  return
45
78
 
46
- # Change the output stream to the original stdout and stderr
47
- # to avoid any issues with the console output
48
79
  original_stdout = sys.stdout
49
80
  original_stderr = sys.stderr
50
- sys.stdout = sys.__stdout__
51
- sys.stderr = sys.__stderr__
52
81
 
53
- # Get the file name and line number of the caller
54
- # using sys._getframe(1) to access the caller's frame
55
- _file = os.path.relpath(sys._getframe(1).f_code.co_filename, start=os.getcwd())
56
- _method = sys._getframe(1).f_code.co_name
57
- _line = sys._getframe(1).f_lineno
82
+ try:
83
+ sys.stdout = sys.__stdout__
84
+ sys.stderr = sys.__stderr__
58
85
 
59
- # Print the contextual information and the provided arguments
60
- Console.textMuted(f"[Printout] File: {_file}, Line: {_line}, Method: {_method}")
61
- print(*args[1:], end='\n')
62
- Console.newLine()
86
+ caller_frame = sys._getframe(1)
87
+ _file = os.path.abspath(caller_frame.f_code.co_filename)
88
+ _line = caller_frame.f_lineno
63
89
 
64
- # Restore the original stdout and stderr streams
65
- sys.stdout = original_stdout
66
- sys.stderr = original_stderr
90
+ dumper = Debug(f"{_file}:{_line}")
91
+ if self.__isTestCaseClass(args[0]):
92
+ dumper.dump(*args[1:])
93
+ else:
94
+ dumper.dump(*args)
95
+ finally:
96
+ sys.stdout = original_stdout
97
+ sys.stderr = original_stderr
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.245.0
3
+ Version: 0.247.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -14,6 +14,9 @@ License-File: LICENCE
14
14
  Requires-Dist: apscheduler>=3.11.0
15
15
  Requires-Dist: python-dotenv>=1.0.1
16
16
  Requires-Dist: requests>=2.32.3
17
+ Requires-Dist: rich>=13.9.4
18
+ Requires-Dist: psutil>=7.0.0
19
+ Requires-Dist: cryptography>=44.0.3
17
20
  Dynamic: author
18
21
  Dynamic: author-email
19
22
  Dynamic: classifier