Exemplo n.º 1
0
class CategoryTest(TestCase):
    def setUp(self):
        self.category = Category(description='Comedy')
        self.category.save()

    def test_create(self):
        'Category instance may be saved.'
        self.assertEqual(1, self.category.pk)

    def test_str(self):
        'Category string representation may be the name.'
        self.assertEqual('Comedy', str(self.category))
Exemplo n.º 2
0
class BookTest(TestCase):
    def setUp(self):
        self.author = Author(name='John Doe')
        self.author.save()

        self.category = Category(description='Comedy', )
        self.category.save()

        self.book = Book(title='Any book',
                         author=self.author,
                         category=self.category,
                         pages=900,
                         description='',
                         published_in=datetime.today())
        self.book.save()

    def test_create(self):
        'Book instance may be saved'
        self.assertEqual(1, self.book.pk)

    def test_str(self):
        'Book string representation may be the name.'
        self.assertEqual('Any book', str(self.book))