Skip to content
Open
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
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ exclude_paths:
- "roles/install_module/vars/"
# Exclude copied playbook - uses nsls2.general collection
- "scripts/deploy_ioc.yml"
- "collections/ansible_collections/"
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---

exclude: |
^collections/ansible_collections/

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
log_format = "%(asctime)s,%(msecs)03d %(levelname)s (%(threadName)s) %(message)s"
log_date_format = "%H:%M:%S"
addopts = "-v"
testpaths = tests
2 changes: 2 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
exclude = ["collections/ansible_collections"]
line-length = 88
indent-width = 4
lint.select = [
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
Expand Down
23 changes: 15 additions & 8 deletions tests/test_device_roles.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import os
from pathlib import Path

import pytest

DEVICE_ROLES = [
role
for role in os.listdir("roles/device_roles")
if os.path.isdir(os.path.join("roles/device_roles", role))
]
DEVICE_ROLES_PATH = Path("roles/device_roles")

DEVICE_ROLES = [role.stem for role in DEVICE_ROLES_PATH.iterdir() if role.is_dir()]


@pytest.mark.parametrize("device_role", DEVICE_ROLES)
def test_ensure_var_file_for_device_role_exists(device_role):
var_file_path = os.path.join("roles", "deploy_ioc", "vars", f"{device_role}.yml")
assert os.path.exists(var_file_path), f"Vars file {var_file_path} not found"
var_file_path = Path("roles/deploy_ioc/vars") / f"{device_role}.yml"
assert var_file_path.exists(), f"Vars file {var_file_path} not found"


@pytest.mark.parametrize("device_role", DEVICE_ROLES)
def test_every_device_role_has_a_readme(device_role):
device_role_path = DEVICE_ROLES_PATH / device_role
readme_path = device_role_path / "README.md"
assert readme_path.exists(), (
f"README.md not found for device role: {device_role}"
)
Loading