Skip to content

Commit 439646e

Browse files
authored
Merge pull request #11 from emvaldes/prototype
Prototype
2 parents d7a9880 + 6c3b274 commit 439646e

49 files changed

Lines changed: 4183 additions & 749 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coverage

0 Bytes
Binary file not shown.

.github/scripts/validate-parameters.shell

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function validate_parameters() {
7373

7474
script_dirname="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
7575
# read -ra parameters <<< "$( sanitize_parameters "${@}" )";
76-
# Capture output of sanitize_parameters as an array (preserving spaces)
76+
# Capture output of sanitize_parameters as an array (preserving spaces)
7777
mapfile -t parameters < <( ${script_dirname}/sanitize-parameters.shell "${@}" );
7878
# echo -e; for param in "${parameters[@]}"; do echo -e "Parameter: ${param}"; done;
7979

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name Stmts Miss Branch BrPart Cover
22
--------------------------------------------------------
3-
lib/system_params.py 76 76 16 0 0%
3+
lib/system_params.py 115 115 42 0 0%
44
--------------------------------------------------------
5-
TOTAL 76 76 16 0 0%
5+
TOTAL 115 115 42 0 0%
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name Stmts Miss Branch BrPart Cover
22
------------------------------------------------------------------------------
3-
packages/requirements/lib/version_utils.py 126 126 34 0 0%
3+
packages/requirements/lib/version_utils.py 114 114 30 0 0%
44
------------------------------------------------------------------------------
5-
TOTAL 126 126 34 0 0%
5+
TOTAL 114 114 30 0 0%

docs/pydoc/.prototypes/testing.pydoc

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/pydoc/lib/pkgconfig_loader.pydoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ DATA
165165
project_logs = PosixPath('<project-location>/logs...
166166
project_packages = PosixPath('<project-location>/...
167167
project_root = PosixPath('<project-location>')
168-
timestamp = '20250310091339'
168+
timestamp = '20250312140238'
169169

170170
VERSION
171171
0.1.0

docs/pydoc/lib/system_params.pydoc

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ FUNCTIONS
8080
Error Handling:
8181
- Raises RuntimeError if an error occurs while retrieving the variable.
8282

83-
load_json_config(runtime_params_filepath: pathlib._local.Path) -> dict
83+
load_json_config(
84+
json_filepath: str = '',
85+
validation_schema: Optional[dict] = None
86+
) -> Union[bool, dict]
8487
Function: load_json_config(runtime_params_filepath: Path) -> dict
8588
Description:
8689
Loads a JSON configuration file and validates its contents.
@@ -119,12 +122,45 @@ FUNCTIONS
119122
- Raises ValueError if the file is empty or contains invalid JSON.
120123

121124
DATA
125+
Dict = typing.Dict
126+
A generic version of dict.
127+
122128
Optional = typing.Optional
123129
Optional[X] is equivalent to Union[X, None].
124130

125131
RUNTIME_PARAMS = {'defaults': {'options': {'auto': 'False', 'debug': '...
126132
SECTIONS_VARS = {'defaults': {'auto': 'False', 'debug': 'False', 'exam...
127133
SYSTEM_PARAMS = {'defaults': {'options': {'auto': {'default': False, '...
134+
Union = typing.Union
135+
Union type; Union[X, Y] means either X or Y.
136+
137+
On Python 3.10 and higher, the | operator
138+
can also be used to denote unions;
139+
X | Y means the same thing to the type checker as Union[X, Y].
140+
141+
To define a union, use e.g. Union[int, str]. Details:
142+
- The arguments must be types and there must be at least one.
143+
- None as an argument is a special case and is replaced by
144+
type(None).
145+
- Unions of unions are flattened, e.g.::
146+
147+
assert Union[Union[int, str], float] == Union[int, str, float]
148+
149+
- Unions of a single argument vanish, e.g.::
150+
151+
assert Union[int] == int # The constructor actually returns int
152+
153+
- Redundant arguments are skipped, e.g.::
154+
155+
assert Union[int, str, int] == Union[int, str]
156+
157+
- When comparing unions, the argument order is ignored, e.g.::
158+
159+
assert Union[int, str] == Union[str, int]
160+
161+
- You cannot subclass or instantiate a union.
162+
- You can use Optional[X] as a shorthand for Union[X, None].
163+
128164
default_params_filepath = PosixPath('<user-home>/.repos/devops/wor...
129165
file = <_io.TextIOWrapper name='<user-home>/.repos/...s/runtime-pa...
130166
project_params_filepath = PosixPath('<user-home>/.repos/devops/wor...

docs/pydoc/tests/mocks/__init__.pydoc

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
11
### Documentation for tests/mocks/__init__.py
22

3-
⚠️ No .pydoc file found at <project-location>/tests/mocks/.pydocs/pydoc.__init__.py.
4-
⚠️ No .pydoc file found at <project-location>/tests/mocks/.pydocs/pydoc.__init__.py.
53
Help on module tests.mocks.__init__ in tests.mocks:
64

75
NAME
8-
tests.mocks.__init__ - # File: ./scripts/__init__.py
6+
tests.mocks.__init__ - File Path: tests/mocks/__init__.py
7+
8+
DESCRIPTION
9+
Description:
10+
Initialization module for the `tests.mocks` package.
11+
12+
This module ensures that the `tests/mocks/` directory is recognized as a Python package.
13+
It provides a structured framework for organizing mock objects and configurations used
14+
across the test suite.
15+
16+
Core Features:
17+
- **Package Initialization**: Enables `tests/mocks/` to function as a Python package.
18+
- **Mock Configuration Management**: Ensures that mock configuration loaders are accessible.
19+
- **Explicit Import Control**: Prevents unintended execution by requiring explicit mock imports.
20+
- **Dynamic Documentation Loading**: Loads and applies documentation dynamically to maintain
21+
structured docstrings across modules.
22+
23+
Usage:
24+
Modules within `tests/mocks/` should be explicitly imported when needed:
25+
from tests.mocks import config_loader
26+
config_loader.load_mock_requirements()
27+
28+
Important Notes:
29+
- This file **does not** automatically import submodules to prevent unnecessary execution.
30+
- Individual mock modules must be explicitly imported as required to maintain modularity.
31+
32+
Dependencies:
33+
- pathlib (for handling file paths)
34+
- sys (for managing system path imports)
35+
- lib.pydoc_loader (for loading documentation dynamically)
36+
37+
Example:
38+
```python
39+
from tests.mocks import config_loader
40+
config_data = config_loader.load_mock_requirements()
41+
```
942

1043
VERSION
1144
0.1.0

docs/pydoc/tests/mocks/config_loader.pydoc

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,104 @@
11
### Documentation for tests/mocks/config_loader.py
22

3-
⚠️ No .pydoc file found at <project-location>/tests/mocks/.pydocs/pydoc.__init__.py.
43
Help on module tests.mocks.config_loader in tests.mocks:
54

65
NAME
76
tests.mocks.config_loader - File Path: tests/mocks/config_loader.py
87

98
DESCRIPTION
109
Description:
11-
Mock Configuration Loader for Test Environments
10+
Mock Configuration Loader Module
1211

13-
This module provides structured mock configuration files for testing purposes. It ensures
14-
that test cases operate with predictable configuration data by loading predefined JSON files
15-
(`mock_requirements.json` and `mock_installed.json`).
12+
This module provides utilities for loading mock JSON-based configurations used
13+
in testing environments. It dynamically loads and processes configuration files,
14+
ensuring structured fallback handling and maintaining data integrity.
1615

1716
Core Features:
18-
- Loads `mock_requirements.json` for testing dependency policies.
19-
- Loads `mock_installed.json` for simulating installed packages.
20-
- Ensures missing configuration fields are automatically populated.
21-
- Prevents test failures due to missing or incomplete configuration files.
17+
- JSON Configuration Loading: Reads and validates structured JSON files.
18+
- Base Configuration Handling: Ensures required fields exist in loaded configurations.
19+
- Mock Data Processing: Allows simulated testing of dependency behaviors.
20+
- Error Handling: Captures and logs missing or malformed JSON files.
2221

23-
Expected Behavior:
24-
- If `mock_requirements.json` or `mock_installed.json` is missing, a default structure is used.
25-
- Test cases can rely on consistent configuration values.
26-
- Returns structured dictionaries with all required configuration fields.
22+
Usage:
23+
To load mock requirements:
24+
from tests.mocks.config_loader import load_mock_requirements
25+
mock_config = load_mock_requirements()
26+
27+
To load installed package mock data:
28+
from tests.mocks.config_loader import load_mock_installed
29+
installed_config = load_mock_installed()
2730

2831
Dependencies:
29-
- json (for reading and writing structured data)
30-
- pathlib (for managing file paths)
32+
- sys - Handles system path modifications.
33+
- os - Provides file system utilities.
34+
- json - Loads and validates JSON-based configuration data.
35+
- pathlib - Ensures safe file path resolution.
3136

32-
Usage:
33-
```python
34-
from tests.mocks.config_loader import load_mock_requirements, load_mock_installed
37+
Global Behavior:
38+
- Loads mock configuration data dynamically.
39+
- Ensures missing configuration fields are populated with default values.
40+
- Prevents errors due to missing or malformed configuration files.
3541

36-
requirements = load_mock_requirements()
37-
installed = load_mock_installed()
38-
```
42+
Exit Codes:
43+
- 0: Execution completed successfully.
44+
- 1: Failure due to configuration loading errors.
3945

4046
FUNCTIONS
4147
load_mock_installed() -> dict
42-
Function: load_mock_installed()
48+
Function: load_mock_installed() -> dict
4349

4450
Description:
45-
Loads and returns the contents of `mock_installed.json`, ensuring
46-
that all required fields are present. If the file is missing, a default
47-
base configuration is returned.
51+
Loads and returns the contents of `mock_installed.json`, ensuring missing fields are populated.
4852

4953
Parameters:
5054
- None
5155

5256
Returns:
53-
- dict: A structured dictionary representing the mock installed package configuration.
57+
- dict: The processed installed package configuration dictionary.
5458

5559
Behavior:
56-
- If `mock_installed.json` exists, its contents are loaded.
57-
- If the file is missing, a predefined base configuration is used.
58-
- Ensures all required keys are present in the loaded data.
59-
60-
Example:
61-
```python
62-
installed = load_mock_installed()
63-
print(installed["packages"]["installation"]["configs"])
64-
```
65-
66-
Notes:
67-
- Used for testing dependency installations and package state validation.
68-
- Guarantees test cases receive structured data.
60+
- Ensures structured test data for installed dependencies.
61+
- Uses `BASE_INSTALLED_CONFIG` as a fallback if the file is missing.
6962

7063
load_mock_requirements() -> dict
71-
Function: load_mock_requirements()
64+
Function: load_mock_requirements() -> dict
7265

7366
Description:
74-
Loads and returns the contents of `mock_requirements.json`, ensuring
75-
that all required fields are present. If the file is missing, a default
76-
base configuration is returned.
67+
Loads and returns the contents of `mock_requirements.json`, ensuring missing fields are populated.
7768

7869
Parameters:
7970
- None
8071

8172
Returns:
82-
- dict: A structured dictionary representing the mock requirements configuration.
73+
- dict: The processed configuration dictionary with all necessary fields.
8374

8475
Behavior:
85-
- If `mock_requirements.json` exists, its contents are loaded.
86-
- If the file is missing, a predefined base configuration is used.
87-
- Ensures all required keys are present in the loaded data.
76+
- Ensures a structured mock environment for package requirements.
77+
- Uses `BASE_REQUIREMENTS_CONFIG` as a fallback if the file is missing.
8878

89-
Example:
90-
```python
91-
config = load_mock_requirements()
92-
print(config["logging"]["enable"]) # True
93-
```
79+
main() -> None
80+
Function: main() -> None
9481

95-
Notes:
96-
- Prevents test failures due to missing configuration files.
97-
- Populates default values for missing fields.
82+
Description:
83+
Placeholder function for module execution.
9884

99-
main() -> None
85+
Parameters:
86+
- None
87+
88+
Returns:
89+
- None
10090

10191
DATA
10292
BASE_INSTALLED_CONFIG = {'colors': {}, 'environment': {'BREW_AVAILABLE...
10393
BASE_REQUIREMENTS_CONFIG = {'colors': {}, 'environment': {'BREW_AVAILA...
94+
INSTALLED_FILEPATH = '<project-location>/tests/mo...
95+
LIB_DIR = PosixPath('<project-location>/lib')
10496
MOCKS_DIR = PosixPath('<project-location>/tests/m...
97+
REQUIREMENTS_FILEPATH = '<project-location>/tests...
98+
SCRIPT_DIR = '<project-location>/tests/mocks'
99+
installed_config = {'colors': {}, 'environment': {'BREW_AVAILABLE': Fa...
100+
requirements_config = {'colors': {}, 'environment': {'BREW_AVAILABLE':...
101+
validation_schema = {'requirements': [{}]}
105102

106103
VERSION
107104
0.1.0

0 commit comments

Comments
 (0)