Read patched recipes by stable id
Co-authored-by: Bumble <bumble@agents.famfallman.com> Co-authored-by: fredamn76 <fredrik.fallman@gmail.com> Signed-off-by: fredamn76 <fredrik.fallman@gmail.com>
This commit is contained in:
@@ -62,14 +62,24 @@ class TestUrlImportResponse:
|
||||
class TestPatchContract:
|
||||
def test_patch_recipe_reads_back_the_final_object(self, monkeypatch):
|
||||
seen = []
|
||||
updated = {"slug": "soppa", "name": "Soppa", "tags": [{"name": "📅 Vardag"}]}
|
||||
before = {"id": "stable-id", "slug": "soppa", "name": "Soppa"}
|
||||
updated = {
|
||||
"id": "stable-id",
|
||||
"slug": "ny-soppa",
|
||||
"name": "Ny soppa",
|
||||
"tags": [{"name": "📅 Vardag"}],
|
||||
}
|
||||
|
||||
def request(method, path, **kwargs):
|
||||
seen.append((method, path, kwargs))
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(server, "_request", request)
|
||||
monkeypatch.setattr(server, "get_recipe", lambda slug: updated if slug == "soppa" else None)
|
||||
monkeypatch.setattr(
|
||||
server,
|
||||
"get_recipe",
|
||||
lambda key: before if key == "soppa" else updated if key == "stable-id" else None,
|
||||
)
|
||||
|
||||
assert server.patch_recipe("soppa", {"tags": updated["tags"]}) == updated
|
||||
assert seen == [("PATCH", "/api/recipes/soppa", {"json": {"tags": updated["tags"]}})]
|
||||
|
||||
Reference in New Issue
Block a user