forked from Hammanek/AutoAFK
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(api): images should be able to be located
Test whether our images are located when expected in a series of screenshots. (Test true positives).
- Loading branch information
Showing
33 changed files
with
123 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pipdeptree | ||
pip-tools | ||
pyinstaller | ||
pytest | ||
ufmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import os | ||
|
||
|
||
TEST_DIR = os.path.dirname(os.path.abspath(__file__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import json | ||
import os | ||
|
||
import pyscreeze | ||
import pytest | ||
from PIL import Image | ||
|
||
from autoafk.tools import open_image | ||
from test import TEST_DIR | ||
|
||
|
||
def get_params() -> list[tuple[str, str]]: | ||
params: list[tuple[str, str]] = [] | ||
|
||
with open(os.path.join(TEST_DIR, "ss-imgs-map.json")) as f: | ||
SS_IMGS_DICT = json.load(f) | ||
for ss, images in SS_IMGS_DICT.items(): | ||
for image in images: | ||
params.append((image, ss)) | ||
|
||
return params | ||
|
||
|
||
def open_test_image(image: str) -> Image.Image: | ||
return Image.open(os.path.join(TEST_DIR, "ss", f"{image}.png")) | ||
|
||
|
||
@pytest.mark.parametrize("image,ss", get_params()) | ||
def test_locate_img_in_ss(image: str, ss: str): | ||
assert bool( | ||
pyscreeze.locate(open_image(image), open_test_image(ss), confidence=0.9) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"menus/quests": ["buttons/collect_quest", "buttons/back"], | ||
"menus/quests2": ["buttons/fullquestchest"], | ||
"menus/mail": ["buttons/collect_all", "buttons/back"], | ||
"menus/friends": ["buttons/sendandreceive", "buttons/back"], | ||
"menus/mercs": ["buttons/exitmenu"], | ||
|
||
"campaign/tab": [ | ||
"buttons/campaign_selected", | ||
"buttons/darkforest_unselected", | ||
"buttons/ranhorn_unselected", | ||
|
||
"buttons/begin", | ||
"buttons/fastrewards", | ||
|
||
"buttons/events", | ||
"menus/quests", | ||
"menus/bag", | ||
"buttons/mail", | ||
"buttons/friends" | ||
], | ||
"campaign/menu-1-collapsed": ["buttons/downarrow"], | ||
"campaign/menu-2-collapsed": ["buttons/downarrow"], | ||
"campaign/afk-rewards": ["buttons/collect", "buttons/close"], | ||
"campaign/fast-rewards": ["buttons/close"], | ||
"campaign/multi-battle-preview": ["buttons/begin"], | ||
"campaign/multi-battle": [ | ||
"buttons/heroclassselect", | ||
"buttons/beginbattle", | ||
"buttons/back" | ||
], | ||
"campaign/single-battle": [ | ||
"buttons/heroclassselect", | ||
"buttons/battle", | ||
"buttons/back" | ||
], | ||
|
||
"dark-forest/tab": [ | ||
"buttons/campaign_unselected", | ||
"buttons/darkforest_selected", | ||
"buttons/ranhorn_unselected", | ||
|
||
"buildings/trift" | ||
], | ||
"dark-forest/bounty-board/solo-collect": ["buttons/collect_all"], | ||
"dark-forest/bounty-board/solo": [ | ||
"labels/bountyboard", | ||
"buttons/dispatch", | ||
"labels/bounties/dust", | ||
"labels/bounties/diamonds", | ||
"buttons/refresh", | ||
"buttons/back" | ||
], | ||
"dark-forest/bounty-board/solo-dispatch": ["buttons/dispatch"], | ||
"dark-forest/bounty-board/team-collect": ["buttons/collect_all"], | ||
"dark-forest/bounty-board/team": ["buttons/dispatch", "buttons/back"], | ||
"dark-forest/bounty-board/team-dispatch": ["buttons/confirm"], | ||
"dark-forest/towers/kings-tower": ["buttons/back"], | ||
"dark-forest/trift": ["buttons/back"], | ||
"dark-forest/arena/menu": ["buttons/back"], | ||
|
||
"ranhorn/tab": [ | ||
"buttons/campaign_unselected", | ||
"buttons/darkforest_unselected", | ||
"buttons/ranhorn_selected", | ||
|
||
"buildings/store" | ||
], | ||
|
||
"misc/battle": ["buttons/pause"], | ||
"misc/battle-menu": ["buttons/exitbattle"] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.