1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
import pytest
from django.test import TestCase
from ddf import *
class SampleAppTestCase(TestCase):
def test_publisher(self):
o = G('django_dynamic_fixture.Publisher')
assert o.name is not None
def test_author(self):
o = G('django_dynamic_fixture.Author')
assert o.name is not None
assert o.description is None
o = G('django_dynamic_fixture.Author', fill_nullable_fields=True)
assert o.description is not None
def test_category(self):
o = G('django_dynamic_fixture.Category')
assert o.name is not None
assert o.parent is None
o = G('django_dynamic_fixture.Category', fk_min_depth=1)
assert o.parent is not None
assert o.parent.parent is None
o = G('django_dynamic_fixture.Category', fk_min_depth=2)
assert o.parent.parent is not None
assert o.parent.parent.parent is None
def test_book(self):
o = G('django_dynamic_fixture.Book')
assert o.main_author is not None
assert o.main_author.name is not None
assert o.authors.all().count() == 0
assert o.categories.all().count() == 0
o = G('django_dynamic_fixture.Book', authors=2, categories=5)
assert o.authors.all().count() == 2
assert o.categories.all().count() == 5
o = G('django_dynamic_fixture.Book', metadata={'a': 1})
assert o.metadata == {'a': 1}
def test_book_edition(self):
o = G('django_dynamic_fixture.BookEdition')
assert o.book is not None
assert o.year is not None
assert o.publishers.all().count() == 0
o = G('django_dynamic_fixture.BookEdition', publishers=2)
assert o.publishers.all().count() == 2
def test_book_publisher(self):
o = G('django_dynamic_fixture.BookPublisher')
assert o.book_edition.book is not None
assert o.publisher is not None
assert o.comments is not None
|