Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Recipe route gate test: stub the recipe store with the real signature…
…s (red on main since #19610 added also_base)
  • Loading branch information
danielhanchen committed Nov 27, 2026
commit 7b952bf47604f80f524eb7018820cabf3d848bc2
22 changes: 20 additions & 2 deletions studio/backend/tests/test_managed_account_route_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

import asyncio
import inspect

import pytest
from fastapi import FastAPI, HTTPException
Expand Down Expand Up @@ -171,18 +172,35 @@ def test_a_path_the_owner_saved_still_replays_for_a_managed_account(monkeypatch)
}


def _shaped_like(real, fake):
"""A stub that takes whatever the real function takes, and nothing else: a call the real
signature would reject still fails here, and a parameter added to it does not break the stub."""
signature = inspect.signature(real)

def stub(*args, **kwargs):
signature.bind(*args, **kwargs)
return fake(*args, **kwargs)

return stub


@pytest.fixture
def recipe_store(monkeypatch):
from routes.data_recipe import library

saved = []
monkeypatch.setattr(
library.db, "upsert_recipe", lambda record, base: saved.append(record) or record
library.db,
"upsert_recipe",
_shaped_like(library.db.upsert_recipe, lambda record, *_: saved.append(record) or record),
)
monkeypatch.setattr(
library.db,
"import_legacy",
lambda recipes, executions: saved.extend(recipes) or {"recipes": len(recipes)},
_shaped_like(
library.db.import_legacy,
lambda recipes, *_: saved.extend(recipes) or {"recipes": len(recipes)},
),
)
return saved

Expand Down
Loading