Skip to content

Commit e8f4ac6

Browse files
author
Dagger Agent
committed
Fixes PR #134
1 parent 973926a commit e8f4ac6

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class BookIn(BaseModel):
2626

2727
title: str
2828
author: str
29+
publisher: str
2930

3031

3132
class BookOut(BaseModel):

repositories.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Create a new book
66
def create_book(db: Session, book: models.BookIn):
7-
db_book = models.Book(title=book.title, author=book.author)
7+
db_book = models.Book(title=book.title, author=book.author, publisher=book.publisher)
88
db.add(db_book)
99
db.commit()
1010
db.refresh(db_book)
@@ -27,6 +27,7 @@ def update_book(db: Session, book_id: int, book: models.BookIn):
2727
if db_book:
2828
db_book.title = book.title
2929
db_book.author = book.author
30+
db_book.publisher = book.publisher
3031
db.commit()
3132
db.refresh(db_book)
3233
return db_book

test_main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
# Test data constants
77
TEST_BOOKS = [
8-
{"title": "Carrie", "author": "Stephen King"},
9-
{"title": "Ready Player One", "author": "Ernest Cline"},
8+
{"title": "Carrie", "author": "Stephen King", "publisher": "Publisher A"},
9+
{"title": "Ready Player One", "author": "Ernest Cline", "publisher": "Publisher B"},
1010
]
1111

1212
class TestMainApp:
@@ -57,7 +57,7 @@ def test_update_book(self, test_db):
5757

5858
def test_delete_book(self, test_db):
5959
"""Test deleting a book"""
60-
book = create_book(test_db, BookIn(title="To Delete", author="Author"))
60+
book = create_book(test_db, BookIn(title="To Delete", author="Author", publisher="Publisher C"))
6161
deleted_book = delete_book(test_db, book.id)
6262

6363
assert deleted_book is not None
@@ -67,5 +67,6 @@ def test_delete_book(self, test_db):
6767
def test_nonexistent_operations(self, test_db):
6868
"""Test operations on nonexistent books"""
6969
assert get_book(test_db, 999999) is None
70-
assert update_book(test_db, 999999, BookIn(title="Test", author="Test")) is None
70+
assert update_book(test_db, 999999, BookIn(title="Test", author="Test", publisher="Publisher D")) is None
7171
assert delete_book(test_db, 999999) is None
72+

0 commit comments

Comments
 (0)