refractoring + test fiche étudiante correcte avec les notes

This commit is contained in:
Aurelien PLANCKE 2021-05-12 14:49:00 +02:00
parent b06207b593
commit 12d3ab8869
7 changed files with 1941 additions and 105 deletions

View File

@ -1,13 +1,11 @@
import unittest
import time
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
SCODOC_ADMIN_ID = "admin"
SCODOC_ADMIN_PASS = "root_pass_42"
class PythonOrgSearch(unittest.TestCase):
nomDpt = "AurelienUS"
@ -21,7 +19,7 @@ class PythonOrgSearch(unittest.TestCase):
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
self.driver.get("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc")
self.driver.get(BASE_URL)
# Test : Verification de la connexion admin effective
# @expected : "Bonjour admin" est présent sur la page d'accueil
@ -33,7 +31,7 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : Le département est présent sur la page d'accueil
def test_create_departement(self):
driver = self.driver
driver.get("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/scodoc_admin")
driver.get(BASE_URL + "/scodoc_admin")
select = Select(driver.find_element_by_name("DeptId"))
select.select_by_visible_text("TESTDPT")
self.assertTrue(select.first_selected_option.text == "TESTDPT")
@ -41,7 +39,7 @@ class PythonOrgSearch(unittest.TestCase):
element = driver.find_element_by_id("gtrcontent").find_element_by_tag_name("h6")
element.submit()
time.sleep(2)
driver.get("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc")
driver.get(BASE_URL)
self.assertTrue("TESTDPT" in driver.page_source)
# def test_create_module(self):

View File

@ -1,5 +1,6 @@
import unittest
import time
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
@ -7,7 +8,7 @@ from selenium.webdriver.support.select import Select
SCODOC_ADMIN_ID = "admin"
SCODOC_ADMIN_PASS = "root_pass_42"
nomDpt = "AurelienUS"
NOM_DPT = "AurelienUS"
baseURL = "https://scodoc-dev-iutinfo.univ-lille.fr"
@ -28,11 +29,11 @@ class PythonOrgSearch(unittest.TestCase):
# @expected :
def test_create_formation(self):
driver = self.driver
url = baseURL + "/ScoDoc/" + nomDpt + "/Scolarite/Notes/formation_create"
url = baseURL + "/ScoDoc/" + NOM_DPT + "/Scolarite/Notes/formation_create"
driver.get(url)
select = Select(driver.find_element_by_name("DeptId"))
select.select_by_visible_text("TESTDPT")
self.assertTrue(select.first_selected_option.text == "TESTDPT")
select.select_by_visible_text(NOM_DPT)
self.assertTrue(select.first_selected_option.text == NOM_DPT)
element = driver.find_element_by_name("DeptId")
element = driver.find_element_by_id("gtrcontent").find_element_by_tag_name("h6")
element.submit()

View File

@ -1,5 +1,6 @@
import unittest
import time
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
import urllib.parse as urlparse
from urllib.parse import parse_qs
from selenium import webdriver
@ -39,7 +40,7 @@ class PythonOrgSearch(unittest.TestCase):
driver = self.driver
url = (
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
+ nomDPT
+ NOM_DPT
+ "/Scolarite/etudident_create_form"
)
driver.get(url)

View File

@ -1,6 +1,7 @@
import unittest
import time
import urllib.parse as urlparse
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
from urllib.parse import parse_qs
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
@ -8,9 +9,6 @@ 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_ADMIN_ID = "admin"
SCODOC_ADMIN_PASS = "root_pass_42"
nomDPT = "AurelienUS"
nomEtu = "UnAutreEtudiant"
prenomEtu = "Normal"
oldnip = "11122234"
@ -36,8 +34,8 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : Le nip sur la page informations de l'étudiant est mis à jour
def test_changement_info_etudiant(self):
url = (
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
+ nomDPT
BASE_URL
+ NOM_DPT
+ "/Scolarite/etudident_edit_form?etudid="
+ eid
)

View File

@ -1,6 +1,7 @@
import unittest
import time
import urllib.parse as urlparse
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
from urllib.parse import parse_qs
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
@ -8,9 +9,6 @@ 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_ADMIN_ID = "admin"
SCODOC_ADMIN_PASS = "root_pass_42"
nomDPT = "AurelienUS"
nomEtu = "UnAutreEtudiant"
prenomEtu = "Normal"
nip = "11122234"
@ -34,8 +32,8 @@ class PythonOrgSearch(unittest.TestCase):
driver = self.driver
driver.implicitly_wait(10)
url = (
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
+ nomDPT
BASE_URL
+ NOM_DPT
+ "/Scolarite/Absences/search_etud_in_dept"
)
driver.get(url)

View File

