generated from coulomb/repo-seed
Some checks failed
ci / validate-registry (push) Has been cancelled
Implement Integration Definition validator CLI with schema and index checks, pytest suite, and CI workflow. Register open-cmis-tck and issue-core-gitea in the integration index. Closes OPEN-WP-0003 and OPEN-WP-0004.
120 lines
3.3 KiB
Python
120 lines
3.3 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from open_reuse.registry import PACKAGE_ROOT, resolve_repo_root
|
|
from open_reuse.validate import run_validate, validate_definition
|
|
from open_reuse.registry import load_schema
|
|
|
|
FIXTURES = Path(__file__).parent / "fixtures"
|
|
REPO_ROOT = resolve_repo_root()
|
|
SCHEMA = load_schema(REPO_ROOT)
|
|
MARKITECT_QUARKDOWN = Path("/home/worsch/markitect-quarkdown/integration/quarkdown.integration.yaml")
|
|
|
|
|
|
def test_valid_fixture_passes_schema() -> None:
|
|
errors, warnings = validate_definition(FIXTURES / "valid.integration.yaml", SCHEMA)
|
|
assert errors == []
|
|
assert warnings == []
|
|
|
|
|
|
def test_invalid_fixture_fails_schema() -> None:
|
|
errors, warnings = validate_definition(FIXTURES / "invalid.integration.yaml", SCHEMA)
|
|
assert errors
|
|
assert any("schema error" in item for item in errors)
|
|
|
|
|
|
@pytest.mark.skipif(not MARKITECT_QUARKDOWN.is_file(), reason="markitect-quarkdown not present")
|
|
def test_markitect_quarkdown_reference_passes_schema() -> None:
|
|
errors, warnings = validate_definition(MARKITECT_QUARKDOWN, SCHEMA)
|
|
assert errors == []
|
|
|
|
|
|
def test_validate_command_success_on_fixture() -> None:
|
|
code = run_validate(
|
|
root=REPO_ROOT,
|
|
targets=[FIXTURES / "valid.integration.yaml"],
|
|
repos_base=None,
|
|
fail_on_warnings=False,
|
|
check_index=False,
|
|
indexed_only=False,
|
|
)
|
|
assert code == 0
|
|
|
|
|
|
def test_validate_command_fails_on_invalid_fixture() -> None:
|
|
code = run_validate(
|
|
root=REPO_ROOT,
|
|
targets=[FIXTURES / "invalid.integration.yaml"],
|
|
repos_base=None,
|
|
fail_on_warnings=False,
|
|
check_index=False,
|
|
indexed_only=False,
|
|
)
|
|
assert code == 1
|
|
|
|
|
|
def test_index_requires_fields() -> None:
|
|
code = run_validate(
|
|
root=REPO_ROOT,
|
|
targets=[],
|
|
repos_base=None,
|
|
fail_on_warnings=False,
|
|
check_index=True,
|
|
indexed_only=True,
|
|
)
|
|
assert code == 0
|
|
|
|
|
|
@pytest.mark.skipif(not MARKITECT_QUARKDOWN.is_file(), reason="markitect-quarkdown not present")
|
|
def test_index_consistency_with_repos_base() -> None:
|
|
code = run_validate(
|
|
root=REPO_ROOT,
|
|
targets=[],
|
|
repos_base=Path("/home/worsch"),
|
|
fail_on_warnings=False,
|
|
check_index=True,
|
|
indexed_only=True,
|
|
)
|
|
assert code == 0
|
|
|
|
|
|
def test_active_without_maintainers_warns_with_fail_on_warnings() -> None:
|
|
active_fixture = FIXTURES / "active-missing-maintainers.integration.yaml"
|
|
active_fixture.write_text(
|
|
"""
|
|
schema_version: open-reuse.integration.v0.1
|
|
id: active-missing-maintainers
|
|
name: Active Missing Maintainers
|
|
status: active
|
|
owner: open-reuse
|
|
upstream:
|
|
name: Example Upstream
|
|
reuse:
|
|
primary_reuse_mode: adapter
|
|
boundary:
|
|
type: adapter
|
|
local_adapter: fixture.adapter.Adapter
|
|
validation:
|
|
harness: python3 -m pytest
|
|
maintenance:
|
|
escalation_conditions:
|
|
- validation failure
|
|
""".strip()
|
|
+ "\n",
|
|
encoding="utf-8",
|
|
)
|
|
try:
|
|
code = run_validate(
|
|
root=REPO_ROOT,
|
|
targets=[active_fixture],
|
|
repos_base=None,
|
|
fail_on_warnings=True,
|
|
check_index=False,
|
|
indexed_only=False,
|
|
)
|
|
assert code == 1
|
|
finally:
|
|
active_fixture.unlink(missing_ok=True) |