Skip to content

Commit

Permalink
Test artifact configuration on the user interface
Browse files Browse the repository at this point in the history
Signed-off-by: Akashdeep Dhar <[email protected]>
  • Loading branch information
gridhead committed Sep 20, 2024
1 parent c822cbe commit 6b5c98e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gi_loadouts/face/wind/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def change_data_by_changing_level_or_stat(self, droplevl: QComboBox, droptype: Q
rare = getattr(Rare, droprare.currentText().replace(" ", "_"))
stat = getattr(arti, f"revmap_{part}")[dropstat.currentText().strip()]
item = getattr(team.value, part)
item.levl, item.rare, item.stat_name = levl.value.levl, rare.value.qant, stat
item.rare, item.levl, item.stat_name = rare.value.qant, levl.value.levl, stat
statdata.setText(f"{round(item.stat_data, 1)}")

def change_artifact_team_by_changing_type(self, droptype: QComboBox, part: str) -> None:
Expand Down
Empty file added test/face/wind/arti/__init__.py
Empty file.
58 changes: 58 additions & 0 deletions test/face/wind/arti/test_arti.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from random import choice

import pytest

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


@pytest.mark.parametrize(
"name, rare, pair, quad, coll",
[
pytest.param(
name, team.rare, team.pairtext, team.quadtext,
(team.fwol, team.pmod, team.sdoe, team.gboe, team.ccol),
id=f"face.wind.rule: Configuration artifact - {name}"
) for name, team in __artilist__.items()
]
)
def test_arti(runner, name, rare, pair, quad, coll) -> None:
"""
Test the configuration of artifacts on the user interface
:return:
"""

"""
Set the user interface elements as intended
"""
conf = dict()

for area in ["fwol", "pmod", "sdoe", "gboe", "ccol"]:
conf[area] = dict()
getattr(runner, f"arti_{area}_type").setCurrentText(name)
conf[area]["rare"] = choice([item for item in rare])
getattr(runner, f"arti_{area}_rare").setCurrentText(conf[area]["rare"].value.name)
conf[area]["levl"] = choice([item for item in ArtiLevl if conf[area]["rare"] in item.value.rare])
getattr(runner, f"arti_{area}_levl").setCurrentText(conf[area]["levl"].value.name)
conf[area]["stat"] = choice([item for item in getattr(base, f"MainStatType_{area.upper()}") if item.value != STAT.none])
getattr(runner, f"arti_{area}_name_main").setCurrentText(conf[area]["stat"].value.value)

"""
Confirm if the user interface elements change accordingly
"""
if name == "None":
return

for indx, area in enumerate(["fwol", "pmod", "sdoe", "gboe", "ccol"]):
item = coll[indx]
assert getattr(runner, f"arti_{area}_type_name").text() == truncate_text(coll[indx].__name__, 32)
item.rare, item.levl, item.stat_name = conf[area]["rare"].value.qant, conf[area]["levl"].value.levl, conf[area]["stat"]
assert getattr(runner, f"arti_{area}_data_main").text() == str(round(item.stat_data, 1))

assert runner.pair_area_head.text() == f"<b>{truncate_text(name, 26)}</b> (2)"
assert runner.quad_area_head.text() == f"<b>{truncate_text(name, 26)}</b> (4)"
assert runner.pair_area_desc.toPlainText() == pair
assert runner.quad_area_desc.toPlainText() == quad

0 comments on commit 6b5c98e

Please sign in to comment.