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,4 +1,5 @@
1
1
  from abc import ABC
2
+ import json
2
3
  from orionis.luminate.support.introspection.reflection import Reflection
3
4
  from orionis.luminate.test import TestCase
4
5
  from tests.support.inspection.fakes.fake_reflect_abstract import FakeAbstractClass
@@ -62,10 +63,70 @@ class TestReflectAbstract(TestCase):
62
63
  - Return type is correct
63
64
  """
64
65
  attributes = Reflection.abstract(FakeAbstractClass).getAllAttributes()
65
- self.print(attributes)
66
+ self.assertIn('__private_class_attribute', attributes.private)
67
+ self.assertIn('_protected_class_attribute', attributes.protected)
68
+ self.assertIn('public_class_attribute', attributes.public)
66
69
 
70
+ async def testReflectionAbstractGetAttribute(self):
71
+ """Test getAttribute() method.
67
72
 
73
+ Verifies that:
74
+ - Correct attribute is returned
75
+ - Attribute type is correct
76
+ """
77
+ attr = Reflection.abstract(FakeAbstractClass).getAttributes()
78
+ self.assertIn('__private_class_attribute', attr)
79
+ self.assertIn('_protected_class_attribute', attr)
80
+ self.assertIn('public_class_attribute', attr)
81
+
82
+ async def testReflectionAbstractGetPublicAttributes(self):
83
+ """Test getPublicAttributes() method.
84
+
85
+ Verifies that:
86
+ - Only public attributes are returned
87
+ - No private/protected attributes are included
88
+ """
89
+ public_attributes = Reflection.abstract(FakeAbstractClass).getPublicAttributes()
90
+ self.assertIn('public_class_attribute', public_attributes)
91
+ self.assertNotIn('_protected_class_attribute', public_attributes)
92
+ self.assertNotIn('__private_class_attribute', public_attributes)
93
+
94
+ async def testReflectionAbstractGetProtectedAttributes(self):
95
+ """Test getProtectedAttributes() method.
68
96
 
