From 2519454dae7b8122557258fc3fc848ba285caf14 Mon Sep 17 00:00:00 2001 From: aurelien Date: Thu, 24 Jun 2021 15:04:22 +0200 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20des=20rapports=20&=20cr?= =?UTF-8?q?=C3=A9ation=20de=20scripts=20pour=20l'ind=C3=A9pendance=20des?= =?UTF-8?q?=20jeux=20de=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01_creation_departement_test.py | 29 ++++--- 02_creation_formation_test.py | 41 +++------ 03_etudiant_test.py | 21 +++-- 04_creation_absence_test.py | 20 +++-- 05_saisie_note_test.py | 20 +++-- 06_test_moyenne.py | 28 ++++--- 07_test_admission.py | 20 +++-- ...©ation dĂ©partement_2021-06-24_15-02-41.html | 84 +++++++++++++++++++ createDepartement.py | 8 ++ creationSiteDepartement.py | 53 ++++++++++++ deleteDepartement.py | 8 ++ index.html | 0 lancement_de_tout_les_tests.sh | 13 ++- readme.md | 4 + suppressionSiteDepartement.py | 50 +++++++++++ 15 files changed, 315 insertions(+), 84 deletions(-) create mode 100644 ResultatTest/01_crĂ©ation dĂ©partement_2021-06-24_15-02-41.html create mode 100644 createDepartement.py create mode 100644 creationSiteDepartement.py create mode 100644 deleteDepartement.py create mode 100644 index.html create mode 100644 suppressionSiteDepartement.py diff --git a/01_creation_departement_test.py b/01_creation_departement_test.py index 6093b7c..39a39f4 100644 --- a/01_creation_departement_test.py +++ b/01_creation_departement_test.py @@ -3,6 +3,10 @@ import unittest import time import subprocess import HtmlTestRunner +import createDepartement +import creationSiteDepartement +import deleteDepartement +import suppressionSiteDepartement from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, @@ -66,25 +70,20 @@ class PythonOrgSearch(unittest.TestCase): driver.find_element_by_id("DeleteDept").submit() driver.get(BASE_URL) self.assertTrue(NOM_DPT not in driver.page_source) - cmdProcess = [ - "./scriptDeleteDepartement.sh", - LINK_SCODOC_SERVER, - NOM_DPT, - ] - process = subprocess.Popen(cmdProcess) - process.wait() # ferme la fenetre Ă  chaque fin de test - def tearDown(self): self.driver.close() 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() - unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output")) \ No newline at end of file + deleteDepartement.main() + createDepartement.main() + suppressionSiteDepartement.main() + unittest.main( + testRunner=HtmlTestRunner.HTMLTestRunner( + report_name="01_crĂ©ation dĂ©partement", + output="./ResultatTest", + combine_reports=True, + ) + ) diff --git a/02_creation_formation_test.py b/02_creation_formation_test.py index 5288d9f..08eedf6 100644 --- a/02_creation_formation_test.py +++ b/02_creation_formation_test.py @@ -3,6 +3,9 @@ import unittest import time import subprocess import HtmlTestRunner +import createDepartement +import creationSiteDepartement +import deleteDepartement from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, @@ -251,32 +254,14 @@ 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() - if NAVIGATEUR == "firefox": - driver = webdriver.Firefox() - else: - driver = webdriver.Chrome() - driver.get( - "https://" - + SCODOC_ADMIN_ID - + ":" - + SCODOC_ADMIN_PASS - + "@" - + BASE_NOT_SECURED_URL - + "force_admin_authentication" + deleteDepartement.main() + createDepartement.main() + creationSiteDepartement.main() + + unittest.main( + testRunner=HtmlTestRunner.HTMLTestRunner( + report_name="02_creation_formation_test", + output="./ResultatTest", + combine_reports=True, + ) ) - 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() - time.sleep(1) - driver.close() - unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output")) diff --git a/03_etudiant_test.py b/03_etudiant_test.py index d602d25..93b9a2c 100644 --- a/03_etudiant_test.py +++ b/03_etudiant_test.py @@ -2,6 +2,9 @@ import unittest import time import HtmlTestRunner import subprocess +import createDepartement +import creationSiteDepartement +import deleteDepartement from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, @@ -137,7 +140,6 @@ class PythonOrgSearch(unittest.TestCase): 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 @@ -182,12 +184,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() + deleteDepartement.main() + createDepartement.main() + creationSiteDepartement.main() cmdProcess = [ "./scriptExecution.sh", LINK_SCODOC_SERVER, @@ -196,4 +195,10 @@ if __name__ == "__main__": ] process = subprocess.Popen(cmdProcess) process.wait() - unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output")) \ No newline at end of file + unittest.main( + testRunner=HtmlTestRunner.HTMLTestRunner( + report_name="03_Etudiant_test", + output="./ResultatTest", + combine_reports=True, + ) + ) diff --git a/04_creation_absence_test.py b/04_creation_absence_test.py index 36c7bea..248a61d 100644 --- a/04_creation_absence_test.py +++ b/04_creation_absence_test.py @@ -3,6 +3,9 @@ import time import urllib.parse as urlparse import subprocess import HtmlTestRunner +import createDepartement +import creationSiteDepartement +import deleteDepartement from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, @@ -151,12 +154,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() + deleteDepartement.main() + createDepartement.main() + creationSiteDepartement.main() cmdProcess = [ "./scriptExecution.sh", LINK_SCODOC_SERVER, @@ -165,4 +165,10 @@ if __name__ == "__main__": ] process = subprocess.Popen(cmdProcess) process.wait() - unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output")) \ No newline at end of file + unittest.main( + testRunner=HtmlTestRunner.HTMLTestRunner( + report_name="04_Absences tests", + output="./ResultatTest", + combine_reports=True, + ) + ) diff --git a/05_saisie_note_test.py b/05_saisie_note_test.py index 93667ac..848f9b9 100644 --- a/05_saisie_note_test.py +++ b/05_saisie_note_test.py @@ -3,6 +3,9 @@ import time import subprocess import urllib.parse as urlparse import HtmlTestRunner +import createDepartement +import creationSiteDepartement +import deleteDepartement from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, @@ -334,12 +337,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() + deleteDepartement.main() + createDepartement.main() + creationSiteDepartement.main() cmdProcess = [ "./scriptExecution.sh", LINK_SCODOC_SERVER, @@ -396,4 +396,10 @@ if __name__ == "__main__": driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("utilisateurs_Vue").click() driver.close() - unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output")) + unittest.main( + testRunner=HtmlTestRunner.HTMLTestRunner( + report_name="05_Saisie note tests", + output="./ResultatTest", + combine_reports=True, + ) + ) diff --git a/06_test_moyenne.py b/06_test_moyenne.py index 88e3042..72bddd9 100644 --- a/06_test_moyenne.py +++ b/06_test_moyenne.py @@ -3,6 +3,9 @@ import time import subprocess import urllib.parse as urlparse import HtmlTestRunner +import createDepartement +import creationSiteDepartement +import deleteDepartement from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, @@ -84,7 +87,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) @@ -335,12 +338,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( + # 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,12 +434,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() + deleteDepartement.main() + createDepartement.main() + creationSiteDepartement.main() cmdProcess = [ "./scriptExecution.sh", LINK_SCODOC_SERVER, @@ -445,4 +445,10 @@ if __name__ == "__main__": ] process = subprocess.Popen(cmdProcess) process.wait() - unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output")) \ No newline at end of file + unittest.main( + testRunner=HtmlTestRunner.HTMLTestRunner( + report_name="06_Moyenne tests", + output="./ResultatTest", + combine_reports=True, + ) + ) diff --git a/07_test_admission.py b/07_test_admission.py index 314b19e..0daf547 100644 --- a/07_test_admission.py +++ b/07_test_admission.py @@ -3,6 +3,9 @@ import time import subprocess import urllib.parse as urlparse import HtmlTestRunner +import createDepartement +import creationSiteDepartement +import deleteDepartement from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, @@ -219,12 +222,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() + deleteDepartement.main() + createDepartement.main() + creationSiteDepartement.main() cmdProcess = [ "./scriptExecution.sh", LINK_SCODOC_SERVER, @@ -233,4 +233,10 @@ if __name__ == "__main__": ] process = subprocess.Popen(cmdProcess) process.wait() - unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output")) \ No newline at end of file + unittest.main( + testRunner=HtmlTestRunner.HTMLTestRunner( + report_name="07_Admission et passages tests", + output="./ResultatTest", + combine_reports=True, + ) + ) diff --git a/ResultatTest/01_crĂ©ation dĂ©partement_2021-06-24_15-02-41.html b/ResultatTest/01_crĂ©ation dĂ©partement_2021-06-24_15-02-41.html new file mode 100644 index 0000000..2ef3d2d --- /dev/null +++ b/ResultatTest/01_crĂ©ation dĂ©partement_2021-06-24_15-02-41.html @@ -0,0 +1,84 @@ + + + + Unittest Results + + + + + +
+
+
+

