import pytest import aiohttp from run import ShoeiAPI, Interface, parse_isbn import os @pytest.mark.asyncio async def test_get_thumbnail(): shoei = ShoeiAPI() isbn = '9784320026926' _, temp_dir = Interface.get_tempdir() thumbnail = await shoei.get_thumbnail(isbn, temp_dir) assert thumbnail is not None, "Thumbnail should not be None" assert os.path.isfile(thumbnail), "Thumbnail file should exist" @pytest.mark.asyncio async def test_export_html(): shoei = ShoeiAPI() csv_input = """1,4092904517,9784092904510,,,読みたい,,,9/14/2022 17:46,9/14/2022 17:46,シルバーウィング (銀翼のコウモリ (1)),ケネス オッペル,小学館,2004,本,349 1,4636968913,9784636968914,,,読みたい,,,9/15/2022 3:40,,和音の正体 ~和音の成り立ち、仕組み、進化の歴史~,舟橋 三十子,ヤマハミュージックエンタテイメントホールディングス,2022,本,224""" book_data = await parse_isbn(csv_input) _, temp_dir = Interface.get_tempdir() html_content = await shoei.export_html(book_data, 'templates/table.html', temp_dir) assert '

Table of contents' in html_content, "HTML content should contain the header" assert '9784092904510' in html_content, "HTML content should contain the first ISBN" assert '9784636968914' in html_content, "HTML content should contain the second ISBN" @pytest.mark.asyncio async def test_parse_isbn(): csv_input = """1,4092904517,9784092904510,,,読みたい,,,9/14/2022 17:46,9/14/2022 17:46,シルバーウィング (銀翼のコウモリ (1)),ケネス オッペル,小学館,2004,本,349 1,4636968913,9784636968914,,,読みたい,,,9/15/2022 3:40,,和音の正体 ~和音の成り立ち、仕組み、進化の歴史~,舟橋 三十子,ヤマハミュージックエンタテイメントホールディングス,2022,本,224""" book_data = await parse_isbn(csv_input) assert len(book_data) == 2, "Should return two book records" assert book_data[0]['isbn'] == '4092904517', "First ISBN should be converted to ISBN-10" assert book_data[1]['isbn'] == '4636968913', "Second ISBN should be converted to ISBN-10"