Skip to content

Commit

Permalink
Add test for output window
Browse files Browse the repository at this point in the history
Signed-off-by: Shounak Dey <[email protected]>
  • Loading branch information
sdglitched committed Sep 24, 2024
1 parent 950aca2 commit 080d536
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 0 deletions.
127 changes: 127 additions & 0 deletions test/face/otpt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
__test_arti__ = {
"fwol": {
"rare": "Star 5",
"levl": "Level 20",
"main": "HP",
"type": "Emblem of Severed Fate",
"name": "Magnificent Tsuba",
"stat": {
"a": {
"name": "Crit Rate",
"data": 12.0
},
"b": {
"name": "Crit DMG",
"data": 34.0
},
"c": {
"name": "Elemental Mastery",
"data": 56.0
},
"d": {
"name": "Energy Recharge",
"data": 78.0
},
}
},
"pmod": {
"rare": "Star 5",
"levl": "Level 20",
"main": "ATK",
"type": "Emblem of Severed Fate",
"name": "Sundered Feather",
"stat": {
"a": {
"name": "DEF",
"data": 12.0
},
"b": {
"name": "DEF %",
"data": 34.0
},
"c": {
"name": "HP",
"data": 56.0
},
"d": {
"name": "HP %",
"data": 78.0
},
}
},
"sdoe": {
"rare": "Star 5",
"levl": "Level 20",
"main": "Elemental Mastery",
"type": "Shimenawa's Reminiscence",
"name": "Morning Dew's Moment",
"stat": {
"a": {
"name": "ATK",
"data": 12.0
},
"b": {
"name": "ATK %",
"data": 34.0
},
"c": {
"name": "Crit Rate",
"data": 56.0
},
"d": {
"name": "Crit DMG",
"data": 78.0
},
}
},
"gboe": {
"rare": "Star 5",
"levl": "Level 20",
"main": "Physical DMG Bonus",
"type": "Shimenawa's Reminiscence",
"name": "Hopeful Heart",
"stat": {
"a": {
"name": "Elemental Mastery",
"data": 12.0
},
"b": {
"name": "Energy Recharge",
"data": 34.0
},
"c": {
"name": "HP %",
"data": 56.0
},
"d": {
"name": "HP",
"data": 78.0
},
}
},
"ccol": {
"rare": "Star 5",
"levl": "Level 20",
"main": "Healing Bonus",
"type": "Noblesse Oblige",
"name": "Royal Masque",
"stat": {
"a": {
"name": "ATK",
"data": 12.0
},
"b": {
"name": "ATK %",
"data": 34.0
},
"c": {
"name": "Crit Rate",
"data": 56.0
},
"d": {
"name": "Crit DMG",
"data": 78.0
},
}
}
}
84 changes: 84 additions & 0 deletions test/face/otpt/test_otpt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from random import choice

import pytest
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QMainWindow

from gi_loadouts import __versdata__
from gi_loadouts.data.char import __charmaps__
from gi_loadouts.data.weap import Family
from gi_loadouts.type.char.cons import Cons
from gi_loadouts.type.levl import Level

from . import __test_arti__


@pytest.mark.parametrize(
"type",
[
pytest.param("Bow"),
pytest.param("Catalyst"),
pytest.param("Claymore"),
pytest.param("Polearm"),
pytest.param("Sword"),
]
)
def test_otpt(runner, qtbot, type) -> None:
"""
Attempt to generate final calculation based on character, weapon and artifact stats
:return:
"""

"""
Set the user interface elements as intended
"""
cname = choice([char.name for char in __charmaps__.values() if char.weapon.value == type])
clevl = choice(list(item.value.name for item in Level))
ccons = choice(list(item.value.name for item in Cons))

wname = choice(list(Family[type].keys()))
wobjc = Family[type][wname]
wlevl = choice(wobjc.levl_bind).value.name
wrefn = choice(list(wobjc.refinement.keys())) if wobjc.refinement.keys() else ""

runner.head_char_name.setCurrentText(cname)
runner.head_char_levl.setCurrentText(clevl)
runner.head_char_cons.setCurrentText(ccons)

runner.weap_area_name.setCurrentText(wname)
runner.weap_area_levl.setCurrentText(wlevl)
runner.weap_area_refn.setCurrentText(wrefn) if wrefn != "" else None

for area in ["fwol", "pmod", "sdoe", "gboe", "ccol"]:
getattr(runner, f"arti_{area}_type").setCurrentText(__test_arti__[area]["type"])
getattr(runner, f"arti_{area}_rare").setCurrentText(__test_arti__[area]["rare"])
getattr(runner, f"arti_{area}_levl").setCurrentText(__test_arti__[area]["levl"])
getattr(runner, f"arti_{area}_name_main").setCurrentText(__test_arti__[area]["main"])
for alfa in ["a", "b", "c", "d"]:
getattr(runner, f"arti_{area}_name_{alfa}").setCurrentText(__test_arti__[area]["stat"][alfa]["name"])
getattr(runner, f"arti_{area}_data_{alfa}").setText(str(__test_arti__[area]["stat"][alfa]["data"]))

if runner.collection.quad != "":
artiline = f"4 x <b>{runner.collection.quad}</b>"
elif len(runner.collection.pair) >= 1:
artiline = ", ".join([f"2 x <b>{item}</b>" for item in runner.collection.pair])
else:
artiline = "No artifact set bonus."

"""
Perform the action of clicking the help button
"""
qtbot.mouseClick(runner.head_scan, Qt.LeftButton)

"""
Confirm if the user interface elements change accordingly
"""

assert runner.head_scan.toolTip() == "Generate"
assert isinstance(runner.otptobjc, QMainWindow)
assert runner.otptobjc.windowTitle() == f"Loadouts for Genshin Impact v{__versdata__} - {runner.head_char_name.currentText()}"
assert runner.otptobjc.windowModality() == Qt.ApplicationModal
assert runner.otptobjc.head_area_line_prim.text() == f"<b>{cname}</b> - {clevl} ({ccons})"
assert runner.otptobjc.head_area_line_seco.text() == f"<b>{wname}</b> - {wlevl} ({wrefn})" + "<br/>" + f"{artiline}"

0 comments on commit 080d536

Please sign in to comment.