* Switch feature flag paths from docker.service.<name>.enabled to docker.services.<name>.enabled * Update CSP builder and smart-default toggles and unit tests * Update desktop cards iframe flag and desktop domain validation * Update logout domain filter and tests * Update recaptcha enable flags in Keycloak and EspoCRM * Fix sys-ctl-cln-docker meta description formatting * Follow-up: reorder imports in web_health_expectations so module_utils path injection runs before importing get_app_conf https://chatgpt.com/share/6963f484-4cb4-800f-a9f4-8d70a66e4d32
Unit Tests
This directory contains unit tests for various custom components in the project, such as the custom lookup plugin docker_cards used in the web-app-desktop role.
Overview
The unit tests are written using Python’s built-in unittest framework. They are designed to verify that your custom logic works as expected—such as extracting metadata from role files—without needing to run the entire playbook.
Running the Tests
You can run the tests using one of the following methods:
-
Using Unittest Discovery:
From the project's root directory, run:
python -m unittest discover -s tests/unitThis command will discover and execute all test files within the
tests/unitdirectory. -
Running a Specific Test File:
If you want to run only the Docker cards test, execute:
python tests/unit/test_docker_cards.py
How It Works
-
Setup:
The test script creates a temporary directory to simulate your roles folder. It then creates a sample role (web-app-desktop) with aREADME.mdfile (containing a header for the title) and ameta/main.ymlfile (with the required metadata). -
Execution:
Dummy variable values fordomainsandapplicationsare provided (these are the variables the lookup plugin expects). The lookup plugin is then run, which processes the sample role and returns the card information. -
Verification:
The test uses assertions to ensure that the output contains the expected title, description, icon information, constructed URL, and the correct iframe flag. -
Cleanup:
After the test completes, the temporary directory is removed, ensuring that no test artifacts remain.
Requirements
- Python 3.6 or newer is recommended.
- All necessary dependencies for your project should be installed.
These tests help ensure that your custom code is reliable and behaves as expected, and they can be easily integrated into a Continuous Integration (CI) pipeline.
Happy testing!