orionis 0.246.0__py3-none-any.whl → 0.248.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 (91) 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/entities/testing.py +192 -14
  14. orionis/luminate/config/exceptions/integrity_exception.py +30 -0
  15. orionis/luminate/console/dumper/dump_die.py +418 -0
  16. orionis/luminate/contracts/facades/commands/scheduler_facade.py +1 -1
  17. orionis/luminate/facades/files/path_facade.py +1 -1
  18. orionis/luminate/patterns/__init__.py +4 -0
  19. orionis/luminate/patterns/singleton/__init__.py +10 -0
  20. orionis/luminate/patterns/singleton/meta_class.py +56 -0
  21. orionis/luminate/providers/commands/reactor_commands_service_provider.py +3 -3
  22. orionis/luminate/providers/commands/scheduler_provider.py +1 -1
  23. orionis/luminate/providers/config/config_service_provider.py +1 -1
  24. orionis/luminate/providers/environment/environment__service_provider.py +2 -2
  25. orionis/luminate/providers/files/paths_provider.py +1 -1
  26. orionis/luminate/providers/log/log_service_provider.py +2 -2
  27. orionis/luminate/services/environment/__init__.py +10 -0
  28. orionis/luminate/services/environment/contracts/__init__.py +5 -0
  29. orionis/luminate/services/environment/contracts/env.py +93 -0
  30. orionis/luminate/services/environment/dot_env.py +293 -0
  31. orionis/luminate/services/environment/env.py +77 -0
  32. orionis/luminate/services/paths/__init__.py +9 -0
  33. orionis/luminate/services/paths/contracts/resolver.py +67 -0
  34. orionis/luminate/services/paths/resolver.py +83 -0
  35. orionis/luminate/services/workers/__init__.py +10 -0
  36. orionis/luminate/services/workers/maximum_workers.py +36 -0
  37. orionis/luminate/services_/commands/__init__.py +0 -0
  38. orionis/luminate/services_/config/__init__.py +0 -0
  39. orionis/luminate/services_/log/__init__.py +0 -0
  40. orionis/luminate/test/__init__.py +11 -1
  41. orionis/luminate/test/cases/test_async.py +1 -10
  42. orionis/luminate/test/cases/test_case.py +8 -3
  43. orionis/luminate/test/cases/test_sync.py +1 -0
  44. orionis/luminate/test/core/contracts/test_suite.py +19 -31
  45. orionis/luminate/test/core/contracts/test_unit.py +4 -0
  46. orionis/luminate/test/core/test_suite.py +27 -26
  47. orionis/luminate/test/core/test_unit.py +28 -45
  48. orionis/luminate/test/entities/test_result.py +13 -16
  49. orionis/luminate/test/exceptions/test_exception.py +1 -1
  50. orionis/luminate/test/output/contracts/test_std_out.py +22 -11
  51. orionis/luminate/test/output/test_std_out.py +69 -80
  52. orionis/static/__init__.py +0 -0
  53. {orionis-0.246.0.dist-info → orionis-0.248.0.dist-info}/METADATA +4 -1
  54. {orionis-0.246.0.dist-info → orionis-0.248.0.dist-info}/RECORD +81 -51
  55. tests/config/__init__.py +0 -0
  56. tests/config/test_app.py +122 -0
  57. tests/config/test_auth.py +21 -0
  58. tests/config/test_cache.py +20 -0
  59. tests/patterns/__init__.py +0 -0
  60. tests/patterns/singleton/__init__.py +0 -0
  61. tests/patterns/singleton/test_singleton.py +18 -0
  62. tests/services/__init__.py +0 -0
  63. tests/services/environment/__init__.py +0 -0
  64. tests/services/environment/test_env.py +33 -0
  65. orionis/luminate/config/entities/app.py +0 -47
  66. orionis/luminate/config/entities/auth.py +0 -15
  67. orionis/luminate/config/entities/cache.py +0 -51
  68. orionis/luminate/support/environment/contracts/env.py +0 -68
  69. orionis/luminate/support/environment/env.py +0 -139
  70. orionis/luminate/support/environment/functions.py +0 -49
  71. orionis/luminate/support/environment/helper.py +0 -26
  72. orionis/luminate/support/patterns/singleton.py +0 -44
  73. tests/support/environment/test_env.py +0 -91
  74. tests/support/patterns/test_singleton.py +0 -18
  75. /orionis/luminate/config/{entities → app/entities}/__init__.py +0 -0
  76. /orionis/luminate/{services/commands → config/app/enums}/__init__.py +0 -0
  77. /orionis/luminate/{services/config → config/auth/entities}/__init__.py +0 -0
  78. /orionis/luminate/{services/log → config/cache/entities}/__init__.py +0 -0
  79. /orionis/luminate/{support/environment → config/cache/enums}/__init__.py +0 -0
  80. /orionis/luminate/{support/environment/contracts → config/exceptions}/__init__.py +0 -0
  81. /orionis/luminate/{support/patterns → console/dumper}/__init__.py +0 -0
  82. {tests/support/environment → orionis/luminate/services/paths/contracts}/__init__.py +0 -0
  83. {tests/support/patterns → orionis/luminate/services_}/__init__.py +0 -0
  84. /orionis/luminate/{services → services_}/commands/reactor_commands_service.py +0 -0
  85. /orionis/luminate/{services → services_}/commands/scheduler_service.py +0 -0
  86. /orionis/luminate/{services → services_}/config/config_service.py +0 -0
  87. /orionis/luminate/{services → services_}/log/log_service.py +0 -0
  88. {orionis-0.246.0.dist-info → orionis-0.248.0.dist-info}/LICENCE +0 -0
  89. {orionis-0.246.0.dist-info → orionis-0.248.0.dist-info}/WHEEL +0 -0
  90. {orionis-0.246.0.dist-info → orionis-0.248.0.dist-info}/entry_points.txt +0 -0
  91. {orionis-0.246.0.dist-info → orionis-0.248.0.dist-info}/top_level.txt +0 -0
