File size: 5,075 Bytes
86cbfce 834b7c1 e2523de de39e8f 8b3139e ad476aa 8b3139e de39e8f 264afdc de39e8f 264afdc de39e8f 264afdc de39e8f 264afdc de39e8f 264afdc de39e8f 264afdc de39e8f e2523de 834b7c1 de39e8f 6d959c6 834b7c1 1154bfc 834b7c1 ad476aa 6d959c6 1154bfc 834b7c1 ad476aa 1154bfc ad476aa 6d959c6 1154bfc 834b7c1 ad476aa 1154bfc ad476aa 1154bfc 834b7c1 1154bfc cefe018 1154bfc cefe018 6d959c6 834b7c1 cefe018 834b7c1 cefe018 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
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_tool_wiki_featured_articles import MyWikiFeaturedArticles
from my_base_libretexts_api import MyLibreTextsAPI
from my_tool_excel_load import ExcelLoadTool
from my_tool_python_load import PythonLoadTool
import pytest
import matplotlib as mp
#pytest --capture=no
@pytest.mark.parametrize("_task_id,_exp", [("f918266a-b3e0-4914-865d-4faa564f1aef", "")])
def test_tool_python_load(_task_id,_exp):
print(f"\nLoading Python file for task id: {_task_id}")
t = PythonLoadTool()
result = t.forward(_task_id)
print(f"Got result:\n{result}")
assert True
@pytest.mark.skip(reason="disabled")
@pytest.mark.parametrize("_task_id,_exp", [("7bd855d8-463d-4ed5-93ca-5fe35145f733", "")])
def test_tool_excel_load(_task_id,_exp):
print(f"\nLoading Excel file for task id: {_task_id}")
t = ExcelLoadTool()
result = t.forward(_task_id)
print(f"Got result:\n{result}")
assert True
@pytest.mark.skip(reason="disabled")
@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["url"]
books = api.get_books(shelf_1_url)
book_2 = books[1]
book_2_url = book_2["url"]
sections = api.get_book_sections(book_2_url)
section_2 = sections[1]
section_2_url = section_2["url"]
paragraphs = api.get_book_section_paragraphs(section_2_url)
paragraph_8 = paragraphs[7]
paragraph_8_url = paragraph_8["url"]
contents = api.get_paragraph_contents(paragraph_8_url)
#print(f"Contents:\n{contents}")
assert "Louvrier" in contents
@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
|