fix 8 tests failing in Gitea Actions CI environment
- cli tests: strip ANSI escape codes from Rich/typer help output before asserting keywords (Rich outputs ANSI in no-TTY mode) - conf/test_connect: skip DuckDB tests when data/aco.duckdb is absent (3GB file not present in CI checkout) - docs/test_docs_build: resolve paths relative to repo root (CI may run from a different working directory)
This commit is contained in:
@@ -2,12 +2,21 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from typer.testing import CliRunner
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
from cli import app
|
from cli import app
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
|
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")
|
||||||
|
|
||||||
|
|
||||||
|
def _plain(text: str) -> str:
|
||||||
|
"""Strip ANSI escape codes for assertion matching."""
|
||||||
|
return _ANSI_RE.sub("", text)
|
||||||
|
|
||||||
|
|
||||||
class TestTopLevel:
|
class TestTopLevel:
|
||||||
def test_help(self) -> None:
|
def test_help(self) -> None:
|
||||||
@@ -69,7 +78,7 @@ class TestBib:
|
|||||||
def test_bib_sync_help(self) -> None:
|
def test_bib_sync_help(self) -> None:
|
||||||
result = runner.invoke(app, ["bib", "sync", "--help"])
|
result = runner.invoke(app, ["bib", "sync", "--help"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert "dry-run" in result.output
|
assert "dry-run" in _plain(result.output)
|
||||||
|
|
||||||
def test_bib_tag(self) -> None:
|
def test_bib_tag(self) -> None:
|
||||||
result = runner.invoke(app, ["bib", "tag"])
|
result = runner.invoke(app, ["bib", "tag"])
|
||||||
@@ -86,19 +95,21 @@ class TestLake:
|
|||||||
def test_lake_deploy_help(self) -> None:
|
def test_lake_deploy_help(self) -> None:
|
||||||
result = runner.invoke(app, ["lake", "deploy", "--help"])
|
result = runner.invoke(app, ["lake", "deploy", "--help"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert "catalog-type" in result.output
|
out = _plain(result.output)
|
||||||
assert "dry-run" in result.output
|
assert "catalog-type" in out
|
||||||
|
assert "dry-run" in out
|
||||||
|
|
||||||
def test_lake_load_help(self) -> None:
|
def test_lake_load_help(self) -> None:
|
||||||
result = runner.invoke(app, ["lake", "load", "--help"])
|
result = runner.invoke(app, ["lake", "load", "--help"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert "catalog-type" in result.output
|
out = _plain(result.output)
|
||||||
assert "mode" in result.output
|
assert "catalog-type" in out
|
||||||
|
assert "mode" in out
|
||||||
|
|
||||||
def test_lake_validate_help(self) -> None:
|
def test_lake_validate_help(self) -> None:
|
||||||
result = runner.invoke(app, ["lake", "validate", "--help"])
|
result = runner.invoke(app, ["lake", "validate", "--help"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert "catalog-type" in result.output
|
assert "catalog-type" in _plain(result.output)
|
||||||
|
|
||||||
def test_lake_parity_help(self) -> None:
|
def test_lake_parity_help(self) -> None:
|
||||||
result = runner.invoke(app, ["lake", "parity", "--help"])
|
result = runner.invoke(app, ["lake", "parity", "--help"])
|
||||||
@@ -139,7 +150,7 @@ class TestDocs:
|
|||||||
def test_docs_build_help(self) -> None:
|
def test_docs_build_help(self) -> None:
|
||||||
result = runner.invoke(app, ["docs", "build", "--help"])
|
result = runner.invoke(app, ["docs", "build", "--help"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert "skip-generate" in result.output
|
assert "skip-generate" in _plain(result.output)
|
||||||
|
|
||||||
def test_docs_serve_help(self) -> None:
|
def test_docs_serve_help(self) -> None:
|
||||||
result = runner.invoke(app, ["docs", "serve", "--help"])
|
result = runner.invoke(app, ["docs", "serve", "--help"])
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ from unittest.mock import MagicMock, patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from conf import connect
|
from conf import connect, path
|
||||||
|
|
||||||
|
_HAS_ACO_DB = path("db.aco").exists()
|
||||||
|
|
||||||
|
|
||||||
class TestDuckdb:
|
class TestDuckdb:
|
||||||
|
@pytest.mark.skipif(not _HAS_ACO_DB, reason="data/aco.duckdb not present")
|
||||||
def test_returns_connection(self):
|
def test_returns_connection(self):
|
||||||
con = connect.duckdb()
|
con = connect.duckdb()
|
||||||
assert con is not None
|
assert con is not None
|
||||||
@@ -19,6 +22,7 @@ class TestDuckdb:
|
|||||||
assert result[0] == 1
|
assert result[0] == 1
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
@pytest.mark.skipif(not _HAS_ACO_DB, reason="data/aco.duckdb not present")
|
||||||
def test_read_only_default(self):
|
def test_read_only_default(self):
|
||||||
con = connect.duckdb()
|
con = connect.duckdb()
|
||||||
with pytest.raises(Exception, match="read-only"):
|
with pytest.raises(Exception, match="read-only"):
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
BIB_DB = Path("data/bib.sqlite")
|
_ROOT = Path(__file__).resolve().parents[2]
|
||||||
EXPORT_SCRIPT = Path("docs/scripts/export_library.py")
|
BIB_DB = _ROOT / "data/bib.sqlite"
|
||||||
LIBRARY_JSON = Path("docs/static/library.json")
|
EXPORT_SCRIPT = _ROOT / "docs/scripts/export_library.py"
|
||||||
DOCS_DIR = Path("docs/docs")
|
LIBRARY_JSON = _ROOT / "docs/static/library.json"
|
||||||
|
DOCS_DIR = _ROOT / "docs/docs"
|
||||||
INTRO_MD = DOCS_DIR / "intro.md"
|
INTRO_MD = DOCS_DIR / "intro.md"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user