mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 14:38:03 +01:00
Refactor tests
This commit is contained in:
parent
5c9718d14a
commit
5426c4ac3c
1 changed files with 44 additions and 23 deletions
|
@ -2,7 +2,6 @@ import pytest
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
from pytest_django.live_server_helper import LiveServer
|
from pytest_django.live_server_helper import LiveServer
|
||||||
from selenium.webdriver import Keys
|
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.firefox.webdriver import WebDriver
|
from selenium.webdriver.firefox.webdriver import WebDriver
|
||||||
from selenium.webdriver.support.select import Select
|
from selenium.webdriver.support.select import Select
|
||||||
|
@ -129,22 +128,23 @@ def test_player_can_add_effect_to_group(
|
||||||
|
|
||||||
assert BattleEffect.objects.count() == 0
|
assert BattleEffect.objects.count() == 0
|
||||||
|
|
||||||
login(selenium, live_server, user, password)
|
name = "Agrandissement"
|
||||||
|
target = "Joueur 4"
|
||||||
url = reverse("party:details", kwargs={"pk": party.pk})
|
description = (
|
||||||
selenium.get(live_server.url + url)
|
|
||||||
selenium.find_element(By.ID, "add-effect").click()
|
|
||||||
selenium.find_element(By.ID, "id_name").send_keys("Agrandissement")
|
|
||||||
selenium.find_element(By.ID, "id_target").send_keys("Joueur 4")
|
|
||||||
selenium.find_element(By.ID, "id_description").send_keys(
|
|
||||||
"Le Magicien ou une cible volontaire (au contact) voit sa taille augmenter de "
|
"Le Magicien ou une cible volontaire (au contact) voit sa taille augmenter de "
|
||||||
"50% pendant [5 + Mod. d'INT] tours. Il gagne +2 aux DM au contact et aux "
|
"50% pendant [5 + Mod. d'INT] tours. Il gagne +2 aux DM au contact et aux "
|
||||||
"tests de FOR. Pataud, il subit un malus de -2 aux tests de DEX."
|
"tests de FOR. Pataud, il subit un malus de -2 aux tests de DEX."
|
||||||
)
|
)
|
||||||
selenium.find_element(By.ID, "id_remaining_rounds").send_keys(Keys.DELETE, "8")
|
remaining_rounds = "8"
|
||||||
selenium.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
|
|
||||||
|
|
||||||
assert BattleEffect.objects.count() == 1
|
login(selenium, live_server, user, password)
|
||||||
|
|
||||||
|
url = reverse("party:details", kwargs={"pk": party.pk})
|
||||||
|
selenium.get(live_server.url + url)
|
||||||
|
|
||||||
|
fill_effect(selenium, name, description, target, remaining_rounds)
|
||||||
|
|
||||||
|
assert_effect_is_created(name, description, target, remaining_rounds)
|
||||||
# Todo: assert effect is displayed
|
# Todo: assert effect is displayed
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,24 +159,25 @@ def test_gm_can_add_effect_to_group(
|
||||||
|
|
||||||
assert BattleEffect.objects.count() == 0
|
assert BattleEffect.objects.count() == 0
|
||||||
|
|
||||||
login(selenium, live_server, user, password)
|
name = "Brûlé"
|
||||||
|
target = "Boss 2"
|
||||||
url = reverse("party:details", kwargs={"pk": party.pk})
|
description = (
|
||||||
selenium.get(live_server.url + url)
|
|
||||||
selenium.find_element(By.ID, "add-effect").click()
|
|
||||||
selenium.find_element(By.ID, "id_name").send_keys("Brûlé")
|
|
||||||
selenium.find_element(By.ID, "id_target").send_keys("Boss 2")
|
|
||||||
selenium.find_element(By.ID, "id_description").send_keys(
|
|
||||||
"Le Magicien choisit une cible située à moins de 30 mètres. Si son attaque "
|
"Le Magicien choisit une cible située à moins de 30 mètres. Si son attaque "
|
||||||
"magique réussit, la cible encaisse [1d6 + Mod. d'INT] DM et la flèche "
|
"magique réussit, la cible encaisse [1d6 + Mod. d'INT] DM et la flèche "
|
||||||
"enflamme ses vêtements. Chaque tour de combat suivant, le feu inflige 1d6 "
|
"enflamme ses vêtements. Chaque tour de combat suivant, le feu inflige 1d6 "
|
||||||
"dégâts supplémentaires. Sur un résultat de 1 à 2, les flammes s'éteignent et "
|
"dégâts supplémentaires. Sur un résultat de 1 à 2, les flammes s'éteignent et "
|
||||||
"le sort prend fin."
|
"le sort prend fin."
|
||||||
)
|
)
|
||||||
selenium.find_element(By.ID, "id_remaining_rounds").send_keys(Keys.DELETE, "-1")
|
remaining_rounds = "-1"
|
||||||
selenium.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
|
|
||||||
|
|
||||||
assert BattleEffect.objects.count() == 1
|
login(selenium, live_server, user, password)
|
||||||
|
|
||||||
|
url = reverse("party:details", kwargs={"pk": party.pk})
|
||||||
|
selenium.get(live_server.url + url)
|
||||||
|
|
||||||
|
fill_effect(selenium, name, description, target, remaining_rounds)
|
||||||
|
|
||||||
|
assert_effect_is_created(name, description, target, remaining_rounds)
|
||||||
# Todo: assert effect is displayed
|
# Todo: assert effect is displayed
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,3 +214,23 @@ def test_player_can_delete_terminated_effect(
|
||||||
selenium: WebDriver, live_server: LiveServer, initial_data: None
|
selenium: WebDriver, live_server: LiveServer, initial_data: None
|
||||||
):
|
):
|
||||||
"""Members of the group can delete terminated effects."""
|
"""Members of the group can delete terminated effects."""
|
||||||
|
|
||||||
|
|
||||||
|
def fill_effect(selenium, name, description, target, remaining_rounds):
|
||||||
|
selenium.find_element(By.ID, "add-effect").click()
|
||||||
|
selenium.find_element(By.ID, "id_name").send_keys(name)
|
||||||
|
selenium.find_element(By.ID, "id_target").send_keys(target)
|
||||||
|
selenium.find_element(By.ID, "id_description").send_keys(description)
|
||||||
|
rounds_element = selenium.find_element(By.ID, "id_remaining_rounds")
|
||||||
|
rounds_element.clear()
|
||||||
|
rounds_element.send_keys(remaining_rounds)
|
||||||
|
selenium.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
|
||||||
|
|
||||||
|
|
||||||
|
def assert_effect_is_created(name, description, target, remaining_rounds):
|
||||||
|
assert BattleEffect.objects.count() == 1
|
||||||
|
effect = BattleEffect.objects.first()
|
||||||
|
assert effect.name == name
|
||||||
|
assert effect.target == target
|
||||||
|
assert effect.description == description
|
||||||
|
assert str(effect.remaining_rounds) == remaining_rounds
|
||||||
|
|
Loading…
Reference in a new issue