Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/scripts/validate-parameters.shell
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function validate_parameters() {

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

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/coverage/lib/system_params.coverage
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name Stmts Miss Branch BrPart Cover
--------------------------------------------------------
lib/system_params.py 76 76 16 0 0%
lib/system_params.py 115 115 42 0 0%
--------------------------------------------------------
TOTAL 76 76 16 0 0%
TOTAL 115 115 42 0 0%
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name Stmts Miss Branch BrPart Cover
------------------------------------------------------------------------------
packages/requirements/lib/version_utils.py 126 126 34 0 0%
packages/requirements/lib/version_utils.py 114 114 30 0 0%
------------------------------------------------------------------------------
TOTAL 126 126 34 0 0%
TOTAL 114 114 30 0 0%
19 changes: 0 additions & 19 deletions docs/pydoc/.prototypes/testing.pydoc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/pydoc/lib/pkgconfig_loader.pydoc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ DATA
project_logs = PosixPath('<project-location>/logs...
project_packages = PosixPath('<project-location>/...
project_root = PosixPath('<project-location>')
timestamp = '20250310091339'
timestamp = '20250312140238'

VERSION
0.1.0
Expand Down
38 changes: 37 additions & 1 deletion docs/pydoc/lib/system_params.pydoc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ FUNCTIONS
Error Handling:
- Raises RuntimeError if an error occurs while retrieving the variable.

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

DATA
Dict = typing.Dict
A generic version of dict.

Optional = typing.Optional
Optional[X] is equivalent to Union[X, None].

RUNTIME_PARAMS = {'defaults': {'options': {'auto': 'False', 'debug': '...
SECTIONS_VARS = {'defaults': {'auto': 'False', 'debug': 'False', 'exam...
SYSTEM_PARAMS = {'defaults': {'options': {'auto': {'default': False, '...
Union = typing.Union
Union type; Union[X, Y] means either X or Y.

On Python 3.10 and higher, the | operator
can also be used to denote unions;
X | Y means the same thing to the type checker as Union[X, Y].

To define a union, use e.g. Union[int, str]. Details:
- The arguments must be types and there must be at least one.
- None as an argument is a special case and is replaced by
type(None).
- Unions of unions are flattened, e.g.::

assert Union[Union[int, str], float] == Union[int, str, float]

- Unions of a single argument vanish, e.g.::

assert Union[int] == int # The constructor actually returns int

- Redundant arguments are skipped, e.g.::

assert Union[int, str, int] == Union[int, str]

- When comparing unions, the argument order is ignored, e.g.::

assert Union[int, str] == Union[str, int]

- You cannot subclass or instantiate a union.
- You can use Optional[X] as a shorthand for Union[X, None].

default_params_filepath = PosixPath('<user-home>/.repos/devops/wor...
file = <_io.TextIOWrapper name='<user-home>/.repos/...s/runtime-pa...
project_params_filepath = PosixPath('<user-home>/.repos/devops/wor...
Expand Down
39 changes: 36 additions & 3 deletions docs/pydoc/tests/mocks/__init__.pydoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
### Documentation for tests/mocks/__init__.py

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

NAME
tests.mocks.__init__ - # File: ./scripts/__init__.py
tests.mocks.__init__ - File Path: tests/mocks/__init__.py

DESCRIPTION
Description:
Initialization module for the `tests.mocks` package.

This module ensures that the `tests/mocks/` directory is recognized as a Python package.
It provides a structured framework for organizing mock objects and configurations used
across the test suite.

Core Features:
- **Package Initialization**: Enables `tests/mocks/` to function as a Python package.
- **Mock Configuration Management**: Ensures that mock configuration loaders are accessible.
- **Explicit Import Control**: Prevents unintended execution by requiring explicit mock imports.
- **Dynamic Documentation Loading**: Loads and applies documentation dynamically to maintain
structured docstrings across modules.

Usage:
Modules within `tests/mocks/` should be explicitly imported when needed:
from tests.mocks import config_loader
config_loader.load_mock_requirements()

Important Notes:
- This file **does not** automatically import submodules to prevent unnecessary execution.
- Individual mock modules must be explicitly imported as required to maintain modularity.

Dependencies:
- pathlib (for handling file paths)
- sys (for managing system path imports)
- lib.pydoc_loader (for loading documentation dynamically)

Example:
```python
from tests.mocks import config_loader
config_data = config_loader.load_mock_requirements()
```

VERSION
0.1.0
Expand Down
109 changes: 53 additions & 56 deletions docs/pydoc/tests/mocks/config_loader.pydoc
Original file line number Diff line number Diff line change
@@ -1,107 +1,104 @@
### Documentation for tests/mocks/config_loader.py

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

NAME
tests.mocks.config_loader - File Path: tests/mocks/config_loader.py

DESCRIPTION
Description:
Mock Configuration Loader for Test Environments
Mock Configuration Loader Module

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

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

Expected Behavior:
- If `mock_requirements.json` or `mock_installed.json` is missing, a default structure is used.
- Test cases can rely on consistent configuration values.
- Returns structured dictionaries with all required configuration fields.
Usage:
To load mock requirements:
from tests.mocks.config_loader import load_mock_requirements
mock_config = load_mock_requirements()

To load installed package mock data:
from tests.mocks.config_loader import load_mock_installed
installed_config = load_mock_installed()

Dependencies:
- json (for reading and writing structured data)
- pathlib (for managing file paths)
- sys - Handles system path modifications.
- os - Provides file system utilities.
- json - Loads and validates JSON-based configuration data.
- pathlib - Ensures safe file path resolution.

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

requirements = load_mock_requirements()
installed = load_mock_installed()
```
Exit Codes:
- 0: Execution completed successfully.
- 1: Failure due to configuration loading errors.

FUNCTIONS
load_mock_installed() -> dict
Function: load_mock_installed()
Function: load_mock_installed() -> dict

Description:
Loads and returns the contents of `mock_installed.json`, ensuring
that all required fields are present. If the file is missing, a default
base configuration is returned.
Loads and returns the contents of `mock_installed.json`, ensuring missing fields are populated.

Parameters:
- None

Returns:
- dict: A structured dictionary representing the mock installed package configuration.
- dict: The processed installed package configuration dictionary.

Behavior:
- If `mock_installed.json` exists, its contents are loaded.
- If the file is missing, a predefined base configuration is used.
- Ensures all required keys are present in the loaded data.

Example:
```python
installed = load_mock_installed()
print(installed["packages"]["installation"]["configs"])
```

Notes:
- Used for testing dependency installations and package state validation.
- Guarantees test cases receive structured data.
- Ensures structured test data for installed dependencies.
- Uses `BASE_INSTALLED_CONFIG` as a fallback if the file is missing.

load_mock_requirements() -> dict
Function: load_mock_requirements()
Function: load_mock_requirements() -> dict

Description:
Loads and returns the contents of `mock_requirements.json`, ensuring
that all required fields are present. If the file is missing, a default
base configuration is returned.
Loads and returns the contents of `mock_requirements.json`, ensuring missing fields are populated.

Parameters:
- None

Returns:
- dict: A structured dictionary representing the mock requirements configuration.
- dict: The processed configuration dictionary with all necessary fields.

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

Example:
```python
config = load_mock_requirements()
print(config["logging"]["enable"]) # True
```
main() -> None
Function: main() -> None

Notes:
- Prevents test failures due to missing configuration files.
- Populates default values for missing fields.
Description:
Placeholder function for module execution.

main() -> None
Parameters:
- None

Returns:
- None

DATA
BASE_INSTALLED_CONFIG = {'colors': {}, 'environment': {'BREW_AVAILABLE...
BASE_REQUIREMENTS_CONFIG = {'colors': {}, 'environment': {'BREW_AVAILA...
INSTALLED_FILEPATH = '<project-location>/tests/mo...
LIB_DIR = PosixPath('<project-location>/lib')
MOCKS_DIR = PosixPath('<project-location>/tests/m...
REQUIREMENTS_FILEPATH = '<project-location>/tests...
SCRIPT_DIR = '<project-location>/tests/mocks'
installed_config = {'colors': {}, 'environment': {'BREW_AVAILABLE': Fa...
requirements_config = {'colors': {}, 'environment': {'BREW_AVAILABLE':...
validation_schema = {'requirements': [{}]}

VERSION
0.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FUNCTIONS
- `None` when the package is not found.

test_check_availability_failure()
**Test: Homebrew Availability (Failure)**
**Test: Homebrew Availability (Failure)**

**Purpose:**
- Ensure `check_availability()` correctly identifies when Homebrew is **not installed**.
Expand All @@ -32,7 +32,7 @@ FUNCTIONS
- Homebrew is **not installed** or its binary is not in the system `PATH`.

test_check_availability_success()
**Test: Homebrew Availability (Success)**
**Test: Homebrew Availability (Success)**

**Purpose:**
- Verify that `check_availability()` correctly detects when Homebrew is installed.
Expand All @@ -48,7 +48,7 @@ FUNCTIONS
- Homebrew is installed and accessible via `/usr/local/bin/brew`.

test_detect_environment_brew()
**Test: Detect Homebrew-Managed Python Environment**
**Test: Detect Homebrew-Managed Python Environment**

**Purpose:**
- Validate that `detect_environment()` correctly identifies a **Homebrew-managed Python installation**.
Expand All @@ -65,7 +65,7 @@ FUNCTIONS
- The system has Homebrew installed and Python is managed by Homebrew.

test_detect_environment_standalone()
**Test: Detect Standalone Python Environment**
**Test: Detect Standalone Python Environment**

**Purpose:**
- Ensure `detect_environment()` correctly identifies when Python is **not managed by Homebrew**.
Expand All @@ -90,7 +90,7 @@ FUNCTIONS
- `None` when the package is not found.

test_latest_version_success(installed_config)
**Test: Retrieve Latest Available Version of a Homebrew Package**
**Test: Retrieve Latest Available Version of a Homebrew Package**

**Purpose:**
- Validate that `latest_version(package)` correctly extracts the latest stable version of a Homebrew package.
Expand All @@ -106,7 +106,7 @@ FUNCTIONS
- The package is available in Homebrew and has a newer version.

test_version_installed(requirements_config)
**Test: Retrieve Installed Package Version (Homebrew)**
**Test: Retrieve Installed Package Version (Homebrew)**

**Purpose:**
- Validate that `version(package)` correctly retrieves the installed version of a Homebrew-managed package.
Expand All @@ -122,7 +122,7 @@ FUNCTIONS
- The package exists and is installed via Homebrew.

test_version_not_installed()
**Test: Handle Missing Package in Homebrew**
**Test: Handle Missing Package in Homebrew**

**Purpose:**
- Ensure `version(package)` returns `None` when the package is not installed.
Expand All @@ -138,8 +138,6 @@ FUNCTIONS

DATA
ROOT_DIR = PosixPath('<project-location>')
__module_name__ = 'brew_utils'
__package_name__ = 'requirements'
pytestmark = MarkDecorator(mark=Mark(name='skipif', args=(Fal...': 'Ho...

VERSION
Expand Down
Loading