2021-04-21 13:28:58 +02:00
|
|
|
import unittest
|
|
|
|
import time
|
|
|
|
import urllib.parse as urlparse
|
2021-05-28 20:41:04 +02:00
|
|
|
import subprocess
|
2021-06-23 14:27:05 +02:00
|
|
|
import HtmlTestRunner
|
2021-05-28 20:41:04 +02:00
|
|
|
from setting import (
|
|
|
|
SCODOC_ADMIN_ID,
|
|
|
|
SCODOC_ADMIN_PASS,
|
|
|
|
BASE_URL,
|
|
|
|
NOM_DPT,
|
|
|
|
LINK_SCODOC_SERVER,
|
|
|
|
BASE_NOT_SECURED_URL,
|
2021-06-01 16:50:45 +02:00
|
|
|
NAVIGATEUR,
|
2021-05-28 20:41:04 +02:00
|
|
|
)
|
2021-04-21 13:28:58 +02:00
|
|
|
from urllib.parse import parse_qs
|
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
|
|
from selenium.webdriver.support.ui import Select, WebDriverWait
|
|
|
|
from selenium.webdriver.support.select import Select
|
|
|
|
|
2021-05-27 16:36:42 +02:00
|
|
|
URL = BASE_URL + NOM_DPT + "/Scolarite"
|
2021-06-01 16:50:45 +02:00
|
|
|
NOM_ETU = "Semestre11"
|
2021-05-28 20:41:04 +02:00
|
|
|
PRENOM_ETU = "EtudiantNumero1"
|
2021-06-01 16:50:45 +02:00
|
|
|
dateDebutAbsenceNonJustifiee = "31/05/2021"
|
2021-06-07 16:48:11 +02:00
|
|
|
dateDebutAbsenceJustifiee = "25/05/2021"
|
2021-04-21 13:28:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PythonOrgSearch(unittest.TestCase):
|
|
|
|
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
|
|
|
def setUp(self):
|
2021-06-01 16:50:45 +02:00
|
|
|
if NAVIGATEUR == "firefox":
|
|
|
|
self.driver = webdriver.Firefox()
|
|
|
|
else:
|
|
|
|
self.driver = webdriver.Chrome()
|
2021-04-21 13:28:58 +02:00
|
|
|
self.wait = WebDriverWait(self.driver, 10)
|
|
|
|
self.driver.get(
|
|
|
|
"https://"
|
|
|
|
+ SCODOC_ADMIN_ID
|
|
|
|
+ ":"
|
|
|
|
+ SCODOC_ADMIN_PASS
|
2021-05-27 16:36:42 +02:00
|
|
|
+ "@"
|
|
|
|
+ BASE_NOT_SECURED_URL
|
|
|
|
+ "force_admin_authentication"
|
2021-04-21 13:28:58 +02:00
|
|
|
)
|
2021-05-27 16:36:42 +02:00
|
|
|
global URL
|
|
|
|
self.driver.get(URL)
|
2021-05-28 20:41:04 +02:00
|
|
|
|
|
|
|
def test_010_trouver_etudiant(self):
|
2021-04-21 13:28:58 +02:00
|
|
|
driver = self.driver
|
2021-05-28 20:41:04 +02:00
|
|
|
global URL
|
|
|
|
self.driver.get(BASE_URL + NOM_DPT + "/Scolarite")
|
|
|
|
element = self.driver.find_element_by_id("in-expnom")
|
|
|
|
element.send_keys(NOM_ETU)
|
2021-04-21 13:28:58 +02:00
|
|
|
element.submit()
|
2021-05-28 20:41:04 +02:00
|
|
|
self.wait.until(EC.url_changes(URL))
|
|
|
|
URL = driver.current_url
|
2021-06-01 16:50:45 +02:00
|
|
|
self.assertTrue(NOM_ETU.upper() in driver.page_source)
|
2021-04-21 13:28:58 +02:00
|
|
|
|
2021-05-06 08:32:30 +02:00
|
|
|
# Test : creer une absence non justifiée
|
|
|
|
# @expected : La fiche étudiante est incrémentée avec le nombre d'absence injustifiée correspondant
|
2021-05-28 20:41:04 +02:00
|
|
|
def test_020_ajout_absence_non_justifiee(self):
|
2021-04-21 13:28:58 +02:00
|
|
|
driver = self.driver
|
2021-05-28 20:41:04 +02:00
|
|
|
global URL
|
2021-06-01 16:50:45 +02:00
|
|
|
driver.find_element_by_id("ajout_Absence").click()
|
2021-04-21 13:28:58 +02:00
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
|
|
|
|
driver.find_element_by_id("butsubmit").submit()
|
|
|
|
time.sleep(1)
|
|
|
|
self.assertTrue(
|
|
|
|
"Ajout de 2 absences <b>NON justifiées</b>" in driver.page_source
|
|
|
|
)
|
|
|
|
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Liste").click()
|
|
|
|
self.assertTrue("2 absences non justifiées:" in driver.page_source)
|
|
|
|
|
|
|
|
# def test_modification_liste_absence_non_justifiee(self):
|
|
|
|
# driver = self.driver
|
|
|
|
# driver.find_element_by_link_text("Liste").click()
|
|
|
|
# self.assertTrue("2 absences non justifiées:" in driver.page_source)
|
|
|
|
|
2021-05-06 08:32:30 +02:00
|
|
|
# Test pour ajouter deux absences justifiées
|
|
|
|
# @expected : La fiche d'information de l'étudiant concerné à son compteur d'absence augmenté de 2
|
2021-06-01 16:50:45 +02:00
|
|
|
def test_021_ajout_absence_justifiee(self):
|
2021-04-21 13:28:58 +02:00
|
|
|
driver = self.driver
|
2021-05-28 20:41:04 +02:00
|
|
|
global URL
|
2021-06-01 16:50:45 +02:00
|
|
|
driver.find_element_by_id("ajout_Absence").click()
|
2021-04-21 13:28:58 +02:00
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
|
|
|
driver.find_element_by_name("estjust").click()
|
|
|
|
driver.find_element_by_id("butsubmit").submit()
|
2021-06-07 16:48:11 +02:00
|
|
|
time.sleep(1)
|
2021-04-21 13:28:58 +02:00
|
|
|
self.assertTrue("Ajout de 2 absences <b>justifiées</b>" in driver.page_source)
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Liste").click()
|
|
|
|
self.assertTrue("2 absences justifiées:" in driver.page_source)
|
|
|
|
|
|
|
|
# def test_modification_liste_absence_justifiee(self):
|
|
|
|
# driver = self.driver
|
|
|
|
# driver.find_element_by_link_text("Liste").click()
|
|
|
|
# self.assertTrue("2 absences justifiées:" in driver.page_source)
|
|
|
|
|
2021-05-06 08:32:30 +02:00
|
|
|
# Test Justification d'une absence non justifiée
|
|
|
|
# @expected : Le champs des absences non justifiées diminue et celui des justifiés augmente du nombre d'absence
|
2021-06-01 16:50:45 +02:00
|
|
|
def test_022_ajout_justification(self):
|
2021-04-21 13:28:58 +02:00
|
|
|
driver = self.driver
|
2021-05-28 20:41:04 +02:00
|
|
|
global URL
|
2021-06-01 16:50:45 +02:00
|
|
|
driver.find_element_by_id("justifier_Absence").click()
|
2021-04-21 13:28:58 +02:00
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
|
|
|
driver.find_element_by_name("description").send_keys("Un test selenium")
|
|
|
|
driver.find_element_by_xpath("//input[@value='Envoyer']").click()
|
2021-06-01 16:50:45 +02:00
|
|
|
self.wait.until(EC.url_changes(URL))
|
2021-04-21 13:28:58 +02:00
|
|
|
self.assertTrue("Ajout de 2 <b>justifications</b>" in driver.page_source)
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Liste").click()
|
|
|
|
self.assertTrue("2 absences justifiées:" in driver.page_source)
|
|
|
|
self.assertTrue("absences non justifiées:" in driver.page_source)
|
|
|
|
|
|
|
|
# def test_modification_liste_ajout_justification(self):
|
|
|
|
# driver = self.driver
|
|
|
|
# driver.find_element_by_link_text("Liste").click()
|
|
|
|
# self.assertTrue("4 absences justifiées:" in driver.page_source)
|
|
|
|
# self.assertTrue("absences non justifiées:" not in driver.page_source)
|
|
|
|
|
2021-05-06 08:32:30 +02:00
|
|
|
# Test Suppression des absences pour un élève
|
|
|
|
# @expected : Les compteurs d'absences sont remplacés par "Pas d'absences"
|
2021-06-01 16:50:45 +02:00
|
|
|
def test_024_supprimer_absence(self):
|
2021-04-21 13:28:58 +02:00
|
|
|
driver = self.driver
|
2021-05-28 20:41:04 +02:00
|
|
|
global URL
|
2021-06-01 16:50:45 +02:00
|
|
|
driver.find_element_by_id("supprimer_Absence").click()
|
2021-04-21 13:28:58 +02:00
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
|
|
|
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
2021-06-01 16:50:45 +02:00
|
|
|
self.wait.until(EC.url_changes(URL))
|
2021-04-21 13:28:58 +02:00
|
|
|
self.assertTrue("Annulation sur 2 demi-journées " in driver.page_source)
|
2021-06-07 16:48:11 +02:00
|
|
|
driver.find_element_by_id("supprimer_Absence").click()
|
2021-04-21 13:28:58 +02:00
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
|
|
|
|
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
2021-06-01 16:50:45 +02:00
|
|
|
self.wait.until(EC.url_changes(URL))
|
|
|
|
driver.find_element_by_id("afficher_Liste_Absence").click()
|
2021-04-21 13:28:58 +02:00
|
|
|
self.assertTrue("Pas d'absences justifiées" in driver.page_source)
|
|
|
|
self.assertTrue("Pas d'absences non justifiées" in driver.page_source)
|
|
|
|
|
|
|
|
# def test_modification_liste_supression_absence(self):
|
|
|
|
# driver = self.driver
|
|
|
|
# driver.find_element_by_link_text("Liste").click()
|
|
|
|
# self.assertTrue("2 absences justifiées:" in driver.page_source)
|
|
|
|
# self.assertTrue("absences non justifiées:" not in driver.page_source)
|
|
|
|
|
|
|
|
# ferme la fenetre
|
|
|
|
def tearDown(self):
|
|
|
|
self.driver.close()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-06-07 16:48:11 +02:00
|
|
|
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
|
|
|
|
process = subprocess.Popen(cmdProcess)
|
|
|
|
process.wait()
|
|
|
|
cmdProcess = [
|
|
|
|
"./scriptExecution.sh",
|
|
|
|
LINK_SCODOC_SERVER,
|
|
|
|
NOM_DPT,
|
|
|
|
"test_scenario2_formation.py",
|
|
|
|
]
|
|
|
|
process = subprocess.Popen(cmdProcess)
|
|
|
|
process.wait()
|
2021-06-23 14:27:05 +02:00
|
|
|
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))
|