Skip to content

Commit

Permalink
test: ✅ add sqlmodel test and clean import
Browse files Browse the repository at this point in the history
  • Loading branch information
dubusster committed Apr 11, 2024
1 parent 5751f1b commit b7a4a1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/sqlalchemy/crud/test_upsert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from sqlalchemy import select

from fastcrud.crud.fast_crud import FastCRUD


Expand Down
16 changes: 16 additions & 0 deletions tests/sqlmodel/crud/test_upsert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest

from fastcrud.crud.fast_crud import FastCRUD


@pytest.mark.asyncio
async def test_upsert_successful(async_session, test_model, read_schema):
crud = FastCRUD(test_model)
new_data = read_schema(id=1, name="New Record", tier_id=1, category_id=1)
fetched_record = await crud.upsert(async_session, new_data, return_as_model=True)
assert read_schema.model_validate(fetched_record) == new_data

fetched_record.name == "New name"

updated_fetched_record = await crud.upsert(async_session, fetched_record)
assert read_schema.model_validate(updated_fetched_record) == fetched_record

0 comments on commit b7a4a1a

Please sign in to comment.