"""The per-run test repository (e2e_support.fresh_repo): what the operator provides for a project (D4, D8), made and deleted by the test operator.""" import uuid from pathlib import Path import pytest from e2e_support import fresh_repo, operator_gitea from nisse_dev.config import AgentConfig from nisse_dev.gitea import GiteaClient, GiteaError pytestmark = pytest.mark.integration def test_a_fresh_repository_is_seeded_shared_and_protected( tmp_path: Path, live_config: AgentConfig, gitea: GiteaClient ) -> None: operator = operator_gitea(live_config.gitea_url) run = uuid.uuid4().hex[:8] with fresh_repo(operator, run, tmp_path / "keys", agent=gitea.whoami()) as repo: # Seeded: the package and its tests, and the README replaced. text = gitea._request("GET", f"/repos/{repo.name}/contents/sandbox/text.py") assert text["name"] == "text.py" assert gitea._request("GET", f"/repos/{repo.name}/contents/tests") # The agent sees it as a collaborator that may push, and main as # protected against it (what D4's verification reads). main = gitea._request("GET", f"/repos/{repo.name}/branches/main") assert main["protected"] and not main["user_can_push"] assert gitea._request("GET", f"/repos/{repo.name}")["permissions"]["push"] assert repo.push_key.exists() with pytest.raises(GiteaError, match="404"): gitea._request("GET", f"/repos/{repo.name}")