Skip to content

Commit 0b88123

Browse files
committed
Test document CRUD delete
1 parent d3e0c40 commit 0b88123

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pytest
2+
from sqlmodel import Session, select
3+
4+
from app.crud import DocumentCrud
5+
from app.models import Document
6+
7+
from _utils import (
8+
insert_document,
9+
rm_documents,
10+
)
11+
12+
@pytest.fixture
13+
def document(db: Session):
14+
rm_documents(db)
15+
document = insert_document(db)
16+
17+
crud = DocumentCrud(db)
18+
crud.delete(document.id, document.owner_id)
19+
20+
statement = (
21+
select(Document)
22+
.where(Document.id == document.id)
23+
)
24+
return db.exec(statement).one()
25+
26+
class TestDatabaseUpdate:
27+
def test_delete_is_soft(self, document: Document):
28+
assert document is not None
29+
30+
def test_delete_marks_deleted(self, document: Document):
31+
assert document.deleted_at is not None
32+
33+
def test_delete_follows_insert(self, document: Document):
34+
assert document.created_at <= document.deleted_at

0 commit comments

Comments
 (0)