@ -1,6 +1,7 @@
import unittest
import time
import urllib.parse as urlparse
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT,SCODOC_ENS_ID,SCODOC_ENS_PASS,SCODOC_CHEF_ID,SCODOC_CHEF_PASS
from urllib.parse import parse_qs
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
@ -9,30 +10,23 @@ 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@"
SCODOC_CHEF = "chefdesetudesUS"
SCODOC_CHEF_PASS = "passwordUS42"
nomDPT = "AurelienUS"
SCODOC_ADMIN_ID = "admin"
SCODOC_ADMIN_PASS = "root_pass_42"
baseURL = "https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
urlMatiere = ''
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.url = baseURL + nomDPT + "/Scolarite"
self.url = BASE_URL + NOM_DPT + "/Scolarite"
self.wait = WebDriverWait(self.driver, 10)
self.driver.get(baseURL)
self.driver.find_element_by_id("name").send_keys(SCODOC_ID)
self.driver.find_element_by_id("password").send_keys(SCODOC_PASS)
self.driver.get(BASE_URL)
self.driver.find_element_by_id("name").send_keys(SCODOC_ENS_ID)
self.driver.find_element_by_id("password").send_keys(SCODOC_ENS_PASS)
self.driver.find_element_by_id("submit").click()
# Test : Vérifie s'il y a un semestre en cours
# @expected : La class listesems n'est pas vide et contient "Session en cours"
def test_01semestre_en_cours(self):
def test_010_semestre_en_cours(self):
driver = self.driver
url = self.url
driver.get(url)
@ -43,7 +37,7 @@ class PythonOrgSearch(unittest.TestCase):
# Test : Vérifie si une matière existe
# @expected : Le nom de la matière est présent dans le semestre préalablement testé
def test_02matiere_existante(self):
def test_020_matiere_existante(self):
driver = self.driver
url = self.url
driver.get(url)
@ -57,7 +51,7 @@ class PythonOrgSearch(unittest.TestCase):
# 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
def test_03ajout_enseignant_sur_module(self):
def test_030_ajout_enseignant_sur_module(self):
driver = self.driver
url = self.url
self.driver.get(
@ -71,29 +65,35 @@ class PythonOrgSearch(unittest.TestCase):
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
time.sleep(1)
global urlMatiere
urlMatiere = driver.current_url
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)
self.assertTrue(SCODOC_ENS_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):
def test_040_creation_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()
driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
#driver.get(BASE_URL)
#driver.find_element_by_link_text("déconnecter").click()
#driver.get(BASE_URL)
#driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID)
#driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
#driver.find_element_by_id("submit").click()
driver.get(urlMatiere)
time.sleep(1)
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
time.sleep(1)
@ -105,12 +105,9 @@ class PythonOrgSearch(unittest.TestCase):
# Test Vérifie si une interrogation existe sur un module
# @expected "Module" est présent dans le "formsemetre"
def test_05interro_existante(self):
def test_050_interro_existante(self):
driver = self.driver
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()
driver.get(urlMatiere)
time.sleep(1)
self.assertTrue(
"Module" in driver.find_element_by_class_name("formsemestre").text
@ -118,56 +115,46 @@ class PythonOrgSearch(unittest.TestCase):
# 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):
def test_060_entree_note(self):
driver = self.driver
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()
driver.get(urlMatiere)
time.sleep(1)
driver.find_element_by_class_name("notes_img").click()
time.sleep(1)
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.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)
# 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):
def test_070_ajout_note_incomplete(self):
driver = self.driver
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()
driver.get(urlMatiere)
time.sleep(1)
driver.find_element_by_class_name("notes_img").click()
elements = driver.find_elements_by_class_name("note")
for element in elements:
print(element.text)
if element.text != "":
if element.get_attribute("value") == "":
element.send_keys(15)
driver.find_element_by_id("formnotes_submit").click()
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("UneEtudianteEnS4")
element.submit()
time.sleep(5)
self.assertTrue("12" in driver.find_element_by_class_name("ue").text)
# 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):
def test_080_suppression_note(self):
driver = self.driver
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()
driver.get(urlMatiere)
time.sleep(1)
driver.find_element_by_class_name("notes_img").click()
time.sleep(1)
@ -176,7 +163,7 @@ class PythonOrgSearch(unittest.TestCase):
element.clear()
element.send_keys("SUPR")
driver.find_element_by_id("formnotes_submit").click()
self.wait.until(EC.url_changes(url))
time.sleep(1)
try:
driver.find_element_by_link_text("afficher")
self.assertFalse(False)
@ -185,35 +172,32 @@ class PythonOrgSearch(unittest.TestCase):
# 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"
def test_090_suppresion_interrogation(self):
descriptionInterrogation = "Interrogation à supprimer"
driver = self.driver
url = self.url
driver.get(baseURL)
driver.get(BASE_URL)
driver.find_element_by_link_text("déconnecter").click()
driver.get(baseURL)
driver.find_element_by_id("name").send_keys(SCODOC_CHEF)
driver.get(BASE_URL)
driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID)
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()
driver.get(urlMatiere)
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)
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)
driver.find_element_by_class_name("delete_img").click()
time.sleep(1)
driver.find_element_by_id("tf_submit").click()
self.assertFalse(descriptionInterrogation in driver.page_source)
# 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):
def test_200_suppression_enseignant_sur_module(self):
driver = self.driver
url = self.url
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
@ -221,9 +205,7 @@ class PythonOrgSearch(unittest.TestCase):
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
driver.get(url)
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
driver.find_element_by_link_text("M4101C").click()
driver.get(urlMatiere)
time.sleep(1)
driver.find_element_by_partial_link_text("modifier les enseignants").click()
time.sleep(1)
@ -232,9 +214,30 @@ class PythonOrgSearch(unittest.TestCase):
element.click()
time.sleep(1)
time.sleep(1)
self.assertTrue(SCODOC_ID not in driver.page_source)
self.assertTrue(SCODOC_ENS_ID not in driver.page_source)
# ferme la fenetre
def test_910_suppresion_interrogation_restante(self):
driver = self.driver
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
driver.get(urlMatiere)
time.sleep(1)
elements = driver.find_elements_by_class_name("delete_img")
while elements:
elements[0].click()
time.sleep(1)
driver.find_element_by_id("tf_submit").click()
time.sleep(1)
driver.get(urlMatiere)
time.sleep(1)
elements = driver.find_elements_by_class_name("delete_img")
# ferme la fenetre et fais du clean up
def tearDown(self):
self.driver.close()

File diff suppressed because it is too large Load Diff