Ejemplo n.º 1
0
    def test_dao_put_book_add(self):

        author = Author()
        author.name = "John Snow"

        book = Book()
        book.isbn10 = "0123456789"
        book.isbn13 = "0123456789123"
        book.title = "A title"
        book.nb_pages = 5
        book.language = "fr"
        book.year = 2015
        book.description = "The long description"
        book.authors.append(author)

        dao = BookDAO()
        dao.put(book)

        session = common.session()

        expected = [book]
        result = session.query(Book).all()
        self.assertEqual(result, expected)

        expected = [author]
        result = session.query(Author).all()
        self.assertEqual(result, expected)
Ejemplo n.º 2
0
    def test_dao_get_book(self):

        author = Author()
        author.name = "John Snow"

        book = Book()
        book.isbn10 = "0123456789"
        book.isbn13 = "0123456789123"
        book.title = "A title"
        book.nb_pages = 5
        book.language = "fr"
        book.year = 2015
        book.description = "The long description"
        book.authors.append(author)

        session = common.session()
        session.add(book)
        session.commit()

        dao = BookDAO()

        expected = book
        result = dao.get(book.isbn10)
        self.assertEqual(result, expected)