File size: 3,487 Bytes
86cbfce
 
 
 
 
834b7c1
 
6d959c6
ad476aa
 
 
 
 
a573bfb
 
6d959c6
a573bfb
834b7c1
a573bfb
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
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 --capture=no

@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)
    # print(f"Got page section content: \n{result}")
    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')
    #plt.imshow(result)
    #plt.show()


@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