97
+ Verifies that:
98
+ - Only protected attributes are returned
99
+ - No private/public attributes are included
100
+ """
101
+ protected_attributes = Reflection.abstract(FakeAbstractClass).getProtectedAttributes()
102
+ self.assertIn('_protected_class_attribute', protected_attributes)
103
+ self.assertNotIn('__private_class_attribute', protected_attributes)
104
+ self.assertNotIn('public_class_attribute', protected_attributes)
105
+
106
+ async def testReflectionAbstractGetPrivateAttributes(self):
107
+ """Test getPrivateAttributes() method.
108
+
109
+ Verifies that:
110
+ - Only private attributes are returned
111
+ - No protected/public attributes are included
112
+ """
113
+ private_attributes = Reflection.abstract(FakeAbstractClass).getPrivateAttributes()
114
+ self.assertIn('__private_class_attribute', private_attributes)
115
+ self.assertNotIn('_protected_class_attribute', private_attributes)
116
+ self.assertNotIn('public_class_attribute', private_attributes)
117
+
118
+ async def testReflectionAbstractGetAllMethods(self):
119
+ """Test getAllMethods() method.
120
+
121
+ Verifies that:
122
+ - All methods are detected
123
+ - No private/protected methods are included
124
+ - Return type is correct
125
+ """
126
+ methods = Reflection.abstract(FakeAbstractClass).getAllMethods()
127
+ self.console().info(message="Hola")
128
+ # self.print(Reflection.abstract(FakeAbstractClass).getAllAttributes())
129
+ # self.dd(json.dumps(methods, indent=4))
69
130
 
70
131
 
71
132
 
@@ -37,7 +37,6 @@ class TestReflectInstance(TestCase):
37
37
  """Check that getAllAttributes returns all attributes of the class."""
38
38
  reflex = Reflection.instance(FakeClass())
39
39
  attributes = reflex.getAllAttributes()
40
- self.print(attributes)
41
40
  self.assertTrue("public_attr" in attributes.public)
42
41
  self.assertTrue("__private_attr" in attributes.private)
43
42
  self.assertTrue("_protected_attr" in attributes.protected)
@@ -1,47 +0,0 @@
1
- from dataclasses import dataclass, field
2
- from typing import Dict
3
-
4
- @dataclass
5
- class App:
6
- """
7
- Represents the application's core configuration.
8
-
9
- This class defines the essential settings for the application, including
10
- its name, debugging mode, encryption settings, and server-related properties.
11
-
12
- Attributes
13
- ----------
14
- name : str
15
- The name of the application, used in logs, UI elements, and notifications.
16
- debug : bool
17
- Determines whether debugging mode is enabled. Should be `False` in production.
18
- bytecode : bool
19
- Indicates whether Python bytecode caching (.pyc files) is enabled.
20
- timezone : str
21
- The default timezone for the application, used for logging and scheduled tasks.
22
- url : str
23
- The base URL or host address where the application runs.
24
- port : int
25
- The port number the application listens on.
26
- workers : int
27
- The number of worker processes handling requests (affects performance).
28
- reload : bool
29
- Enables automatic server reloading when code changes (useful for development).
30
- cipher : str
31
- The encryption algorithm used for secure data handling (e.g., "AES-256-GCM").
32
- key : str
33
- The encryption key used for cryptographic operations.
34
- custom : dict
35
- A dictionary for storing additional custom properties. Defaults to an empty dictionary.
36
- """
37
- name: str
38
- debug: bool
39
- bytecode: bool
40
- timezone: str
41
- url: str
42
- port: int
43
- workers: int
44
- reload: bool
45
- cipher: str
46
- key: str
47
- custom: Dict[str, any] = field(default_factory=dict)
@@ -1,15 +0,0 @@
1
- from dataclasses import dataclass, field
2
- from typing import Dict
3
-
4
- @dataclass
5
- class Auth:
6
- """
7
- Represents a class that holds custom properties in a dictionary.
8
-
9
- Attributes
10
- ----------
11
- custom : dict
12
- A dictionary to store any additional custom properties.
13
- This field is initialized with an empty dictionary by default.
14
- """
15
- custom: Dict[str, any] = field(default_factory=dict)
@@ -1,51 +0,0 @@
1
- from dataclasses import dataclass, field
2
- from typing import Dict, Any
3
-
4
- @dataclass
5
- class File:
6
- """
7
- Represents a file storage path.
8
-
9
- Attributes
10
- ----------
11
- path : str
12
- The file path used for caching.
13
- """
14
- path: str
15
-
16
- @dataclass
17
- class Stores:
18
- """
19
- Defines available cache stores.
20
-
21
- Attributes
22
- ----------
23
- file : File
24
- An instance of `File` representing file-based cache storage.
25
- """
26
- file: File
27
-
28
- @dataclass
29
- class Cache:
30
- """
31
- Configuration for a cache system.
32
-
33
- Attributes
34
- ----------
35
- default : str
36
- The default cache storage type (e.g., "ram" or "file").
37
- stores : Stores
38
- An instance of `Stores` containing cache storage configurations.
39
- custom : Dict[str, Any], optional
40
- A dictionary containing additional custom properties for cache configuration.
41
- Defaults to an empty dictionary.
42
-
43
- Notes
44
- -----
45
- - The `default` attribute defines the main cache type.
46
- - The `stores` attribute holds configurations for different cache stores.
47
- - The `custom` attribute allows for dynamic additional properties if needed.
48
- """
49
- default: str
50
- stores: Stores = field(default_factory=lambda: Stores(File("")))
51
- custom: Dict[str, Any] = field(default_factory=dict)
@@ -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,138 +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
-
12
- class Env(IEnv):
13
- """
14
- A utility class for managing environment variables stored in a `.env` file.
15
- """
16
-
17
- @staticmethod
18
- def get(key: str, default: Optional[Any] = None) -> Any:
19
- """
20
- Retrieves the value of an environment variable from the `.env` file.
21
-
22
- Parameters
23
- ----------
24
- path : str or Path, optional
25
- The path to the `.env` file. If None, a default path is used.
26
- key : str
27
- The name of the environment variable to retrieve.
28
- default : Any, optional
29
- The default value to return if the variable is not found.
30
-
31
- Returns
32
- -------
33
- Any
34
- The value of the environment variable, parsed into its appropriate type,
35
- or the default value if the variable is not found.
36
- """
37
- resolved_path = _initialize()
38
- value = dotenv_values(resolved_path).get(key) or os.getenv(key)
39
- return _parse_value(value) if value is not None else default
40
-
41
- @staticmethod
42
- def set(key: str, value: Union[str, int, float, bool, list, dict]) -> None:
43
- """
44
- Sets the value of an environment variable in the `.env` file.
45
-
46
- Parameters
47
- ----------
48
- path : str or Path, optional
49
- The path to the `.env` file. If None, a default path is used.
50
- key : str
51
- The name of the environment variable to set.
52
- value : str, int, float, bool, list, or dict
53
- The value to assign to the environment variable. It will be serialized
54
- before being stored.
55
-
56
- Returns
57
- -------
58
- None
59
- """
60
- resolved_path = _initialize()
61
- serialized_value = _serialize_value(value)
62
- set_key(str(resolved_path), key, serialized_value)
63
-
64
- @staticmethod
65
- def unset(key: str) -> None:
66
- """
67
- Removes an environment variable from the `.env` file.
68
-
69
- Parameters
70
- ----------
71
- path : str or Path, optional
72
- The path to the `.env` file. If None, a default path is used.
73
- key : str
74
- The name of the environment variable to remove.
75
-
76
- Returns
77
- -------
78
- None
79
- """
80
- resolved_path = _initialize()
81
- unset_key(str(resolved_path), key)
82
-
83
- @staticmethod
84
- def all() -> dict:
85
- """
86
- Retrieves all environment variables from the `.env` file.
87
-
88
- Parameters
89
- ----------
90
- path : str or Path, optional
91
- The path to the `.env` file. If None, a default path is used.
92
-
93
- Returns
94
- -------
95
- dict
96
- A dictionary containing all environment variables from the `.env` file,
97
- with their values parsed into their appropriate types.
98
- """
99
- resolved_path = _initialize()
100
- env_vars = {}
101
- data = dotenv_values(resolved_path)
102
-
103
- for key, value in data.items():
104
- env_vars[key] = _parse_value(value)
105
-
106
- return env_vars
107
-
108
- @staticmethod
109
- def initialize() -> None:
110
- """
111
- Initializes the `.env` file if it does not exist.
112
-
113
- Parameters
114
- ----------
115
- path : str or Path, optional
116
- The path to the `.env` file. If None, a default path is used.
117
-
118
- Returns
119
- -------
120
- None
121
- """
122
- _initialize()
123
-
124
- @staticmethod
125
- def destroy() -> None:
126
- """
127
- Deletes the `.env` file.
128
-
129
- Parameters
130
- ----------
131
- path : str or Path, optional
132
- The path to the `.env` file. If None, a default path is used.
133
-
134
- Returns
135
- -------
136
- None
137
- """
138
- _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)
File without changes
File without changes
File without changes