mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Huge role refactoring/cleanup. Other commits will propably follow. Because some bugs will exist. Still important for longrun and also for auto docs/help/slideshow generation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 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 `docker-portfolio` role.
|
||||
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-portfolio` role.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -31,7 +31,7 @@ You can run the tests using one of the following methods:
|
||||
## How It Works
|
||||
|
||||
- **Setup:**
|
||||
The test script creates a temporary directory to simulate your roles folder. It then creates a sample role (`docker-portfolio`) with a `README.md` file (containing a header for the title) and a `meta/main.yml` file (with the required metadata).
|
||||
The test script creates a temporary directory to simulate your roles folder. It then creates a sample role (`web-app-portfolio`) with a `README.md` file (containing a header for the title) and a `meta/main.yml` file (with the required metadata).
|
||||
|
||||
- **Execution:**
|
||||
Dummy variable values for `domains` and `applications` are 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.
|
||||
|
@@ -6,7 +6,7 @@ import tempfile
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
# Import functions to test; adjust path as needed
|
||||
from cli.create_docker_role import (
|
||||
from cli.create_web_app import (
|
||||
get_next_network,
|
||||
get_next_port,
|
||||
load_yaml_with_comments,
|
@@ -14,7 +14,7 @@ class TestGenerateDefaultApplicationsUsers(unittest.TestCase):
|
||||
self.roles_dir.mkdir()
|
||||
|
||||
# Sample role with users meta
|
||||
self.role = self.roles_dir / "docker-app-with-users"
|
||||
self.role = self.roles_dir / "web-app-app-with-users"
|
||||
(self.role / "vars").mkdir(parents=True)
|
||||
(self.role / "meta").mkdir(parents=True)
|
||||
|
||||
|
@@ -15,7 +15,7 @@ class TestGenerateDefaultApplications(unittest.TestCase):
|
||||
self.roles_dir.mkdir()
|
||||
|
||||
# Sample role
|
||||
self.sample_role = self.roles_dir / "docker-testapp"
|
||||
self.sample_role = self.roles_dir / "web-app-testapp"
|
||||
(self.sample_role / "vars").mkdir(parents=True)
|
||||
|
||||
# Write application_id and configuration
|
||||
|
@@ -5,7 +5,7 @@ import unittest
|
||||
sys.path.insert(
|
||||
0,
|
||||
os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), "../../../roles/docker-matrix/filter_plugins")
|
||||
os.path.join(os.path.dirname(__file__), "../../../roles/web-app-matrix/filter_plugins")
|
||||
),
|
||||
)
|
||||
|
||||
|
@@ -23,10 +23,10 @@ class TestApplicationGidLookup(unittest.TestCase):
|
||||
|
||||
# Define mock application_ids
|
||||
self.applications = {
|
||||
"nextcloud": "docker-nextcloud",
|
||||
"moodle": "docker-moodle",
|
||||
"wordpress": "docker-wordpress",
|
||||
"taiga": "docker-taiga"
|
||||
"nextcloud": "web-app-nextcloud",
|
||||
"moodle": "web-app-moodle",
|
||||
"wordpress": "web-app-wordpress",
|
||||
"taiga": "web-app-taiga"
|
||||
}
|
||||
|
||||
# Create fake role dirs and vars/main.yml
|
||||
|
@@ -4,8 +4,8 @@ import tempfile
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
# Adjust the PYTHONPATH to include the lookup_plugins folder from the docker-portfolio role.
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../../roles/docker-portfolio/lookup_plugins'))
|
||||
# Adjust the PYTHONPATH to include the lookup_plugins folder from the web-app-portfolio role.
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../../roles/web-app-portfolio/lookup_plugins'))
|
||||
|
||||
from docker_cards import LookupModule
|
||||
|
||||
@@ -13,8 +13,8 @@ class TestDockerCardsLookup(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# Create a temporary directory to simulate the roles directory.
|
||||
self.test_roles_dir = tempfile.mkdtemp(prefix="test_roles_")
|
||||
# Create a sample role "docker-portfolio".
|
||||
self.role_name = "docker-portfolio"
|
||||
# Create a sample role "web-app-portfolio".
|
||||
self.role_name = "web-app-portfolio"
|
||||
self.role_dir = os.path.join(self.test_roles_dir, self.role_name)
|
||||
os.makedirs(os.path.join(self.role_dir, "meta"))
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import sys
|
||||
def load_optimizer_module():
|
||||
module_path = os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'..', "..", "..","..",'roles', 'system-storage-optimizer', 'files', 'system-storage-optimizer.py'
|
||||
'..', "..", "..","..",'roles', 'maintenance-docker-storage-optimizer', 'files', 'maintenance-docker-storage-optimizer.py'
|
||||
))
|
||||
spec = importlib.util.spec_from_file_location('storage_optimizer', module_path)
|
||||
optimizer = importlib.util.module_from_spec(spec)
|
@@ -5,7 +5,7 @@ import importlib.util
|
||||
|
||||
# Dynamisch den Filter-Plugin Pfad hinzufügen
|
||||
current_dir = os.path.dirname(__file__)
|
||||
filter_plugin_path = os.path.abspath(os.path.join(current_dir, "../../../../roles/docker-ldap/filter_plugins"))
|
||||
filter_plugin_path = os.path.abspath(os.path.join(current_dir, "../../../../roles/service-openldap/filter_plugins"))
|
||||
|
||||
# Modul dynamisch laden
|
||||
spec = importlib.util.spec_from_file_location("build_ldap_role_entries", os.path.join(filter_plugin_path, "build_ldap_role_entries.py"))
|
Reference in New Issue
Block a user