fix: env leak from live tests caused test_failed_mutation_returns_404 to fail
The live test modules set DECNET_CONTRACT_TEST=true at module level, which persisted across xdist workers and caused the mutate endpoint to short-circuit before the mock was reached. Clear the env var in affected tests with monkeypatch.delenv.
This commit is contained in:
@@ -14,7 +14,8 @@ class TestMutateDecky:
|
|||||||
assert resp.status_code == 401
|
assert resp.status_code == 401
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_successful_mutation(self, client: httpx.AsyncClient, auth_token: str):
|
async def test_successful_mutation(self, client: httpx.AsyncClient, auth_token: str, monkeypatch: pytest.MonkeyPatch):
|
||||||
|
monkeypatch.delenv("DECNET_CONTRACT_TEST", raising=False)
|
||||||
with patch("decnet.web.router.fleet.api_mutate_decky.mutate_decky", return_value=True):
|
with patch("decnet.web.router.fleet.api_mutate_decky.mutate_decky", return_value=True):
|
||||||
resp = await client.post(
|
resp = await client.post(
|
||||||
"/api/v1/deckies/decky-01/mutate",
|
"/api/v1/deckies/decky-01/mutate",
|
||||||
@@ -24,7 +25,8 @@ class TestMutateDecky:
|
|||||||
assert "Successfully mutated" in resp.json()["message"]
|
assert "Successfully mutated" in resp.json()["message"]
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_failed_mutation_returns_404(self, client: httpx.AsyncClient, auth_token: str):
|
async def test_failed_mutation_returns_404(self, client: httpx.AsyncClient, auth_token: str, monkeypatch: pytest.MonkeyPatch):
|
||||||
|
monkeypatch.delenv("DECNET_CONTRACT_TEST", raising=False)
|
||||||
with patch("decnet.web.router.fleet.api_mutate_decky.mutate_decky", return_value=False):
|
with patch("decnet.web.router.fleet.api_mutate_decky.mutate_decky", return_value=False):
|
||||||
resp = await client.post(
|
resp = await client.post(
|
||||||
"/api/v1/deckies/decky-01/mutate",
|
"/api/v1/deckies/decky-01/mutate",
|
||||||
|
|||||||
Reference in New Issue
Block a user