forked from gridhead/gi-loadouts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new fixture `scantest` for testing `scan` window separately Remove extra loop and include the lines in existing loop Add `pragma: no cover` for the constructor of Assess to exclude it from the `coverage` Signed-off-by: Shounak Dey <[email protected]>
- Loading branch information
1 parent
3da9dc2
commit 1e24db8
Showing
5 changed files
with
151 additions
and
2 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
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,15 @@ | ||
from gi_loadouts.type.arti.base import ( | ||
MainStatType_CCOL, | ||
MainStatType_FWOL, | ||
MainStatType_GBOE, | ||
MainStatType_PMOD, | ||
MainStatType_SDOE, | ||
) | ||
|
||
__dist__ = { | ||
"Flower of Life": {"list": MainStatType_FWOL, "part": "fwol"}, | ||
"Plume of Death": {"list": MainStatType_PMOD, "part": "pmod"}, | ||
"Sands of Eon": {"list": MainStatType_SDOE, "part": "sdoe"}, | ||
"Goblet of Eonothem": {"list": MainStatType_GBOE, "part": "gboe"}, | ||
"Circlet of Logos": {"list": MainStatType_CCOL, "part": "ccol"}, | ||
} |
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,122 @@ | ||
from random import choice | ||
|
||
import pytest | ||
from PySide6.QtCore import Qt | ||
from PySide6.QtWidgets import QDialog | ||
|
||
from gi_loadouts import __versdata__ | ||
from gi_loadouts.data.arti import __artilist__ | ||
from gi_loadouts.face.util import truncate_text | ||
from gi_loadouts.type.arti import ArtiLevl, base | ||
from gi_loadouts.type.stat import STAT | ||
from test.face.scan import __dist__ | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"_", | ||
[ | ||
pytest.param(None, id="face.scan: Test OCR functionality") | ||
] | ||
) | ||
def test_scan(scantest, _) -> None: | ||
""" | ||
Test OCR functionality | ||
:return: | ||
""" | ||
|
||
""" | ||
Confirm if the user interface elements change accordingly | ||
""" | ||
assert isinstance(scantest, QDialog) | ||
assert scantest.windowTitle() == f"Loadouts for Genshin Impact v{__versdata__}" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"name, rare, part, part_type", | ||
[ | ||
pytest.param( | ||
name, team.rare, team.fwol, "Flower of Life", id=f"face.scan.rule: Configuration Flower of Life artifact - {name}" | ||
) for name, team in __artilist__.items() | ||
] + | ||
[ | ||
pytest.param( | ||
name, team.rare, team.pmod, "Plume of Death", id=f"face.scan.rule: Configuration Plume of Death artifact - {name}" | ||
) for name, team in __artilist__.items() | ||
] + | ||
[ | ||
pytest.param( | ||
name, team.rare, team.sdoe, "Sands of Eon", id=f"face.scan.rule: Configuration Sands of Eon artifact - {name}" | ||
) for name, team in __artilist__.items() | ||
] + | ||
[ | ||
pytest.param( | ||
name, team.rare, team.gboe, "Goblet of Eonothem", id=f"face.scan.rule: Configuration Goblet of Eonothem artifact - {name}" | ||
) for name, team in __artilist__.items() | ||
] + | ||
[ | ||
pytest.param( | ||
name, team.rare, team.ccol, "Circlet of Logos", id=f"face.scan.rule: Configuration Circlet of Logos artifact - {name}" | ||
) for name, team in __artilist__.items() | ||
] | ||
) | ||
def test_arti_drop(scantest, name, rare, part, part_type) -> None: | ||
""" | ||
Test the configuration of artifacts on the user interface | ||
:return: | ||
""" | ||
|
||
""" | ||
Set the user interface elements as intended | ||
""" | ||
conf = dict() | ||
|
||
conf["dist"] = part_type | ||
scantest.arti_dist.setCurrentText(conf["dist"]) | ||
conf["name"] = name | ||
scantest.arti_type.setCurrentText(conf["name"]) | ||
conf["rare"] = choice([item for item in rare]) | ||
scantest.arti_rare.setCurrentText(conf["rare"].value.name) | ||
conf["levl"] = choice([item for item in ArtiLevl if conf["rare"] in item.value.rare]) | ||
scantest.arti_levl.setCurrentText(conf["levl"].value.name) | ||
conf["stat"] = choice([item for item in getattr(base, __dist__[conf["dist"]]["list"].__name__) if item.value != STAT.none]) | ||
scantest.arti_name_main.setCurrentText(conf["stat"].value.value) | ||
""" | ||
Confirm if the user interface elements change accordingly | ||
""" | ||
if name == "None": | ||
return | ||
|
||
assert scantest.arti_type_name.text() == truncate_text(part.__name__, 34) | ||
assert scantest.arti_data_main.text() == str(round(part.stat_data, 1)) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"_", | ||
[ | ||
pytest.param(None, id="face.scan.rule: Clearing artifact") | ||
] | ||
) | ||
def test_arti_wipe(scantest, qtbot, _) -> None: | ||
""" | ||
Test the configuration of characters on the user interface | ||
:return: | ||
""" | ||
|
||
""" | ||
Set the user interface elements as intended | ||
""" | ||
qtbot.mouseClick(scantest.arti_back_wipe, Qt.LeftButton) | ||
|
||
""" | ||
Confirm if the user interface elements change accordingly | ||
""" | ||
assert scantest.arti_type.currentText() == "None" | ||
assert scantest.arti_levl.currentText() == "None" | ||
assert scantest.arti_rare.currentText() == "Star 0" | ||
assert scantest.arti_type_name.text() == "None" | ||
for item in ["main", "a", "b", "c", "d"]: | ||
assert getattr(scantest, f"arti_name_{item}").currentText() == "None" | ||
assert getattr(scantest, f"arti_data_{item}").text() == "" |