From 43a1d4b327116a948c505351b86657214cdd9b94 Mon Sep 17 00:00:00 2001 From: aurelien Date: Thu, 3 Jun 2021 16:13:17 +0200 Subject: [PATCH] ajout role de connexion --- 05_saisie_note_test.py | 80 +++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/05_saisie_note_test.py b/05_saisie_note_test.py index c2594bb..c7e1571 100644 --- a/05_saisie_note_test.py +++ b/05_saisie_note_test.py @@ -27,6 +27,9 @@ URL_MATIERE = "" URL_SEMESTRE = "" URL = BASE_URL + NOM_DPT + "/Scolarite" PRENOM_ENS = "Ens" +isAdmin = True +isChef = False +isEns = False # Prérequis class PythonOrgSearch(unittest.TestCase): # Permet de se connecter et se remettre sur la page d'accueil avant chaque test @@ -36,16 +39,26 @@ class PythonOrgSearch(unittest.TestCase): else: self.driver = webdriver.Chrome() self.wait = WebDriverWait(self.driver, 10) - self.driver.get( - "https://" - + SCODOC_ADMIN_ID - + ":" - + SCODOC_ADMIN_PASS - + "@" - + BASE_NOT_SECURED_URL - + "force_admin_authentication" - ) - self.wait = WebDriverWait(self.driver, 10) + if isAdmin: + self.driver.get( + "https://" + + SCODOC_ADMIN_ID + + ":" + + SCODOC_ADMIN_PASS + + "@" + + BASE_NOT_SECURED_URL + + "force_admin_authentication" + ) + else: + self.driver.get(BASE_URL + NOM_DPT + "/Scolarite") + if isChef: + driver.find_element_by_name("__ac_name").send_keys(SCODOC_CHEF_ID) + driver.find_element_by_naùe("__ac_password").send_keys(SCODOC_CHEF_PASS) + driver.find_element_by_id("submit").click() + elif isEns: + driver.find_element_by_name("__ac_name").send_keys(SCODOC_ENS_ID) + driver.find_element_by_naùe("__ac_password").send_keys(SCODOC_ENS_PASS) + driver.find_element_by_id("submit").click() # self.driver.get(self.url) # self.driver.find_element_by_id("name").send_keys(SCODOC_ENS_ID) # self.driver.find_element_by_id("password").send_keys(SCODOC_ENS_PASS) @@ -104,14 +117,11 @@ class PythonOrgSearch(unittest.TestCase): + SCODOC_ENS_ID.lower() + ")" ) - print(constructIDEns) driver.find_element_by_id("ens_id").send_keys(constructIDEns) - time.sleep(5) - driver.find_element_by_id("tf_submit").click() time.sleep(1) driver.get(URL_MATIERE) - self.assertTrue("Enseignants du" in driver.page_source) + # self.assertTrue("Enseignants du" in driver.page_source) self.assertTrue(SCODOC_ENS_ID in driver.page_source) # Test : Création d'une interrogation en tant que chef des études @@ -142,6 +152,10 @@ class PythonOrgSearch(unittest.TestCase): driver.find_element_by_id("tf_coefficient").send_keys("2") driver.find_element_by_id("tf_submit").click() time.sleep(1) + global isAdmin + isAdmin = False + global isEns + isEns = True self.assertTrue(descriptionInterrogation in driver.page_source) # Test Vérifie si une interrogation existe sur un module @@ -161,8 +175,6 @@ class PythonOrgSearch(unittest.TestCase): driver = self.driver global URL_MATIERE driver.get(URL_MATIERE) - print(URL_MATIERE) - time.sleep(10) driver.find_element_by_class_name("notes_img").click() time.sleep(1) element = driver.find_element_by_class_name("note") @@ -186,14 +198,10 @@ class PythonOrgSearch(unittest.TestCase): if element.get_attribute("value") == "": element.send_keys(15) driver.find_element_by_id("formnotes_submit").click() - driver.get( - "https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/AurelienUS/Scolarite/search_etud_in_dept" - ) - element = driver.find_element_by_name("expnom") - element.send_keys("UneEtudianteEnS4") + driver.find_element_by_id("in-expnom").sendKeys("SEMESTRE47") element.submit() time.sleep(5) - self.assertTrue("12" in driver.find_element_by_class_name("ue").text) + self.assertTrue("12" in driver.find_element_by_id("rcp_moy").text) # Test : Suppresion des notes pour tout les étudiants concernés dans une interrogation # @expected : La moyenne ne s'affiche plus, "afficher" disparait de la page d'information de l'interrogation @@ -219,15 +227,9 @@ class PythonOrgSearch(unittest.TestCase): # Test : SUppression d'une interrogation par le chef des études # @expected : L'interrogation n'apparait plus sur le module, les notes sont supprimées également def test_090_suppresion_interrogation(self): + global URL_MATIERE descriptionInterrogation = "Interrogation à supprimer" driver = self.driver - driver.get(BASE_URL) - driver.find_element_by_link_text("déconnecter").click() - driver.get(BASE_URL) - driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID) - driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS) - driver.find_element_by_id("submit").click() - global URL_MATIERE driver.get(URL_MATIERE) time.sleep(1) driver.find_element_by_link_text("Créer nouvelle évaluation").click() @@ -240,19 +242,16 @@ class PythonOrgSearch(unittest.TestCase): driver.find_element_by_class_name("delete_img").click() time.sleep(1) driver.find_element_by_id("tf_submit").click() + global isAdmin + isAdmin = True + global isEns + isEns = False self.assertFalse(descriptionInterrogation in driver.page_source) # Test : Suppression d'un enseignant responsable d'un module # @expected : L'enseignant n'apparait plus comme responsable dans ce module def test_200_suppression_enseignant_sur_module(self): driver = self.driver - self.driver.get( - "https://" - + SCODOC_ADMIN_ID - + ":" - + SCODOC_ADMIN_PASS - + "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication" - ) driver.get(URL_MATIERE) time.sleep(1) driver.find_element_by_partial_link_text("modifier les enseignants").click() @@ -262,20 +261,13 @@ class PythonOrgSearch(unittest.TestCase): element.click() time.sleep(1) time.sleep(1) + driver.get(URL_MATIERE) self.assertTrue(SCODOC_ENS_ID not in driver.page_source) # Test : Suppresion du reste des interrogations sans notes # @expected Tout les interrogation sans notes sont supprimées def test_910_suppresion_interrogation_restante(self): driver = self.driver - self.driver.get( - "https://" - + SCODOC_ADMIN_ID - + ":" - + SCODOC_ADMIN_PASS - + "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication" - ) - driver.get(URL_MATIERE) time.sleep(1) elements = driver.find_elements_by_class_name("delete_img")