@@ -1,68 +0,0 @@
1
- from abc import ABC, abstractmethod
2
- from typing import Any, Optional, Union
3
-
4
- class IEnv(ABC):
5
- """
6
- Interface for a utility class to manage environment variables in a `.env` file.
7
- """
8
-
9
- @staticmethod
10
- @abstractmethod
11
- def get(key: str, default: Optional[Any] = None) -> Any:
12
- """
13
- Retrieve the value of an environment variable.
14
-
15
- Parameters
16
- ----------
17
- key : str
18
- Name of the environment variable.
19
- default : Any, optional
20
- Default value if variable is not found.
21
-
22
- Returns
23
- -------
24
- Any
25
- Parsed value or default.
26
- """
27
- pass
28
-
29
- @staticmethod
30
- @abstractmethod
31
- def set(key: str, value: Union[str, int, float, bool, list, dict]) -> None:
32
- """
33
- Set the value of an environment variable.
34
-
35
- Parameters
36
- ----------
37
- key : str
38
- Name of the environment variable.
39
- value : str, int, float, bool, list, or dict
40
- Value to assign, will be serialized.
41
- """
42
- pass
43
-
44
- @staticmethod
45
- @abstractmethod
46
- def unset(key: str) -> None:
47
- """
48
- Remove an environment variable.
49
-
50
- Parameters
51
- ----------
52
- key : str
53
- Name of the environment variable.
54
- """
55
- pass
56
-
57
- @staticmethod
58
- @abstractmethod
59
- def all() -> dict:
60
- """
61
- Retrieve all environment variables as a dictionary.
62
-
63
- Returns
64
- -------
65
- dict
66
- Dictionary of parsed environment variables.
67
- """
68
- pass
@@ -1,139 +0,0 @@
1
- import os
2
- from typing import Any, Optional, Union
3
- from dotenv import set_key, unset_key, dotenv_values
4
- from orionis.luminate.support.environment.contracts.env import IEnv
5
- from orionis.luminate.support.environment.functions import (
6
- _initialize,
7
- _parse_value,
8
- _serialize_value,
9
- _delete_file
10
- )
11
- from orionis.luminate.support.patterns.singleton import SingletonMeta
12
-
13
- class Env(IEnv):
14
- """
15
- A utility class for managing environment variables stored in a `.env` file.
16
- """
17
-
18
- @staticmethod
19
- def get(key: str, default: Optional[Any] = None) -> Any:
20
- """
21
- Retrieves the value of an environment variable from the `.env` file.
22
-
23
- Parameters
24
- ----------
25
- path : str or Path, optional
26
- The path to the `.env` file. If None, a default path is used.
27
- key : str
28
- The name of the environment variable to retrieve.
29
- default : Any, optional
30
- The default value to return if the variable is not found.
31
-
32
- Returns
33
- -------
34
- Any
35
- The value of the environment variable, parsed into its appropriate type,
36
- or the default value if the variable is not found.
37
- """
38
- resolved_path = _initialize()
39
- value = dotenv_values(resolved_path).get(key) or os.getenv(key)
40
- return _parse_value(value) if value is not None else default
41
-
42
- @staticmethod
43
- def set(key: str, value: Union[str, int, float, bool, list, dict]) -> None:
44
- """
45
- Sets the value of an environment variable in the `.env` file.
46
-
47
- Parameters
48
- ----------
49
- path : str or Path, optional
50
- The path to the `.env` file. If None, a default path is used.
51
- key : str
52
- The name of the environment variable to set.
53
- value : str, int, float, bool, list, or dict
54
- The value to assign to the environment variable. It will be serialized
55
- before being stored.
56
-
57
- Returns
58
- -------
59
- None
60
- """
61
- resolved_path = _initialize()
62
- serialized_value = _serialize_value(value)
63
- set_key(str(resolved_path), key, serialized_value)
64
-
65
- @staticmethod
66
- def unset(key: str) -> None:
67
- """
68
- Removes an environment variable from the `.env` file.
69
-
70
- Parameters
71
- ----------
72
- path : str or Path, optional
73
- The path to the `.env` file. If None, a default path is used.
74
- key : str
75
- The name of the environment variable to remove.
76
-
77
- Returns
78
- -------
79
- None
80
- """
81
- resolved_path = _initialize()
82
- unset_key(str(resolved_path), key)
83
-
84
- @staticmethod
85
- def all() -> dict:
86
- """
87
- Retrieves all environment variables from the `.env` file.
88
-
89
- Parameters
90
- ----------
91
- path : str or Path, optional
92
- The path to the `.env` file. If None, a default path is used.
93
-
94
- Returns
95
- -------
96
- dict
97
- A dictionary containing all environment variables from the `.env` file,
98
- with their values parsed into their appropriate types.
99
- """
100
- resolved_path = _initialize()
101
- env_vars = {}
102
- data = dotenv_values(resolved_path)
103
-
104
- for key, value in data.items():
105
- env_vars[key] = _parse_value(value)
106
-
107
- return env_vars
108
-
109
- @staticmethod
110
- def initialize() -> None:
111
- """
112
- Initializes the `.env` file if it does not exist.
113
-
114
- Parameters
115
- ----------
116
- path : str or Path, optional
117
- The path to the `.env` file. If None, a default path is used.
118
-
119
- Returns
120
- -------
121
- None
122
- """
123
- _initialize()
124
-
125
- @staticmethod
126
- def destroy() -> None:
127
- """
128
- Deletes the `.env` file.
129
-
130
- Parameters
131
- ----------
132
- path : str or Path, optional
133
- The path to the `.env` file. If None, a default path is used.
134
-
135
- Returns
136
- -------
137
- None
138
- """
139
- _delete_file()
@@ -1,49 +0,0 @@
1
- import ast
2
- import os
3
- from pathlib import Path
4
- from typing import Any
5
-
6
- def _initialize() -> Path:
7
- """
8
- Inicializa la ruta al archivo `.env`.
9
- """
10
- resolved_path = Path(os.getcwd()) / ".env"
11
-
12
- # Asegurarse de que el archivo .env exista
13
- if not resolved_path.exists():
14
- resolved_path.touch()
15
-
16
- return resolved_path
17
-
18
- def _parse_value(value: Any) -> Any:
19
- """
20
- Parsea un valor de cadena en un tipo de dato de Python.
21
- """
22
- value = str(value).strip() if value is not None else None
23
-
24
- if not value or value.lower() in {'none', 'null'}:
25
- return None
26
- if value.lower() in {'true', 'false'}:
27
- return value.lower() == 'true'
28
- if value.isdigit():
29
- return int(value)
30
- try:
31
- return ast.literal_eval(value)
32
- except (ValueError, SyntaxError):
33
- return value
34
-
35
- def _serialize_value(value: Any) -> str:
36
- """
37
- Serializa un tipo de dato de Python en una cadena para almacenarlo en el archivo `.env`.
38
- """
39
- if isinstance(value, (list, dict, bool, int, float)):
40
- return repr(value)
41
- return str(value)
42
-
43
- def _delete_file() -> None:
44
- """
45
- Elimina el archivo especificado.
46
- """
47
- resolved_path = Path(os.getcwd()) / ".env"
48
- if resolved_path.exists():
49
- os.remove(resolved_path)
@@ -1,26 +0,0 @@
1
- from typing import Any
2
- from orionis.luminate.support.environment.env import Env
3
-
4
- def env(key: str, default = None) -> Any:
5
- """
6
- Retrieves the value of an environment variable.
7
-
8
- This function provides a convenient way to access environment variables
9
- stored in the application context. If the variable does not exist, it
10
- returns the specified default value.
11
-
12
- Parameters
13
- ----------
14
- key : str
15
- The name of the environment variable to retrieve.
16
- default : Any, optional
17
- The default value to return if the environment variable does not exist.
18
- Defaults to None.
19
-
20
- Returns
21
- -------
22
- Any
23
- The value of the environment variable, or the default value if the variable
24
- does not exist.
25
- """
26
- return Env.get(key, default)
@@ -1,44 +0,0 @@
1
- import threading
2
-
3
- class SingletonMeta(type):
4
- """
5
- A thread-safe metaclass for implementing the Singleton pattern.
6
-
7
- This metaclass ensures that only one instance of a class is created,
8
- even in a multithreaded environment, by using a lock to synchronize
9
- instance creation.
10
-
11
- Attributes
12
- ----------
13
- _instances : dict
14
- A dictionary that holds the single instances of the classes using this metaclass.
15
- _lock : threading.Lock
16
- A lock to ensure thread-safe instance creation.
17
- """
18
- _instances = {}
19
- _lock = threading.Lock()
20
-
21
- def __call__(cls, *args, **kwargs):
22
- """
23
- Return the singleton instance of the class in a thread-safe manner.
24
-
25
- If an instance does not already exist, it is created under the protection
26
- of a lock; otherwise, the existing instance is returned.
27
-
28
- Parameters
29
- ----------
30
- *args : list
31
- Positional arguments for the class constructor.
32
- **kwargs : dict
33
- Keyword arguments for the class constructor.
34
-
35
- Returns
36
- -------
37
- object
38
- The singleton instance of the class.
39
- """
40
- if cls not in cls._instances:
41
- with cls._lock:
42
- if cls not in cls._instances:
43
- cls._instances[cls] = super().__call__(*args, **kwargs)
44
- return cls._instances[cls]
@@ -1,91 +0,0 @@
1
- from orionis.luminate.support.environment.env import Env
2
- from orionis.luminate.test import TestCase
3
-
4
- class TestsEnvironment(TestCase):
5
-
6
- async def testGetEnvVariable(self):
7
- """
8
- Test retrieving an environment variable from the `.env` file.
9
- """
10
-
11
- # Mock the environment setup
12
- Env.set('TEST_KEY', 'TEST_VALUE')
13
-
14
- # Test the get method
15
- result = Env.get('TEST_KEY')
16
- self.assertEqual(result, "TEST_VALUE")
17
-
18
- # Test with a non-existent key
19
- result = Env.get('NON_EXISTENT_KEY', True)
20
- self.assertEqual(result, True)
21
-
22
- # Delete File .env
23
- Env.destroy()
24
-
25
- async def testSetEnvVariable(self):
26
- """
27
- Test setting an environment variable in the `.env` file.
28
- """
29
-
30
- # Set the environment variable
31
- Env.set('TEST_KEY', 'NEW_VALUE')
32
-
33
- # Verify the value was set correctly
34
- result = Env.get('TEST_KEY')
35
- self.assertEqual(result, 'NEW_VALUE')
36
-
37
- # Delete File .env
38
- Env.destroy()
39
-
40
- async def testUnsetEnvVariable(self):
41
- """
42
- Test removing an environment variable from the `.env` file.
43
- """
44
-
45
- # Set and then unset the environment variable
46
- Env.set('TEST_KEY', "TEST_VALUE")
47
- Env.unset('TEST_KEY')
48
-
49
- # Verify the variable was removed
50
- result = Env.get('TEST_KEY')
51
- self.assertIsNone(result)
52
-
53
- # Delete File .env
54
- Env.destroy()
55
-
56
- async def testGetEnvHelper(self):
57
- """"
58
- Test retrieving an environment variable using the env helper.
59
- """
60
-
61
- # Mock the environment setup
62
- Env.set('FRAMEWORK', 'https://github.com/orionis-framework/framework')
63
-
64
- # Import the env helper and retrieve the variable
65
- from orionis.luminate.support.environment.helper import env as get_env
66
- result = get_env('FRAMEWORK')
67
-
68
- # Verify the result
69
- self.assertEqual(result, 'https://github.com/orionis-framework/framework')
70
-
71
- # Delete File .env
72
- Env.destroy()
73
-
74
- async def test_get_all_env_variables(self):
75
- """
76
- Test retrieving all environment variables from the `.env` file.
77
- """
78
-
79
- # Mock the environment setup
80
- Env.set('KEY1', 'value1')
81
- Env.set('KEY2', 'value2')
82
-
83
- # Retrieve all environment variables
84
- result = Env.all()
85
-
86
- # Verify the result
87
- self.assertEqual(result.get('KEY1'), 'value1')
88
- self.assertEqual(result.get('KEY2'), 'value2')
89
-
90
- # Delete File .env
91
- Env.destroy()
@@ -1,18 +0,0 @@
1
- from orionis.luminate.support.patterns.singleton import SingletonMeta
2
- from orionis.luminate.test import TestCase
3
-
4
- class TestsAsyncCoroutine(TestCase):
5
-
6
- async def testSingletonMeta(self):
7
- """
8
- Test the SingletonMeta metaclass to ensure that only one instance of a class is created.
9
- """
10
- class SingletonClass(metaclass=SingletonMeta):
11
- def __init__(self, value):
12
- self.value = value
13
-
14
- instance1 = SingletonClass(1)
15
- instance2 = SingletonClass(2)
16
-
17
- self.assertIs(instance1, instance2)
18
- self.assertEqual(instance1.value, 1)