example-of-crud-in-django-w.../tests/library/test_model.py
Andros Fenollosa aeb5199bdc Add fake data
2021-07-14 16:46:34 +02:00

29 lines
553 B
Python

# tests/Library/test_model.py
import pytest
from app.library.models import Book
@pytest.mark.django_db
def test_book_model():
## Given
book = Book(
title="The foundation",
country="eeuu",
year="1951",
author="Isaac Asimov",
)
book.save()
## When
## Then
assert book.title == "The foundation"
assert book.country == "eeuu"
assert book.year == "1951"
assert book.author == "Isaac Asimov"
assert book.created_at
assert book.updated_at
assert str(book) == book.title