import from kontor-flask

This commit is contained in:
Thomas Peetz
2025-01-08 22:31:20 +01:00
parent fc4110b11d
commit 6923b3e5ee
61 changed files with 4296 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
"""
This module cantains tests for the comic data model
"""
import unittest
from . import TestBase
from kontor.library.models import Author, Publisher, Book
class TestComicsModel(TestBase):
"""This TestCase contains tests for comic data model."""
def setUp(self):
publisher = Publisher()
publisher.name = "Publisher1"
publisher.save()
author = Author()
author.name = "Autor1"
author.save()
book = Book()
book.title = "Title1"
book.save()
def tearDown(self):
for book in Book.objects.all():
book.delete()
for author in Author.objects.all():
author.delete()
for publisher in Publisher.objects.all():
publisher.delete()
def test_comic_model(self):
book_list = Book.objects.all()
self.assertEqual(book_list.count(), 1)
def test_publisher_model(self):
self.assertEqual(Publisher.objects.all().count(), 1)
def test_artist_model(self):
self.assertEqual(Author.objects.all().count(), 1)
def test_assign_publisher(self):
book = Book.objects.first()
publisher = Publisher.objects.first()
book.publisher = publisher
book.save()
self.assertEqual(publisher.name, book.publisher.name)
if __name__ == '__main__':
unittest.main()