def test_book_is_rental2() -> None: bc = BookClassifier(sleep=3) book_info = pd.Series({'13桁ISBN': 333333}) rental_df = pd.DataFrame({'ISBN': [111111, 222222]}) result = bc.book_is_rental_or_reserving(book_info=book_info, nowreading_df=rental_df) assert (not result)
def test_evaluate_book_status2() -> None: bc = BookClassifier(sleep=3) book_info = pd.Series({'13桁ISBN': 111111}) rental_df = pd.DataFrame({'ISBN': [111111, 222222]}) status = bc.evaluate_book_status(book_info=book_info, nowreading_df=rental_df) assert (status == 'rental_or_reserving' or status == 'not_found')
def test_evaluate_book_status4() -> None: bc = BookClassifier(sleep=3) book_info = pd.Series({'13桁ISBN': 9784000052092}) rental_df = pd.DataFrame({'ISBN': [111111, 222222]}) status = bc.evaluate_book_status(book_info=book_info, nowreading_df=rental_df) assert (status == 'has_reservation' or status == 'no_reservation' or status == 'not_found')
def test_evaluate_book_status6() -> None: bc = BookClassifier(sleep=3) status_list = [] status_list.append( bc.evaluate_book_status(book_info=pd.Series({'13桁ISBN': 9784636910650}), nowreading_df=None)) status_list.append( bc.evaluate_book_status(book_info=pd.Series({'13桁ISBN': 9784167801151}), nowreading_df=None)) status_list.append( bc.evaluate_book_status(book_info=pd.Series({'13桁ISBN': 9784041018880}), nowreading_df=None)) status_list.append( bc.evaluate_book_status(book_info=pd.Series({'13桁ISBN': 9784022559296}), nowreading_df=None)) status_list.append( bc.evaluate_book_status(book_info=pd.Series({'13桁ISBN': 9784532319823}), nowreading_df=None)) found_cnt = 0 for status in status_list: if (status != 'not_found'): found_cnt += 1 found_prob = float(found_cnt) / float(len(status_list)) assert (found_prob > 0.5)
def main(options=options): logging.debug("classify_list_ichikawa.py start") bc = BookClassifier(sleep=1) # read booklog data, and rental and reserving book list df_not_read = bc.get_want_read_book_list(options.booklog_data_file) df_reading = bc.read_booklist(options.lend_file) df_reserving = bc.read_booklist(options.reserve_file) df_reading_or_reserving = pd.concat([df_reading, df_reserving]) # get book status status_series = bc.create_all_book_status(df_not_read, df_reading_or_reserving, short=options.short) df_not_read['waitstatus'] = status_series # output dataframe to file # 注: 現在借りている本が読みたいラベルの本リストに存在しているとは限らないので、 # 「現在借用中or予約中」「蔵書なし」「予約なし」「予約あり」を足したものと # 「読みたいラベルの本」は一致しない可能性がある ## not_found df_not_found = df_not_read[df_not_read['waitstatus'] == 'not_found'] df_not_found.to_csv(options.output_not_found_file) ## no_reservation df_not_found = df_not_read[df_not_read['waitstatus'] == 'no_reservation'] df_not_found.to_csv(options.output_no_reservation_file) ## no_reservation df_not_found = df_not_read[df_not_read['waitstatus'] == 'has_reservation'] df_not_found.to_csv(options.output_has_reservation_file) logging.debug("classfy_list_ichikawa.py end")
def test_evaluate_book_status1() -> None: bc = BookClassifier(sleep=3) book_info = pd.Series({'13桁ISBN': np.nan}) status = bc.evaluate_book_status(book_info=book_info, nowreading_df=None) assert (status == 'not_found')
def test_book_is_rental3() -> None: bc = BookClassifier(sleep=3) book_info = pd.Series({'13桁ISBN': 111111}) result = bc.book_is_rental_or_reserving(book_info=book_info, nowreading_df=None) assert (not result)
def test_read_booklist2() -> None: bc = BookClassifier(sleep=3) with pytest.warns(UserWarning): df = bc.read_booklist('not_exist_path') assert (len(df) == 0)
def test_read_booklist1() -> None: bc = BookClassifier(sleep=3) df = bc.read_booklist(os.path.join(test_data_path, 'lend.csv')) assert (len(df) == 1) assert (df['title'].iloc[0] == 'dummy_title')
def test_get_want_read_book_list() -> None: bc = BookClassifier(sleep=3) df = bc.get_want_read_book_list( os.path.join(test_data_path, 'booklog_sample.csv')) assert (len(df) == 1)