ScodocTestClient/06_saisie_note_test.py

243 lines
10 KiB
Python
Raw Normal View History

2021-04-23 13:57:24 +02:00
import unittest
import time
import urllib.parse as urlparse
from urllib.parse import parse_qs
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
2021-04-23 13:57:24 +02:00
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select
SCODOC_ID = "enseignantUS"
SCODOC_PASS = "enseignant@"
2021-05-10 20:52:18 +02:00
SCODOC_CHEF = "chefdesetudesUS"
SCODOC_CHEF_PASS = "passwordUS42"
2021-04-23 13:57:24 +02:00
nomDPT = "AurelienUS"
SCODOC_ADMIN_ID = "admin"
SCODOC_ADMIN_PASS = "root_pass_42"
2021-05-07 15:37:34 +02:00
baseURL = "https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
2021-04-23 13:57:24 +02:00
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()
2021-05-10 20:52:18 +02:00
self.url = baseURL + nomDPT + "/Scolarite"
2021-04-23 13:57:24 +02:00
self.wait = WebDriverWait(self.driver, 10)
2021-05-07 15:37:34 +02:00
self.driver.get(baseURL)
2021-04-23 13:57:24 +02:00
self.driver.find_element_by_id("name").send_keys(SCODOC_ID)
self.driver.find_element_by_id("password").send_keys(SCODOC_PASS)
self.driver.find_element_by_id("submit").click()
2021-05-06 08:32:30 +02:00
# Test : Vérifie s'il y a un semestre en cours
# @expected : La class listesems n'est pas vide et contient "Session en cours"
2021-04-28 13:04:05 +02:00
def test_01semestre_en_cours(self):
2021-04-23 13:57:24 +02:00
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
driver.get(url)
time.sleep(1)
self.assertTrue(
"Sessions en cours" in driver.find_element_by_class_name("listesems").text
)
2021-04-23 13:57:24 +02:00
2021-05-06 08:32:30 +02:00
# Test : Vérifie si une matière existe
# @expected : Le nom de la matière est présent dans le semestre préalablement testé
2021-04-28 13:04:05 +02:00
def test_02matiere_existante(self):
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
time.sleep(1)
try:
driver.find_element_by_class_name("formsemestre_status_ue")
self.assertTrue(True)
except NoSuchElementException:
self.assertFalse(False)
2021-05-06 08:32:30 +02:00
# Test : Ajout d'un enseignant comme résponsable d'un module
# @expected : Le nom de l'enseignant apparait désormais sur la page d'information du module
2021-04-28 13:04:05 +02:00
def test_03ajout_enseignant_sur_module(self):
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
2021-05-06 08:32:30 +02:00
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
driver.find_element_by_partial_link_text("modifier les enseignants").click()
time.sleep(1)
driver.find_element_by_id("ens_id").send_keys("ENSEIGNANT Test (enseignantUS)")
driver.find_element_by_id("tf_submit").click()
time.sleep(1)
self.assertTrue("Enseignants du" in driver.page_source)
self.assertTrue(SCODOC_ID in driver.page_source)
# Test : Création d'une interrogation en tant que chef des études
# @eexpected : L'interrogation apparait désormais dans ce module
def test_04creation_interrogation(self):
descriptionInterrogation = "Interrogation numero 2"
driver = self.driver
url = self.url
driver.get(baseURL)
driver.find_element_by_link_text("déconnecter").click()
driver.get(baseURL)
driver.find_element_by_id("name").send_keys(SCODOC_CHEF)
driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
driver.find_element_by_id("submit").click()
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
time.sleep(1)
driver.find_element_by_id("tf_description").send_keys(descriptionInterrogation)
driver.find_element_by_id("tf_coefficient").send_keys("2")
driver.find_element_by_id("tf_submit").click()
time.sleep(1)
self.assertTrue(descriptionInterrogation in driver.page_source)
2021-05-06 08:32:30 +02:00
# Test Vérifie si une interrogation existe sur un module
# @expected "Module" est présent dans le "formsemetre"
def test_05interro_existante(self):
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
self.assertTrue(
"Module" in driver.find_element_by_class_name("formsemestre").text
)
2021-05-06 08:32:30 +02:00
# Test Entree des notes pour le premier étudiant inscrit à un module
# @expected : "saisir note" est remplacé par "afficher" sur la page d'information de l'interrogation concernée
def test_06entree_note(self):
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
2021-05-06 08:32:30 +02:00
driver.find_element_by_class_name("notes_img").click()
time.sleep(1)
2021-05-06 08:32:30 +02:00
element = driver.find_element_by_class_name("note")
element.send_keys("12")
driver.find_element_by_id("formnotes_submit").click()
self.wait.until(EC.url_changes(url))
self.assertTrue(
driver.find_element_by_link_text("afficher").text in driver.page_source
)
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("UneAutreEtudiante")
element.submit()
time.sleep(5)
self.assertTrue("12" in driver.find_elements_by_class_name("rcp_moy").text)
2021-05-06 08:32:30 +02:00
# Test : Ajoute les notes manquante poru les étudiants concernés dans une interrogation
# @expected : Tout les étudiants on une note
def test_07ajout_note_incomplete(self):
2021-04-28 13:04:05 +02:00
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
driver.get(url)
2021-04-28 13:04:05 +02:00
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
2021-05-06 08:32:30 +02:00
driver.find_element_by_class_name("notes_img").click()
elements = driver.find_elements_by_class_name("note")
for element in elements:
2021-05-10 20:52:18 +02:00
print(element.text)
if element.text != "":
2021-05-06 08:32:30 +02:00
element.send_keys(15)
2021-05-10 20:52:18 +02:00
driver.find_element_by_id("formnotes_submit").click()
2021-04-28 13:04:05 +02:00
2021-05-06 08:32:30 +02:00
# 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
def test_08suppression_note(self):
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
2021-05-06 08:32:30 +02:00
driver.find_element_by_class_name("notes_img").click()
time.sleep(1)
elements = driver.find_elements_by_class_name("note")
for element in elements:
2021-05-06 08:32:30 +02:00
element.clear()
element.send_keys("SUPR")
driver.find_element_by_id("formnotes_submit").click()
self.wait.until(EC.url_changes(url))
try:
driver.find_element_by_link_text("afficher")
self.assertFalse(False)
except NoSuchElementException:
self.assertTrue(True)
# 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_09suppresion_interrogation(self):
descriptionInterrogation = "Interrogation numero 2"
2021-05-07 15:37:34 +02:00
driver = self.driver
url = self.url
driver.get(baseURL)
driver.find_element_by_link_text("déconnecter").click()
2021-05-10 20:52:18 +02:00
driver.get(baseURL)
driver.find_element_by_id("name").send_keys(SCODOC_CHEF)
driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
driver.find_element_by_id("submit").click()
driver.get(url)
2021-05-10 20:52:18 +02:00
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
id = driver.find_element_by_link_text(descriptionInterrogation).text
urlDelete = (
baseURL
+ nomDPT
+ "/Scolarite/Notes/evaluation_delete?evaluation_id=%s" % id
)
driver.get(urlDelete)
driver.get(url)
self.assertFalse(descriptionInterrogation in driver.page_source)
2021-05-07 15:37:34 +02:00
2021-05-06 08:32:30 +02:00
# Test : Suppression d'un enseignant responsable d'un module
# @expected : L'enseignant n'apparait plus comme responsable dans ce module
def test_10suppression_enseignant_sur_module(self):
driver = self.driver
2021-05-06 08:32:30 +02:00
url = self.url
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
2021-05-06 08:32:30 +02:00
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
driver.find_element_by_partial_link_text("modifier les enseignants").click()
time.sleep(1)
elements = driver.find_elements_by_link_text("supprimer")
for element in elements:
element.click()
time.sleep(1)
time.sleep(1)
self.assertTrue(SCODOC_ID not in driver.page_source)
2021-04-23 13:57:24 +02:00
# ferme la fenetre
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()