Unittest Results

+

Start Time: 2021-06-24 15:02:41

+

Duration: 39.96 s

+

Summary: Total: 3, Pass: 3

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
__main__.PythonOrgSearchStatus
test_connexion_admin + Pass + +
test_create_departement + Pass + +
test_delete_departement + Pass + +
+ Total: 3, Pass: 3 -- Duration: 39.96 s +
+
+
+
+ + + + index.html \ No newline at end of file diff --git a/readme.md b/readme.md index 628faf1..4e82f7a 100644 --- a/readme.md +++ b/readme.md @@ -74,6 +74,10 @@ Pour lancer les tests, assurez vous d'avoir une connexion possible avec votre se >python3 01_creation_departement_test.py +Alternativement vous pouvez lancer l'ensemble des tests avec la commande + +>./lancement_de_tout_les_tests.sh + ###Resultats des tests ###TODO diff --git a/suppressionSiteDepartement.py b/suppressionSiteDepartement.py new file mode 100644 index 0000000..12d79e1 --- /dev/null +++ b/suppressionSiteDepartement.py @@ -0,0 +1,50 @@ +# coding: utf8 +import unittest +import time +import subprocess +import HtmlTestRunner +from setting import ( + SCODOC_ADMIN_ID, + SCODOC_ADMIN_PASS, + BASE_URL, + NOM_DPT, + LINK_SCODOC_SERVER, + BASE_NOT_SECURED_URL, + NAVIGATEUR, +) +from selenium import webdriver +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import Select, WebDriverWait +from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.support.ui import Select +from selenium.webdriver.support.select import Select + +URL = BASE_URL + NOM_DPT + "/Scolarite" + +ACRONYME_FORMATION = "FormationTEST" + + +def main(): + if NAVIGATEUR == "firefox": + driver = webdriver.Firefox() + else: + driver = webdriver.Chrome() + 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) + try: + select = Select(driver.find_element_by_id("DeleteDept")) + select.select_by_visible_text(NOM_DPT) + driver.find_element_by_id("DeleteDept").submit() + driver.close() + except NoSuchElementException: + driver.close() \ No newline at end of file