52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
"""
|
|
This module cantains tests for the comic data model
|
|
"""
|
|
import unittest
|
|
from . import TestBase
|
|
from kontor.comics.models import Artist, Comic, Publisher
|
|
|
|
|
|
class TestComicsModel(TestBase):
|
|
"""This TestCase contains tests for comic data model."""
|
|
|
|
def setUp(self):
|
|
publisher = Publisher()
|
|
publisher.name = "Publisher1"
|
|
publisher.save()
|
|
artist = Artist()
|
|
artist.name = "Artist1"
|
|
artist.save()
|
|
comic = Comic()
|
|
comic.title = "Title1"
|
|
comic.save()
|
|
|
|
def tearDown(self):
|
|
for comic in Comic.objects.all():
|
|
comic.delete()
|
|
for artist in Artist.objects.all():
|
|
artist.delete()
|
|
for publisher in Publisher.objects.all():
|
|
publisher.delete()
|
|
|
|
def test_comic_model(self):
|
|
comic_list = Comic.objects.all()
|
|
self.assertEqual(comic_list.count(), 1)
|
|
|
|
def test_publisher_model(self):
|
|
self.assertEqual(Publisher.objects.all().count(), 1)
|
|
|
|
def test_artist_model(self):
|
|
self.assertEqual(Artist.objects.all().count(), 1)
|
|
|
|
def test_assign_publisher(self):
|
|
comic = Comic.objects.first()
|
|
publisher = Publisher.objects.first()
|
|
comic.publisher = publisher
|
|
comic.save()
|
|
self.assertEqual(publisher.name, comic.publisher.name)
|
|
self.assertEqual(publisher.comics.count(), 1)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|