| | 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 |
| | import pytest |
| | import matplotlib as mp |
| |
|
| | |
| |
|
| | @pytest.mark.parametrize("_month,_year,_exp", [('November',2016, "Giganotosaurus")]) |
| | def test_tool_wiki_contributions(_month,_year, _exp): |
| | api = MyWikiAPI() |
| | content = api.get_featured_articles(_month,_year) |
| |
|
| | assert content.find(_exp) >= 0 |
| |
|
| |
|
| | @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 |
| |
|