mirror of https://github.com/gmbrax/Pilgrim.git
test(entry_service): add a failure case test for create method
This commit adds a unit test for an important "unhappy path" in the EntryService's `create` method. It specifically verifies that the method gracefully returns `None` when provided with a `travel_diary_id` that does not exist in the database, ensuring the initial guard clause works as expected.
This commit is contained in:
parent
c4dceda942
commit
3c7925cb1c
|
|
@ -52,4 +52,19 @@ def test_create_entry_successfully(populated_db_session):
|
|||
assert created_entry.photos[0].filepath == "/path/to/photo1.jpg"
|
||||
|
||||
entry_in_db = session.query(Entry).filter_by(id=created_entry.id).one()
|
||||
assert entry_in_db.title == "Primeiro Dia na Praia"
|
||||
assert entry_in_db.title == "Primeiro Dia na Praia"
|
||||
|
||||
def test_create_entry_fails_when_diary_id_is_invalid(db_session):
|
||||
session = db_session
|
||||
service = EntryService(session)
|
||||
invalid_id = 666
|
||||
|
||||
result = service.create(
|
||||
travel_diary_id=invalid_id,
|
||||
title="Título de Teste",
|
||||
text="Texto de Teste",
|
||||
date=datetime(2025, 7, 20),
|
||||
photos=[]
|
||||
)
|
||||
|
||||
assert result is None
|
||||
Loading…
Reference in New Issue