From d9e48101d70d8d8dcba71e9603a105ffc3aae875 Mon Sep 17 00:00:00 2001 From: aurelien Date: Wed, 9 Jun 2021 16:37:58 +0200 Subject: [PATCH] ajout test exc att et abs --- 03_etudiant_test.py | 2 - 05_saisie_note_test.py | 6 +- 06_test_moyenne.py | 148 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 139 insertions(+), 17 deletions(-) diff --git a/03_etudiant_test.py b/03_etudiant_test.py index 20d996e..6a0ea67 100644 --- a/03_etudiant_test.py +++ b/03_etudiant_test.py @@ -128,9 +128,7 @@ class PythonOrgSearch(unittest.TestCase): except NoSuchElementException: self.assertFalse(True) semestres[0].click() - # self.wait.until(EC.url_changes(URL)) driver.find_element_by_xpath("//input[@value='Inscrire']").click() - # self.wait.until(EC.url_changes(url)) self.assertTrue("inscrit" in driver.page_source) time.sleep(1) diff --git a/05_saisie_note_test.py b/05_saisie_note_test.py index e2caeb3..20c865b 100644 --- a/05_saisie_note_test.py +++ b/05_saisie_note_test.py @@ -246,11 +246,13 @@ class PythonOrgSearch(unittest.TestCase): element.send_keys("SUPR") driver.find_element_by_id("formnotes_submit").click() time.sleep(1) + interro_non_Presente = False try: driver.find_element_by_link_text("afficher") - self.assertFalse(False) + interro_non_Presente = False except NoSuchElementException: - self.assertTrue(True) + interro_non_Presente = True + self.assertTrue(interro_non_Presente) global isChef isChef = True global isEns diff --git a/06_test_moyenne.py b/06_test_moyenne.py index c27aedb..ccb85df 100644 --- a/06_test_moyenne.py +++ b/06_test_moyenne.py @@ -28,6 +28,8 @@ listeEtudiant = [] global MOY_UE1 global MOY_UE2 global URL_SEMESTRE +global COEFFUE1 +global COEFFUE2 class PythonOrgSearch(unittest.TestCase): @@ -156,8 +158,10 @@ class PythonOrgSearch(unittest.TestCase): global listeEtudiant global MOY_UE1 global MOY_UE2 - coeffUE1 = 2 - coeffUE2 = 2 + global COEFF_UE1 + global COEFF_UE2 + COEFF_UE1 = 2 + COEFF_UE2 = 2 driver = self.driver url = self.url driver.get(url) @@ -166,28 +170,28 @@ class PythonOrgSearch(unittest.TestCase): searchBar = driver.find_element_by_id("in-expnom") searchBar.send_keys(etudiant) searchBar.submit() - self.wait.until(EC.url_changes(url)) + time.sleep(5) if ( - (float(MOY_UE1) * coeffUE1 + float(MOY_UE2) * coeffUE2) - / (coeffUE1 + coeffUE2) + (float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2) + / (COEFF_UE1 + COEFF_UE2) ) != float(driver.find_element_by_class_name("rcp_moy").text): moyenneBonne = False self.assertTrue(moyenneBonne) def test_040_modification_coefficiant_module(self): global listeEtudiant - moyUE1 = 3 - coeffUE1 = 3 - coeffUE2 = 2 + global COEFF_UE1 + global COEFF_UE2 + COEFF_UE1 = 3 driver = self.driver url = self.url driver.get(url) - URL = driver.current_url driver.find_element_by_id("ProgrammesLink").click() driver.find_element_by_id("titre_DUT Info").click() driver.find_element_by_xpath("//span[contains(text(),'M1101')]").click() driver.find_element_by_id("tf_coefficient").clear() - driver.find_element_by_id("tf_coefficient").send_keys(moyUE1) + driver.find_element_by_id("tf_coefficient").send_keys(COEFF_UE1) + URL = driver.current_url driver.find_element_by_id("tf_submit").click() self.wait.until(EC.url_changes(URL)) moyenneBonne = True @@ -196,14 +200,132 @@ class PythonOrgSearch(unittest.TestCase): searchBar = driver.find_element_by_id("in-expnom") searchBar.send_keys(etudiant) searchBar.submit() - self.wait.until(EC.url_changes(URL)) + time.sleep(5) if ( - (float(MOY_UE1) * coeffUE1 + float(MOY_UE2) * coeffUE2) - / (coeffUE1 + coeffUE2) + (float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2) + / (COEFF_UE1 + COEFF_UE2) ) != float(driver.find_element_by_class_name("rcp_moy").text): moyenneBonne = False self.assertTrue(moyenneBonne) + 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_" + driver = self.driver + driver.get(URL_SEMESTRE) + driver.find_element_by_partial_link_text("malus").click() + driver.find_element_by_link_text("Créer nouvelle évaluation").click() + time.sleep(1) + driver.find_element_by_name("jour").clear() + driver.find_element_by_name("jour").send_keys("31/01/2021") + driver.find_element_by_id("tf_description").send_keys("une interrogation bonus") + driver.find_element_by_id("tf_submit").click() + time.sleep(1) + driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click() + self.wait.until(EC.url_changes(URL_SEMESTRE)) + champsNote = driver.find_elements_by_xpath( + "//input[contains(@id,'" + linkAddNote + "')]" + ) + champsNote[0].clear() + champsNote[1].clear() + champsNote[0].send_keys("-" + moyenneBonusEtudiant1) + champsNote[1].send_keys(moyenneBonusEtudiant2) + driver.find_element_by_id("formnotes_submit").click() + numeroEtu = 0 + moyenneBonne = True + 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) + if numeroEtu == 0: + if ( + ( + float(MOY_UE1) * COEFF_UE1 + + (float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2 + ) + / (COEFF_UE1 + COEFF_UE2) + ) != float(driver.find_element_by_class_name("rcp_moy").text): + moyenneBonne = False + elif numeroEtu == 1: + if ( + ( + float(MOY_UE1) * COEFF_UE1 + + (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2 + ) + / (COEFF_UE1 + COEFF_UE2) + ) != float(driver.find_element_by_class_name("rcp_moy").text): + moyenneBonne = False + numeroEtu = numeroEtu + 1 + self.assertTrue(moyenneBonne) + + def test_060_note_absent(self): + global listeEtudiant + global COEFF_UE1 + global COEFF_UE2 + global URL_SEMESTRE + 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("ATT") + 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") + 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_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 + print(moyenneBonne) + print(affichageMoyenne) + self.assertTrue(moyenneBonne and affichageMoyenne) + + # def test_070_note_attente(self): + # def test_080_note_excuse(self): def tearDown(self): self.driver.close()