ajout test note attente, abs et exc, correction format float et cleaning

This commit is contained in:
Aurélien Plancke 2021-06-10 16:59:01 +02:00
parent a9a90828e4
commit 568f6f3813
2 changed files with 203 additions and 41 deletions

View File

@ -93,32 +93,9 @@ class PythonOrgSearch(unittest.TestCase):
if "12" not in MOY_UE1:
noteBonne = False
self.assertTrue(noteBonne)
# matiereAvecEvaluation = driver.find_elements_by_xpath("//a[contains(text(),'1 prévues, 0 ok')]")
#
# for evaluation in matiereAvecEvaluation:
# URL = driver.current_url
# evaluation.click()
# self.wait.until(EC.url_changes(URL))
# URL_SEMESTRE = driver.current_url
# driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
# self.wait.until(EC.url_changes(URL_SEMESTRE))
# for champs in driver.find_elements_by_xpath(
# "//input[contains(@id,'" + linkAddNote + "')]"
# ):
# champs.send_keys(12)
# idChamp = champs.get_attribute("id")
# idEtud = idChamp[len(linkAddNote) : len(idChamp)]
# if idEtud not in listeEtudiant:
# listeEtudiant.append(idEtud)
# URL = driver.current_url
# driver.find_element_by_id("formnotes_submit").click()
# self.wait.until(EC.url_changes(URL))
# driver.get(URL_SEMESTRE)
# self.wait.until(EC.url_changes(URL))
# matiereAvecEvaluation = driver.find_elements_by_xpath(
# "//a[contains(text(),'1 prévues, 0 ok')]"
# )
# Test : Ajoute une note à la seconde UE pour les deux élèves
# @expected : La moyenne de la seconde UE apparait et corresponds à la note rentrée
def test_020_ajout_note_seconde_ue(self):
global listeEtudiant
global MOY_UE2
@ -154,10 +131,9 @@ class PythonOrgSearch(unittest.TestCase):
self.assertTrue(noteBonne)
# Test : Vérification calcul de la moyenne générale
# @expected La moyenne prends en compte les deux ue et leur coefficiant
def test_030_verification_moyenne_generale(self):
global listeEtudiant
global MOY_UE1
global MOY_UE2
global COEFF_UE1
global COEFF_UE2
COEFF_UE1 = 2
@ -178,10 +154,10 @@ class PythonOrgSearch(unittest.TestCase):
moyenneBonne = False
self.assertTrue(moyenneBonne)
# Test : Changement du coefficiant d'un module et de ce fait, du coefficiant de l'UE
# @expected : La moyenne générale se modifie en fonction de ce changement de coefficiant
def test_040_modification_coefficiant_module(self):
global listeEtudiant
global COEFF_UE1
global COEFF_UE2
COEFF_UE1 = 3
driver = self.driver
url = self.url
@ -208,11 +184,9 @@ class PythonOrgSearch(unittest.TestCase):
moyenneBonne = False
self.assertTrue(moyenneBonne)
# Test : Ajout d'une note bonus pour un étudiant et d'une note malus pour un autre
# @expected : La moyenne de l'UE où est ajouté la note bonus/malus est impactée par cette dernière, la moyenne générale change avec ce changement de moyenne d'UE
def test_050_ajout_note_bonus(self):
global listeEtudiant
global COEFF_UE1
global COEFF_UE2
global URL_SEMESTRE
moyenneBonusEtudiant1 = "0.25"
moyenneBonusEtudiant2 = "0.25"
linkAddNote = "formnotes_note_"
@ -265,11 +239,9 @@ class PythonOrgSearch(unittest.TestCase):
numeroEtu = numeroEtu + 1
self.assertTrue(moyenneBonne)
def test_060_note_absent(self):
global listeEtudiant
global COEFF_UE1
global COEFF_UE2
global URL_SEMESTRE
# Test : Ajout d'une note en attente pour un étudiant, et d'une note entrée pour un autre sur une même évaluation
# @expected :
def test_060_note_attente(self):
moyenneBonusEtudiant1 = "0.25"
moyenneBonusEtudiant2 = "0.25"
linkAddNote = "formnotes_note_"
@ -291,6 +263,130 @@ class PythonOrgSearch(unittest.TestCase):
moyenneBonne = True
affichageMoyenne = True
ueList = []
for etudiant in listeEtudiant:
URL = driver.current_url
searchBar = driver.find_element_by_id("in-expnom")
searchBar.send_keys(etudiant)
searchBar.submit()
time.sleep(5)
ueListElement = driver.find_elements_by_class_name("ue_acro")
ueListText = []
for ueElement in ueListElement:
ueListText.append(ueElement.text)
if numeroEtu == 0:
moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1)
if moyEtudiant1 != float(
driver.find_element_by_class_name("rcp_moy").text
):
moyenneBonne = False
if "UE11" in ueListText:
affichageMoyenne = False
elif numeroEtu == 1:
moyEtudiant2 = (
float(MOY_UE1) * COEFF_UE1
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
) / (COEFF_UE1 + COEFF_UE2)
if moyEtudiant2 != float(
driver.find_element_by_class_name("rcp_moy").text
):
moyenneBonne = False
if "UE11" not in ueListText:
affichageMoyenne = False
numeroEtu = numeroEtu + 1
self.assertTrue(moyenneBonne and affichageMoyenne)
def test_070_note_absent(self):
ue_name = "UE11"
moyenneBonusEtudiant1 = "0.25"
moyenneBonusEtudiant2 = "0.25"
linkAddNote = "formnotes_note_"
MOY_UE1_EXC = 0
champsNote = []
driver = self.driver
driver.get(URL_SEMESTRE)
driver.find_element_by_link_text("M1101").click()
self.wait.until(EC.url_changes(URL_SEMESTRE))
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
URL = driver.current_url
champsNote = driver.find_elements_by_xpath(
"//input[contains(@id,'" + linkAddNote + "')]"
)
champsNote[0].clear()
champsNote[0].send_keys("ABS")
driver.find_element_by_id("formnotes_submit").click()
self.wait.until(EC.url_changes(URL))
numeroEtu = 0
moyenneBonne = True
affichageMoyenne = True
noteExcuseeEgaleAZero = True
ueList = []
for etudiant in listeEtudiant:
URL = driver.current_url
searchBar = driver.find_element_by_id("in-expnom")
searchBar.send_keys(etudiant)
searchBar.submit()
self.wait.until(EC.url_changes(URL))
ueListElement = driver.find_elements_by_class_name("ue_acro")
ueListText = []
for ueElement in ueListElement:
ueListText.append(ueElement.text)
if numeroEtu == 0:
moyEtudiant1 = (
float(MOY_UE1_EXC) * COEFF_UE1
+ ((float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2)
) / (COEFF_UE1 + COEFF_UE2)
print(format(moyEtudiant1, "2.2f"))
print(
format(
float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
)
)
if format(moyEtudiant1, "2.2f") != format(
float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
):
moyenneBonne = False
if ue_name not in ueListText:
affichageMoyenne = False
MOY_UE1 = driver.find_element_by_id("ue_" + ue_name).text
if float(0) != float(MOY_UE1):
noteExcuseeEgaleAZero = False
elif numeroEtu == 1:
MOY_UE1 = driver.find_element_by_id("ue_" + ue_name).text
moyEtudiant2 = (
float(MOY_UE1) * COEFF_UE1
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
) / (COEFF_UE1 + COEFF_UE2)
if moyEtudiant2 != float(
driver.find_element_by_class_name("rcp_moy").text
):
moyenneBonne = False
if "UE11" not in ueListText:
affichageMoyenne = False
numeroEtu = numeroEtu + 1
self.assertTrue(moyenneBonne and affichageMoyenne and noteExcuseeEgaleAZero)
def test_080_note_excuse(self):
moyenneBonusEtudiant1 = "0.25"
moyenneBonusEtudiant2 = "0.25"
linkAddNote = "formnotes_note_"
champsNote = []
driver = self.driver
driver.get(URL_SEMESTRE)
driver.find_element_by_link_text("M1101").click()
self.wait.until(EC.url_changes(URL_SEMESTRE))
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
URL = driver.current_url
champsNote = driver.find_elements_by_xpath(
"//input[contains(@id,'" + linkAddNote + "')]"
)
champsNote[0].clear()
champsNote[0].send_keys("EXC")
driver.find_element_by_id("formnotes_submit").click()
self.wait.until(EC.url_changes(URL))
numeroEtu = 0
moyenneBonne = True
affichageMoyenne = True
ueList = []
for etudiant in listeEtudiant:
URL = driver.current_url
searchBar = driver.find_element_by_id("in-expnom")
@ -323,8 +419,13 @@ class PythonOrgSearch(unittest.TestCase):
numeroEtu = numeroEtu + 1
self.assertTrue(moyenneBonne and affichageMoyenne)
# def test_070_note_attente(self):
# def test_080_note_excuse(self):
# TOdo
def test_090_note_bonus(self):
global listeEtudiant
global COEFF_UE1
global COEFF_UE2
global URL_SEMESTRE
def tearDown(self):
self.driver.close()

View File

@ -0,0 +1,61 @@
import unittest
import time
import subprocess
import urllib.parse as urlparse
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
BASE_URL,
BASE_NOT_SECURED_URL,
LINK_SCODOC_SERVER,
NOM_DPT,
SCODOC_ENS_ID,
SCODOC_ENS_PASS,
SCODOC_CHEF_ID,
SCODOC_CHEF_PASS,
NAVIGATEUR,
)
from urllib.parse import parse_qs
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select
class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self):
if NAVIGATEUR == "firefox":
self.driver = webdriver.Firefox()
elif NAVIGATEUR == "chrome":
self.driver = webdriver.Chrome()
self.url = BASE_URL + NOM_DPT + "/Scolarite"
self.wait = WebDriverWait(self.driver, 10)
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
def test_010_decision_modifiable_sur_fiche_etudiant(self):
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = [
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
NOM_DPT,
"test_scenario4_formation.py",
]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main(warnings="ignore")