def test_parser(self): path = fixtures_dir.joinpath("books/books.json") books = self.parser.from_path(path, Books) self.assertIsInstance(books, Books) self.assertEqual( BookForm( author="Hightower, Kim", title="The First Book", genre="Fiction", price=44.95, pub_date=XmlDate.from_string("2000-10-01"), review="An amazing story of nothing.", id="bk001", ), books.book[0], ) self.assertEqual( BookForm( author="Nagata, Suanne", title="Becoming Somebody", genre="Biography", price=None, pub_date=None, review="A masterpiece of the fine art of gossiping.", id="bk002", ), books.book[1], )
def setUp(self): super().setUp() self.books = Books(book=[ BookForm( id="bk001", author="Hightower, Kim", title="The First Book", genre="Fiction", price=44.95, pub_date=XmlDate.from_string("2000-10-01"), review="An amazing story of nothing.", ), BookForm( id="bk002", author="Nagata, Suanne", title="Becoming Somebody", genre="Biography", review="A masterpiece of the fine art of gossiping.", ), ]) self.expected = { "book": [ { "author": "Hightower, Kim", "genre": "Fiction", "id": "bk001", "lang": "en", "price": 44.95, "pub_date": "2000-10-01", "review": "An amazing story of nothing.", "title": "The First Book", }, { "author": "Nagata, Suanne", "genre": "Biography", "id": "bk002", "lang": "en", "review": "A masterpiece of the fine art of gossiping.", "title": "Becoming Somebody", }, ] }