47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from core.models import Bounds, Scene, SceneElement
|
|
from tools.find_icon import find_icon
|
|
from tools.find_text import find_text
|
|
|
|
|
|
def test_find_text_found_and_not_found() -> None:
|
|
scene = Scene(
|
|
width=100,
|
|
height=100,
|
|
elements=[
|
|
SceneElement(
|
|
id="button",
|
|
type="button",
|
|
text="Search",
|
|
bounds=Bounds(10, 20, 40, 20),
|
|
)
|
|
],
|
|
)
|
|
|
|
assert find_text(scene, "sea")["found"] is True
|
|
assert find_text(scene, "missing") == {
|
|
"found": False,
|
|
"query": "missing",
|
|
"reason": "not found",
|
|
}
|
|
|
|
|
|
def test_find_icon_found_and_not_found() -> None:
|
|
scene = Scene(
|
|
width=100,
|
|
height=100,
|
|
elements=[
|
|
SceneElement(
|
|
id="settings-icon",
|
|
type="image",
|
|
text="Settings",
|
|
bounds=Bounds(50, 50, 20, 20),
|
|
)
|
|
],
|
|
)
|
|
|
|
assert find_icon(scene, "settings")["found"] is True
|
|
assert find_icon(scene, "profile")["reason"] == "not found"
|
|
|