Skip to content

Commit

Permalink
Test for deleted methods
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbenav committed Jan 28, 2024
1 parent b73d845 commit cce3d87
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/endpoint/test_deleted_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest
from fastapi.testclient import TestClient
from fastcrud import FastCRUD, crud_router

from ..conftest import get_session_local


@pytest.mark.asyncio
async def test_deleted_methods(
client: TestClient, async_session, test_model, create_schema, update_schema
):
custom_router = crud_router(
session=get_session_local,
model=test_model,
crud=FastCRUD(test_model),
create_schema=create_schema,
update_schema=update_schema,
deleted_methods=["delete"],
path="/test_custom",
tags=["Test"],
)

client.app.include_router(custom_router)

response = client.post(
"/test_custom/create", json={"name": "Test Item", "tier_id": 1}
)
assert response.status_code == 200

item_id = response.json()["id"]
response = client.delete(f"/test_custom/delete/{item_id}")
assert response.status_code == 404

0 comments on commit cce3d87

Please sign in to comment.