2021-04-21 13:28:58 +02:00
|
|
|
import unittest
|
|
|
|
import time
|
|
|
|
import urllib.parse as urlparse
|
2021-05-12 14:49:00 +02:00
|
|
|
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
|
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
|
|
|
|
|
|
|
|
nomEtu = "UnAutreEtudiant"
|
|
|
|
prenomEtu = "Normal"
|
|
|
|
nip = "11122234"
|
|
|
|
dateDebutAbsenceJustifiee = "12/04/2021"
|
|
|
|
dateDebutAbsenceNonJustifiee = "13/04/2021"
|
|
|
|
|
|
|
|
|
|
|
|
class PythonOrgSearch(unittest.TestCase):
|
|
|
|
|
|
|
|
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
|
|
|
def setUp(self):
|
|
|
|
self.driver = webdriver.Firefox()
|
|
|
|
self.wait = WebDriverWait(self.driver, 10)
|
|
|
|
self.driver.get(
|
|
|
|
"https://"
|
|
|
|
+ SCODOC_ADMIN_ID
|
|
|
|
+ ":"
|
|
|
|
+ SCODOC_ADMIN_PASS
|
|
|
|
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
|
|
|
|
)
|
|
|
|
driver = self.driver
|
|
|
|
driver.implicitly_wait(10)
|
|
|
|
url = (
|
2021-05-12 14:49:00 +02:00
|
|
|
BASE_URL
|
|
|
|
+ NOM_DPT
|
2021-04-21 13:28:58 +02:00
|
|
|
+ "/Scolarite/Absences/search_etud_in_dept"
|
|
|
|
)
|
|
|
|
driver.get(url)
|
|
|
|
element = driver.find_element_by_name("expnom")
|
|
|
|
element.send_keys(nomEtu)
|
|
|
|
element.submit()
|
|
|
|
|
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-04-21 13:28:58 +02:00
|
|
|
def test_ajout_absence_non_justifiee(self):
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Ajouter").click()
|
|
|
|
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-04-21 13:28:58 +02:00
|
|
|
def test_ajout_absence_justifiee(self):
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Ajouter").click()
|
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
|
|
|
driver.find_element_by_name("estjust").click()
|
|
|
|
driver.find_element_by_id("butsubmit").submit()
|
|
|
|
time.sleep(1)
|
|
|
|
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-04-21 13:28:58 +02:00
|
|
|
def test_ajout_justification(self):
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Justifier").click()
|
|
|
|
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()
|
|
|
|
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-04-21 13:28:58 +02:00
|
|
|
def test_supprimer_absence(self):
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Supprimer").click()
|
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
|
|
|
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
|
|
|
self.assertTrue("Annulation sur 2 demi-journées " in driver.page_source)
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Supprimer").click()
|
|
|
|
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
|
|
|
|
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
|
|
|
driver = self.driver
|
|
|
|
driver.find_element_by_link_text("Liste").click()
|
|
|
|
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__":
|
|
|
|
unittest.main()
|