| from my_tool_reverse_string import ReverseStringTool |
| from my_tool_image_load import ImageLoadTool |
| from my_tool_chess_board import ChessBoard |
| from my_tool_fen import FENTool |
| from my_tool_chess_analysis import ChessAnalysisTool |
| from my_tool_wiki_page_section import MyWikiPageSectionTool |
| from my_tool_wiki_filter_tables import MyWikiTableFilterTool |
| from my_base_wiki_api import MyWikiAPI |
| from my_tool_wiki_featured_articles import MyWikiFeaturedArticles |
| from my_base_libretexts_api import MyLibreTextsAPI |
| import pytest |
| import matplotlib as mp |
|
|
| |
|
|
| @pytest.mark.parametrize("_exp", [("Introductory")]) |
| def test_tool_libretextx_bookshelves(_exp): |
| api = MyLibreTextsAPI() |
| bookshelves = api.get_bookshelves() |
|
|
| shelf_1 = bookshelves[0] |
| shelf_1_url = shelf_1[1] |
|
|
| books = api.get_books(shelf_1_url) |
|
|
| book_2 = books[1] |
| book_2_url = book_2[1] |
|
|
| sections = api.get_book_sections(book_2_url) |
|
|
| section_2 = sections[1] |
| section_2_url = section_2[1] |
|
|
| paragraphs = api.get_book_section_paragraphs(section_2_url) |
|
|
| paragraph_8 = paragraphs[7] |
| paragraph_8_url = paragraph_8[1] |
|
|
| |
| |
| |
| |
| |
|
|
| assert 0 == 0 |
|
|
|
|
| @pytest.mark.skip(reason="disabled") |
| @pytest.mark.parametrize("_month,_year,_exp", [('November',2016, "FunkMonk")]) |
| def test_tool_wiki_contributions(_month,_year, _exp): |
| tool = MyWikiFeaturedArticles() |
| results = tool(month=_month, year=_year) |
| results_str = "\n".join(results) |
| print(f"Results: {len(results)}\n{results_str}") |
|
|
| assert _exp in results_str |
|
|
|
|
| @pytest.mark.skip(reason="disabled") |
| @pytest.mark.parametrize("_page,_section,_sub_section,_year_start,_year_end,_exp", |
| [("Mercedes Sosa", "Discography", "Studio albums", 2000, 2009, 3)]) |
| def test_tool_wiki_page_section(_page, _section, _sub_section, _year_start, _year_end, _exp): |
| w = MyWikiPageSectionTool() |
| f = MyWikiTableFilterTool() |
| result = w(page=_page, section=_section) |
| filtered = f(result, _sub_section, _year_start, _year_end) |
| print(f"Table filtered: \n{filtered}") |
| assert len(filtered) == _exp |
|
|
|
|
| @pytest.mark.skip(reason="disabled") |
| @pytest.mark.parametrize("_inp,_exp", [("abc", "cba"), ("ihg fed cba", "abc def ghi")]) |
| def test_tool_reverse_string(_inp,_exp): |
| assert ReverseStringTool().forward(_inp) == _exp |
|
|
|
|
| @pytest.mark.skip(reason="disabled") |
| @pytest.mark.parametrize("_task_id,_exp", [("cca530fc-4052-43b2-b130-b30968d8aa44", "")]) |
| def test_tool_image_load(_task_id,_exp): |
| print(f"\nLoading image for task id: {_task_id}") |
| t = ImageLoadTool() |
| result = t.forward(_task_id) |
| print(f"Got result: {result}") |
| mp.use('QtAgg') |
|
|
|
|
| @pytest.mark.skip(reason="disabled") |
| @pytest.mark.parametrize("_task_id,_exp", [("cca530fc-4052-43b2-b130-b30968d8aa44", |
| "1K1111111PP11111P11RBBqP1111n111Q1111111p11b11111pp111pp1k11r111")]) |
| def test_tool_chess_board(_task_id,_exp): |
| print(f"\nLoading image for task id: {_task_id}") |
| t = ImageLoadTool() |
| image = t.forward(_task_id) |
| print(f"Got result: {image}") |
| chess_board_model_name = "my_chess_pieces_recognition.pth" |
| chess_board_model_dir = "/mnt/c/Users/krzsa/IdeaProjects/Agents-Course-Assignment/saved_models" |
| board_tool = ChessBoard(chess_board_model_name, chess_board_model_dir) |
| pieces = board_tool.forward(image) |
| assert pieces == _exp |
|
|
|
|
| @pytest.mark.skip(reason="disabled") |
| @pytest.mark.parametrize("_pieces_list,_exp", |
| [ |
| ("1K1111111PP11111P11RBBqP1111n111Q1111111p11b11111pp111pp1k11r111", |
| "3r2k1/pp3pp1/4b2p/7Q/3n4/PqBBR2P/5PP1/6K1 b - - 0 1") |
| ]) |
| def test_tool_fen(_pieces_list,_exp): |
| print(f"\nConverting pieces list to FEN: {_pieces_list}") |
| t = FENTool() |
| fen = t.forward(_pieces_list) |
| print(f"Got result: {fen}") |
| assert fen == _exp |
|
|
|
|
| @pytest.mark.skip(reason="disabled") |
| @pytest.mark.parametrize("_fen,_exp", |
| [ |
| ("3r2k1/pp3pp1/4b2p/7Q/3n4/PqBBR2P/5PP1/6K1 b - - 0 1", "d8d5") |
| ]) |
| def test_tool_chess_analysis(_fen,_exp): |
| print(f"\nAnalysing FEN: {_fen}") |
| t = ChessAnalysisTool() |
| best_move = t.forward(_fen) |
| print(f"Got result: {best_move}") |
| assert best_move == _exp |
|
|