def testGenerateJSON(self): self.saveBookDataToDB() book = database.get_book_by_doi("doi.10.11647/OBP.0002") j = book.make_json() decoded = json.loads(j) self.assertEqual(decoded["Product"]["NumberOfPages"], 344) self.assertEqual(decoded["Product"]["ProductIdentifier"]["IDValue"], "9781906924034")
def testReadFromDB(self): params = { "title": "The End of the World", "subtitle": "Apocalypse and its Aftermath in Western Culture", "publisher": "OBP", "book_uuid": str(uuid.uuid4()), "isbn1": "9781906924508", "page_count": 219, "bisac_subject_code_1": "LIT004260", "doi": "doi.10.11647/OBP.0015" } def book_stream(): yield params database._dump_to_db(book_stream) book = database.get_book_by_doi("doi.10.11647/OBP.0015") self.assertEqual(book.isbn, "9781906924508")
def json_doi(doi): book = database.get_book_by_doi(doi) return book.make_clean_dict()
def onix_doi(doi): book = database.get_book_by_doi(doi) return book.make_xml()
def testTitleInDB(self): self.saveBookDataToDB() book = database.get_book_by_doi("doi.10.11647/OBP.0002") self.assertEqual(book.isbn, "9781906924034")
def testIngestDir(self): fake_data_dir = os.path.join(TEST_DIR, "fake-data") ingest.ingest_dir(fake_data_dir) book = database.get_book_by_doi("doi.10.11647/OBP.0002") title = book.to_dict()["ONIXMessage"]["Product"]["Title"]["TitleText"] self.assertEqual(title, "The Alerting Eye")