From 545be29ac69a9151e9e58b32ef30ac7e9556a17b Mon Sep 17 00:00:00 2001 From: Aurelien PLANCKE Date: Mon, 21 Jun 2021 15:19:30 +0200 Subject: [PATCH] =?UTF-8?q?fix=20bug=20sur=20diff=C3=A9rents=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .envmodel | 4 +-- 01_creation_departement_test.py | 16 +++++++----- 02_creation_formation_test.py | 39 +++++++++++++++++++++-------- 03_etudiant_test.py | 13 ++++++++-- 04_creation_absence_test.py | 3 +++ 05_saisie_note_test.py | 13 +++++++--- 06_test_moyenne.py | 18 +++++++------ 07_test_admission.py | 3 +++ __pycache__/setting.cpython-37.pyc | Bin 697 -> 707 bytes 9 files changed, 77 insertions(+), 32 deletions(-) diff --git a/.envmodel b/.envmodel index 15ce929..cee0ad8 100644 --- a/.envmodel +++ b/.envmodel @@ -3,9 +3,9 @@ NOM_DPT = "test01" SCODOC_ADMIN_ID = "admin_id" SCODOC_ADMIN_PASS = "admin_password" SCODOC_ENS_ID = "enseignant_id" -SCODOC_ENS_PASS = "enseignant_password" +SCODOC_ENS_PASS = "enseignant_password@10" SCODOC_CHEF_ID = "chef_id" -SCODOC_CHEF_PASS = "password" +SCODOC_CHEF_PASS = "p@ssword42@" LINK_SCODOC_SERVER = "root@ssh_server_scodoc" BASE_NOT_SECURED_URL = "scodoc-dev-iutinfo.univ-lille.fr/" NAVIGATEUR = "firefox" \ No newline at end of file diff --git a/01_creation_departement_test.py b/01_creation_departement_test.py index 5785951..dbffb79 100644 --- a/01_creation_departement_test.py +++ b/01_creation_departement_test.py @@ -46,13 +46,14 @@ class PythonOrgSearch(unittest.TestCase): def test_create_departement(self): driver = self.driver driver.get(BASE_URL + "/scodoc_admin") + time.sleep(2) select = Select(driver.find_element_by_id("CreateDept")) - select.select_by_visible_text("TESTCREATEDPT") + select.select_by_visible_text(NOM_DPT) driver.find_element_by_name("DeptId").submit() time.sleep(1) driver.find_element_by_id("tf_submit").click() driver.get(BASE_URL) - self.assertTrue("TESTCREATEDPT" in driver.page_source) + self.assertTrue(NOM_DPT in driver.page_source) # Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données # @expected : Le département n'apparait plus sur la page d'accueil @@ -60,14 +61,14 @@ class PythonOrgSearch(unittest.TestCase): driver = self.driver driver.get(BASE_URL + "/scodoc_admin") select = Select(driver.find_element_by_id("DeleteDept")) - select.select_by_visible_text("TESTCREATEDPT") + select.select_by_visible_text(NOM_DPT) driver.find_element_by_id("DeleteDept").submit() driver.get(BASE_URL) - self.assertTrue("TESTCREATEDPT" not in driver.page_source) + self.assertTrue(NOM_DPT not in driver.page_source) cmdProcess = [ "./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, - "TESTCREATEDPT", + NOM_DPT, ] process = subprocess.Popen(cmdProcess) process.wait() @@ -79,7 +80,10 @@ class PythonOrgSearch(unittest.TestCase): if __name__ == "__main__": - cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, "TESTCREATEDPT"] + cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] + process = subprocess.Popen(cmdProcess) + process.wait() + cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] process = subprocess.Popen(cmdProcess) process.wait() unittest.main() \ No newline at end of file diff --git a/02_creation_formation_test.py b/02_creation_formation_test.py index 2ac140a..d7f60a0 100644 --- a/02_creation_formation_test.py +++ b/02_creation_formation_test.py @@ -131,8 +131,6 @@ class PythonOrgSearch(unittest.TestCase): ) driver.get(URL) - self.assertTrue((NOM_DPT.upper() + "-" + "DUT" + "--") in driver.page_source) - # Test : Ajout d'une matière dans la formation # @Expected : La matière est créée et elle apparait désormais sur la page de détail de la formation def test_015_ajout_matiere(self): @@ -231,11 +229,12 @@ class PythonOrgSearch(unittest.TestCase): "//input[@value='Supprimer cette formation']" ).click() driver.get(URL) - try: - driver.find_element_by_id(idButtonDelete) - self.assertTrue(False) - except NoSuchElementException: - self.assertTrue(True) + formations = driver.find_elements_by_class_name("version") + formationDelete = True + for formation in formations: + if "1" in formation.text: + formationDelete = False + self.assertTrue(formationDelete) # def test_create_module(self): # driver = self.driver @@ -247,10 +246,28 @@ class PythonOrgSearch(unittest.TestCase): if __name__ == "__main__": - cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] - process = subprocess.Popen(cmdProcess) - process.wait() - unittest.main() cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] process = subprocess.Popen(cmdProcess) process.wait() + cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] + process = subprocess.Popen(cmdProcess) + process.wait() + #driver = webdriver.Firefox() + #driver.get( + # "https://" + # + SCODOC_ADMIN_ID + # + ":" + # + SCODOC_ADMIN_PASS + # + "@" + # + BASE_NOT_SECURED_URL + # + "force_admin_authentication" + # ) + #driver.get(BASE_URL + "/scodoc_admin") + #time.sleep(2) + #select = Select(driver.find_element_by_id("CreateDept")) + #select.select_by_visible_text(NOM_DPT) + #driver.find_element_by_name("DeptId").submit() + #time.sleep(1) + #driver.find_element_by_id("tf_submit").click() + #driver.close() + unittest.main() diff --git a/03_etudiant_test.py b/03_etudiant_test.py index 6a0ea67..9d45b13 100644 --- a/03_etudiant_test.py +++ b/03_etudiant_test.py @@ -129,8 +129,14 @@ class PythonOrgSearch(unittest.TestCase): self.assertFalse(True) semestres[0].click() driver.find_element_by_xpath("//input[@value='Inscrire']").click() - self.assertTrue("inscrit" in driver.page_source) - time.sleep(1) + time.sleep(2) + boutonInscrireIsNotPresent = False + try: + driver.find_element_by_partial_link_text("inscrire") + except: + boutonInscrireIsNotPresent = True + self.assertTrue(boutonInscrireIsNotPresent) + # Test Supprime un étudiant # @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait @@ -175,6 +181,9 @@ class PythonOrgSearch(unittest.TestCase): if __name__ == "__main__": + cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] + process = subprocess.Popen(cmdProcess) + process.wait() cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] process = subprocess.Popen(cmdProcess) process.wait() diff --git a/04_creation_absence_test.py b/04_creation_absence_test.py index d80cdc8..2e0b3ae 100644 --- a/04_creation_absence_test.py +++ b/04_creation_absence_test.py @@ -150,6 +150,9 @@ class PythonOrgSearch(unittest.TestCase): if __name__ == "__main__": + cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] + process = subprocess.Popen(cmdProcess) + process.wait() cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] process = subprocess.Popen(cmdProcess) process.wait() diff --git a/05_saisie_note_test.py b/05_saisie_note_test.py index 20c865b..1ac27bd 100644 --- a/05_saisie_note_test.py +++ b/05_saisie_note_test.py @@ -57,6 +57,7 @@ class PythonOrgSearch(unittest.TestCase): self.driver.find_element_by_name("__ac_password").send_keys( SCODOC_CHEF_PASS ) + time.sleep(3) self.driver.find_element_by_name("submit").click() elif isEns: self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_ENS_ID) @@ -131,6 +132,7 @@ class PythonOrgSearch(unittest.TestCase): driver = self.driver global URL_MATIERE driver.get(URL_MATIERE) + time.sleep(2) driver.find_element_by_partial_link_text("modifier les enseignants").click() time.sleep(1) constructIDEns = ( @@ -155,6 +157,7 @@ class PythonOrgSearch(unittest.TestCase): def test_040_creation_interrogation(self): descriptionInterrogation = "Interrogation numero 2" driver = self.driver + global URL_MATIERE driver.get( "https://" + SCODOC_ADMIN_ID @@ -298,6 +301,7 @@ class PythonOrgSearch(unittest.TestCase): time.sleep(1) time.sleep(1) driver.get(URL_MATIERE) + time.sleep(5) self.assertTrue(SCODOC_ENS_ID not in driver.page_source) # Test : Suppresion du reste des interrogations sans notes @@ -329,6 +333,9 @@ if __name__ == "__main__": driver = webdriver.Firefox() else: driver = webdriver.Chrome() + cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] + process = subprocess.Popen(cmdProcess) + process.wait() cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] process = subprocess.Popen(cmdProcess) process.wait() @@ -362,7 +369,7 @@ if __name__ == "__main__": if nom.text.lower() == SCODOC_ENS_ID.lower(): ensCree = True if not chefCree: - time.sleep(5) + time.sleep(2) constructValue = "Ens" + NOM_DPT driver.find_element_by_id("creer_Utilisateur").click() driver.find_element_by_id("tf_nom").send_keys(SCODOC_CHEF_ID) @@ -371,11 +378,11 @@ if __name__ == "__main__": driver.find_element_by_id("tf_passwd").send_keys(SCODOC_CHEF_PASS) driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_CHEF_PASS) driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click() - driver.find_element_by_xpath("//input[@value='force:list']").click() + driver.find_element_by_xpath("//input[@name='force:list']").click() driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("utilisateurs_Vue").click() if not ensCree: - time.sleep(5) + time.sleep(2) constructValue = "Ens" + NOM_DPT driver.find_element_by_id("creer_Utilisateur").click() driver.find_element_by_id("tf_nom").send_keys(SCODOC_ENS_ID) diff --git a/06_test_moyenne.py b/06_test_moyenne.py index 16de343..407dd23 100644 --- a/06_test_moyenne.py +++ b/06_test_moyenne.py @@ -83,7 +83,7 @@ class PythonOrgSearch(unittest.TestCase): self.wait.until(EC.url_changes(URL)) driver.get(URL_SEMESTRE) noteBonne = True - print(listeEtudiant) + #print(listeEtudiant) for etudiant in listeEtudiant: searchBar = driver.find_element_by_id("in-expnom") searchBar.send_keys(etudiant) @@ -262,7 +262,6 @@ class PythonOrgSearch(unittest.TestCase): numeroEtu = 0 moyenneBonne = True affichageMoyenne = True - ueList = [] for etudiant in listeEtudiant: URL = driver.current_url searchBar = driver.find_element_by_id("in-expnom") @@ -335,12 +334,12 @@ class PythonOrgSearch(unittest.TestCase): 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" - ) - ) + #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" ): @@ -431,6 +430,9 @@ class PythonOrgSearch(unittest.TestCase): if __name__ == "__main__": + cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] + process = subprocess.Popen(cmdProcess) + process.wait() cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] process = subprocess.Popen(cmdProcess) process.wait() diff --git a/07_test_admission.py b/07_test_admission.py index 2b6e77f..097f7ad 100644 --- a/07_test_admission.py +++ b/07_test_admission.py @@ -218,6 +218,9 @@ class PythonOrgSearch(unittest.TestCase): if __name__ == "__main__": + cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] + process = subprocess.Popen(cmdProcess) + process.wait() cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] process = subprocess.Popen(cmdProcess) process.wait() diff --git a/__pycache__/setting.cpython-37.pyc b/__pycache__/setting.cpython-37.pyc index 9ff96bd99f61846960bca24820308cab131dca5f..c79d961097f49fae0b433e2a2fc0f5484c3c706b 100644 GIT binary patch delta 72 zcmdnVdYF~liI