57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
"""Unit tests for config module constants."""
|
|
|
|
from gitea_runner_manager.config import (
|
|
BRANCH_PROTECTION_CONFIG,
|
|
CONVENTIONAL_RE,
|
|
DEFAULT_PER_PAGE,
|
|
DEFAULT_TIMEOUT,
|
|
GITEA_API_URL,
|
|
REPO_NAME,
|
|
REPO_OWNER,
|
|
TASK_ID_RE,
|
|
VIKUNJA_API_URL,
|
|
VIKUNJA_PROJECT_ID,
|
|
)
|
|
|
|
|
|
class TestConfigConstants:
|
|
def test_api_urls(self) -> None:
|
|
assert "api/v1" in GITEA_API_URL
|
|
assert "api/v1" in VIKUNJA_API_URL
|
|
|
|
def test_project_ids(self) -> None:
|
|
assert VIKUNJA_PROJECT_ID == 6
|
|
|
|
def test_timeouts(self) -> None:
|
|
assert DEFAULT_TIMEOUT == 30
|
|
assert DEFAULT_PER_PAGE == 50
|
|
|
|
def test_owner_and_repo(self) -> None:
|
|
assert REPO_OWNER == "oblachno-oss"
|
|
assert REPO_NAME == "grm"
|
|
|
|
def test_task_id_re(self) -> None:
|
|
assert TASK_ID_RE.search("GRM-1")
|
|
assert TASK_ID_RE.search("GRM-123")
|
|
assert not TASK_ID_RE.search("GRM-")
|
|
assert not TASK_ID_RE.search("other text")
|
|
|
|
def test_conventional_re(self) -> None:
|
|
assert CONVENTIONAL_RE.match("feat: add feature")
|
|
assert CONVENTIONAL_RE.match("fix(scope): bug fix")
|
|
assert not CONVENTIONAL_RE.match("random message")
|
|
assert not CONVENTIONAL_RE.match("feat:")
|
|
assert not CONVENTIONAL_RE.match("BREAKING CHANGE: something")
|
|
|
|
def test_branch_protection_config(self) -> None:
|
|
assert BRANCH_PROTECTION_CONFIG["branch_name"] == "master"
|
|
assert BRANCH_PROTECTION_CONFIG["enable_push"] is True
|
|
assert BRANCH_PROTECTION_CONFIG["enable_push_whitelist"] is True
|
|
assert "emil" in BRANCH_PROTECTION_CONFIG["push_whitelist_usernames"]
|
|
assert BRANCH_PROTECTION_CONFIG["required_approvals"] == 0
|
|
contexts = BRANCH_PROTECTION_CONFIG["status_check_contexts"]
|
|
assert isinstance(contexts, list)
|
|
assert len(contexts) == 4
|
|
assert "CI / quality (pull_request)" in contexts
|
|
assert any("molecule-tests" in c for c in contexts)
|