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 25, 2024
1 parent 950aca2 commit e5f6062
Show file tree
Hide file tree
Showing 2 changed files with 242 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
},
}
}
}
115 changes: 115 additions & 0 deletions test/face/otpt/test_otpt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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 = f"({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.replace("(","").replace(")","")) 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}"
assert runner.otptobjc.area_hlpt_data.text() == str(round(runner.otptobjc.tyvt.health_points.stat_data, 1))
assert runner.otptobjc.area_hlpt_calc.text() == f"{round(runner.otptobjc.tyvt.addendum_base_health_points.stat_data, 1)} + {round(runner.otptobjc.tyvt.addendum_plus_health_points.stat_data, 1)}"
assert runner.otptobjc.area_attk_data.text() == str(round(runner.otptobjc.tyvt.attack.stat_data, 1))
assert runner.otptobjc.area_attk_calc.text() == f"{round(runner.otptobjc.tyvt.addendum_base_attack.stat_data, 1)} + {round(runner.otptobjc.tyvt.addendum_plus_attack.stat_data, 1)}"
assert runner.otptobjc.area_dfns_data.text() == str(round(runner.otptobjc.tyvt.defense.stat_data, 1))
assert runner.otptobjc.area_dfns_calc.text() == f"{round(runner.otptobjc.tyvt.addendum_base_defense.stat_data, 1)} + {round(runner.otptobjc.tyvt.addendum_plus_defense.stat_data, 1)}"
assert runner.otptobjc.area_elma_data.text() == str(round(runner.otptobjc.tyvt.elemental_mastery.stat_data, 1))
assert runner.otptobjc.area_crit_rate_data.text() == f"{str(round(runner.otptobjc.tyvt.critical_rate_perc.stat_data, 1))}%"
assert runner.otptobjc.area_crit_dmge_data.text() == f"{str(round(runner.otptobjc.tyvt.critical_damage_perc.stat_data, 1))}%"
assert runner.otptobjc.area_heal_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.healing_bonus_perc.stat_data, 1))}%"
assert runner.otptobjc.area_heal_incm_data.text() == f"{str(round(runner.otptobjc.tyvt.incoming_healing_bonus_perc.stat_data, 1))}%"
assert runner.otptobjc.area_enrc_data.text() == f"{str(round(runner.otptobjc.tyvt.energy_recharge_perc.stat_data, 1))}%"
assert runner.otptobjc.area_cldn_data.text() == f"{str(round(runner.otptobjc.tyvt.cooldown_reduction_perc.stat_data, 1))}%"
assert runner.otptobjc.area_sdsh_data.text() == f"{str(round(runner.otptobjc.tyvt.shield_strength_perc.stat_data, 1))}%"
assert runner.otptobjc.area_pyro_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_pyro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_pyro_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_pyro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_hydo_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_hydro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_hydo_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_hydro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_dend_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_dendro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_dend_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_dendro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_elec_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_electro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_elec_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_electro_perc.stat_data, 1))}%"
assert runner.otptobjc.area_anem_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_anemo_perc.stat_data, 1))}%"
assert runner.otptobjc.area_anem_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_anemo_perc.stat_data, 1))}%"
assert runner.otptobjc.area_cryo_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_cryo_perc.stat_data, 1))}%"
assert runner.otptobjc.area_cryo_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_cryo_perc.stat_data, 1))}%"
assert runner.otptobjc.area_geox_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_geo_perc.stat_data, 1))}%"
assert runner.otptobjc.area_geox_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_geo_perc.stat_data, 1))}%"
assert runner.otptobjc.area_phys_perc_data.text() == f"{str(round(runner.otptobjc.tyvt.damage_bonus_physical_perc.stat_data, 1))}%"
assert runner.otptobjc.area_phys_resi_data.text() == f"{str(round(runner.otptobjc.tyvt.resistance_physical_perc.stat_data, 1))}%"
assert runner.otptobjc.area_crvl_data.text() == f"{str(round(runner.otptobjc.tyvt.critical_damage_perc.stat_data + 2*(runner.otptobjc.tyvt.critical_rate_perc.stat_data), 1))}"

0 comments on commit e5f6062

Please sign in to comment.