test: domain expectations match corrected defaults

This commit is contained in:
emil
2026-10-20 15:03:53 +02:00
parent 694daac64c
commit c53d9e2f5d
2 changed files with 13 additions and 13 deletions
+10 -10
View File
@@ -86,7 +86,7 @@ class TestPushToBadgesBranch:
class TestUpdateBadgeUrls: class TestUpdateBadgeUrls:
def test_replaces_branch_url(self) -> None: def test_replaces_branch_url(self) -> None:
content = "[![Tests](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]" content = "[![Tests](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]"
result = push_badges.update_badge_urls(content, "abc123def456") result = push_badges.update_badge_urls(content, "abc123def456")
assert "raw/commit/abc123def456/tests.svg" in result assert "raw/commit/abc123def456/tests.svg" in result
assert "raw/branch/badges" not in result assert "raw/branch/badges" not in result
@@ -95,7 +95,7 @@ class TestUpdateBadgeUrls:
"""Old commit SHA URLs should be replaced with the new one.""" """Old commit SHA URLs should be replaced with the new one."""
old_sha = "aabb123456789012345678901234567890123456" # 40 hex chars old_sha = "aabb123456789012345678901234567890123456" # 40 hex chars
new_sha = "ccdd123456789012345678901234567890123456" # 40 hex chars new_sha = "ccdd123456789012345678901234567890123456" # 40 hex chars
content = f"[![Tests](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/commit/{old_sha}/tests.svg)]" content = f"[![Tests](https://git.oblachno.fyi/my-org/my-repo/raw/commit/{old_sha}/tests.svg)]"
result = push_badges.update_badge_urls(content, new_sha) result = push_badges.update_badge_urls(content, new_sha)
assert f"raw/commit/{new_sha}/tests.svg" in result assert f"raw/commit/{new_sha}/tests.svg" in result
assert old_sha not in result assert old_sha not in result
@@ -107,16 +107,16 @@ class TestUpdateBadgeUrls:
def test_multiple_badges(self) -> None: def test_multiple_badges(self) -> None:
content = ( content = (
"[![Coverage](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/coverage.svg)]\n" "[![Coverage](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/coverage.svg)]\n"
"[![Tests](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]\n" "[![Tests](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]\n"
"[![Version](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/version.svg)]" "[![Version](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/version.svg)]"
) )
result = push_badges.update_badge_urls(content, "abc123def456") result = push_badges.update_badge_urls(content, "abc123def456")
assert result.count("raw/commit/abc123def456/") == 3 assert result.count("raw/commit/abc123def456/") == 3
assert "raw/branch/badges" not in result assert "raw/branch/badges" not in result
def test_preserves_non_badge_urls(self) -> None: def test_preserves_non_badge_urls(self) -> None:
content = "[![CI](https://git.oblachno.oblachno.fyi/my-org/my-repo/actions/workflows/ci.yml/badge.svg)]" content = "[![CI](https://git.oblachno.fyi/my-org/my-repo/actions/workflows/ci.yml/badge.svg)]"
result = push_badges.update_badge_urls(content, "abc123") result = push_badges.update_badge_urls(content, "abc123")
assert result == content assert result == content
@@ -124,7 +124,7 @@ class TestUpdateBadgeUrls:
class TestUpdateReadmeWithBadgeSha: class TestUpdateReadmeWithBadgeSha:
def test_updates_readme(self, tmp_path: Path) -> None: def test_updates_readme(self, tmp_path: Path) -> None:
readme = tmp_path / "README.md" readme = tmp_path / "README.md"
readme.write_text("[![Tests](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]") readme.write_text("[![Tests](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]")
with patch("subprocess.run"): with patch("subprocess.run"):
push_badges.update_readme_with_badge_sha("abc123def456", repo_root=tmp_path) push_badges.update_readme_with_badge_sha("abc123def456", repo_root=tmp_path)
content = readme.read_text() content = readme.read_text()
@@ -147,7 +147,7 @@ class TestUpdateReadmeWithBadgeSha:
def test_version_verification_stale(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: def test_version_verification_stale(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
readme = tmp_path / "README.md" readme = tmp_path / "README.md"
readme.write_text("[![Tests](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]") readme.write_text("[![Tests](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]")
monkeypatch.chdir(tmp_path) monkeypatch.chdir(tmp_path)
badges_dir = tmp_path / ".badges" badges_dir = tmp_path / ".badges"
badges_dir.mkdir(exist_ok=True) badges_dir.mkdir(exist_ok=True)
@@ -159,7 +159,7 @@ class TestUpdateReadmeWithBadgeSha:
def test_version_verification_current(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: def test_version_verification_current(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
readme = tmp_path / "README.md" readme = tmp_path / "README.md"
readme.write_text("[![Tests](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]") readme.write_text("[![Tests](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]")
monkeypatch.chdir(tmp_path) monkeypatch.chdir(tmp_path)
badges_dir = tmp_path / ".badges" badges_dir = tmp_path / ".badges"
badges_dir.mkdir(exist_ok=True) badges_dir.mkdir(exist_ok=True)
@@ -171,7 +171,7 @@ class TestUpdateReadmeWithBadgeSha:
def test_version_verification_no_badges_dir(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: def test_version_verification_no_badges_dir(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
readme = tmp_path / "README.md" readme = tmp_path / "README.md"
readme.write_text("[![Tests](https://git.oblachno.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]") readme.write_text("[![Tests](https://git.oblachno.fyi/my-org/my-repo/raw/branch/badges/tests.svg)]")
monkeypatch.chdir(tmp_path) monkeypatch.chdir(tmp_path)
# No .badges/version.svg exists — should skip verification gracefully # No .badges/version.svg exists — should skip verification gracefully
with patch("subprocess.run"): with patch("subprocess.run"):
+3 -3
View File
@@ -19,12 +19,12 @@ from devx.tools.setup_image import (
class TestBuildPipExtraIndexUrl: class TestBuildPipExtraIndexUrl:
def test_basic_url(self) -> None: def test_basic_url(self) -> None:
url = _build_pip_extra_index_url( url = _build_pip_extra_index_url(
"git.oblachno.oblachno.fyi", "git.oblachno.fyi",
"oblachno-oss", "oblachno-oss",
"emil", "emil",
"tok123", "tok123",
) )
assert url == "https://emil:tok123@git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/" assert url == "https://emil:tok123@git.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/"
def test_custom_host_org(self) -> None: def test_custom_host_org(self) -> None:
url = _build_pip_extra_index_url( url = _build_pip_extra_index_url(
@@ -233,7 +233,7 @@ class TestCli:
assert call_args[0] == ".venv" assert call_args[0] == ".venv"
assert call_args[1] == "/opt/venv" assert call_args[1] == "/opt/venv"
assert call_args[2] == "" # no extras assert call_args[2] == "" # no extras
assert call_args[3] == "git.oblachno.oblachno.fyi" assert call_args[3] == "git.oblachno.fyi"
assert call_args[4] == "oblachno-oss" assert call_args[4] == "oblachno-oss"
@patch("devx.tools.setup_image._fallback_to_setup_ci") @patch("devx.tools.setup_image._fallback_to_setup_ci")