refracto test étudiant

This commit is contained in:
Aurélien Plancke 2021-05-27 16:36:42 +02:00
parent 1aebf18999
commit ba68da71fd
4 changed files with 81 additions and 10213 deletions

View File

@ -1,15 +1,24 @@
import unittest import unittest
import time import time
from setup import SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, BASE_URL, NOM_DPT import subprocess
from setup import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
BASE_URL,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL,
)
import urllib.parse as urlparse import urllib.parse as urlparse
from urllib.parse import parse_qs from urllib.parse import parse_qs
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select from selenium.webdriver.support.select import Select
nomDPT = "AurelienUS" URL = BASE_URL + NOM_DPT + "/Scolarite"
nomEtu = "UnAutreEtudiant" nomEtu = "UnAutreEtudiant"
prenomEtu = "Normal" prenomEtu = "Normal"
nip = "11122234" nip = "11122234"
@ -19,6 +28,17 @@ paysdomicile = "Lille"
class PythonOrgSearch(unittest.TestCase): class PythonOrgSearch(unittest.TestCase):
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = [
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
NOM_DPT,
"test_scenario1_formation.py",
]
process = subprocess.Popen(cmdProcess)
process.wait()
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self): def setUp(self):
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
@ -28,20 +48,21 @@ class PythonOrgSearch(unittest.TestCase):
+ SCODOC_ADMIN_ID + SCODOC_ADMIN_ID
+ ":" + ":"
+ SCODOC_ADMIN_PASS + SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication" + "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
) )
self.driver.get("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc") global URL
self.driver.get(URL)
# Test : creer un etudiant et verifie si sa fiche etudiante est creee # Test : creer un etudiant et verifie si sa fiche etudiante est creee
# @expected : A la soumission du formulaire on retrouve la fiche d'information avec le nip (unique) dans la page, on a également un resultat en recherchant l'étudiant # @expected : A la soumission du formulaire on retrouve la fiche d'information avec le nip (unique) dans la page, on a également un resultat en recherchant l'étudiant
def test_01_creation_etudiant(self): def test_01_creation_etudiant(self):
driver = self.driver driver = self.driver
url = ( global URL
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" driver.find_element_by_id("link_create_etudident").click()
+ NOM_DPT self.wait.until(EC.url_changes(URL))
+ "/Scolarite/etudident_create_form" URL = driver.current_url
)
driver.get(url)
driver.find_element_by_id("tf_nom").send_keys(nomEtu) driver.find_element_by_id("tf_nom").send_keys(nomEtu)
driver.find_element_by_id("tf_prenom").send_keys(prenomEtu) driver.find_element_by_id("tf_prenom").send_keys(prenomEtu)
driver.find_element_by_id("tf_annee").send_keys("2021") driver.find_element_by_id("tf_annee").send_keys("2021")
@ -56,12 +77,8 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : La création mène à une page qui affiche "code étudiant dupliqué", l'étudiant n'est pas créé # @expected : La création mène à une page qui affiche "code étudiant dupliqué", l'étudiant n'est pas créé
def test_02_creation_etudiant_avec_meme_nip(self): def test_02_creation_etudiant_avec_meme_nip(self):
driver = self.driver driver = self.driver
url = ( global URL
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" driver.get(URL)
+ nomDPT
+ "/Scolarite/etudident_create_form"
)
driver.get(url)
driver.find_element_by_id("tf_nom").send_keys(nomEtu) driver.find_element_by_id("tf_nom").send_keys(nomEtu)
driver.find_element_by_id("tf_prenom").send_keys(prenomEtu) driver.find_element_by_id("tf_prenom").send_keys(prenomEtu)
driver.find_element_by_id("tf_annee").send_keys("2021") driver.find_element_by_id("tf_annee").send_keys("2021")
@ -78,17 +95,15 @@ class PythonOrgSearch(unittest.TestCase):
# expected : La nouvelle adresse est mise à jour sur la page information de l'étudiant # expected : La nouvelle adresse est mise à jour sur la page information de l'étudiant
def test_03_modification_adresse_etudiant(self): def test_03_modification_adresse_etudiant(self):
driver = self.driver driver = self.driver
url = ( global URL
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" driver.get(URL)
+ nomDPT element = driver.find_element_by_id("in-expnom")
+ "/Scolarite/search_etud_in_dept"
)
driver.get(url)
element = driver.find_element_by_name("expnom")
element.send_keys(nomEtu) element.send_keys(nomEtu)
element.submit() element.submit()
time.sleep(1) self.wait.until(EC.url_changes(URL))
driver.find_element_by_id("changerCoordonneesEtudiant").click() driver.find_element_by_xpath(
"//a[contains(@href,'formChangeCoordonnees')]"
).click()
time.sleep(1) time.sleep(1)
driver.find_element_by_id("tf_domicile").send_keys(domicile) driver.find_element_by_id("tf_domicile").send_keys(domicile)
driver.find_element_by_id("tf_codepostaldomicile").send_keys(codepostaldomicile) driver.find_element_by_id("tf_codepostaldomicile").send_keys(codepostaldomicile)
@ -96,31 +111,35 @@ class PythonOrgSearch(unittest.TestCase):
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
time.sleep(1) time.sleep(1)
self.assertTrue( self.assertTrue(
codepostaldomicile in driver.find_element_by_id("champAdresse").text codepostaldomicile in driver.find_element_by_id("adresse_etudiant").text
) )
# Test Inscription d'un étudiant dans un semestre # Test Inscription d'un étudiant dans un semestre
# @expected : # @expected :
def test_04_inscription_etudiant(self): def test_04_inscription_etudiant(self):
driver = self.driver driver = self.driver
url = ( global URL
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" driver.get(URL)
+ nomDPT element = driver.find_element_by_id("in-expnom")
+ "/Scolarite/search_etud_in_dept"
)
driver.get(url)
element = driver.find_element_by_id("searchEtud")
element.send_keys(nomEtu) element.send_keys(nomEtu)
element.submit() element.submit()
time.sleep(1) self.wait.until(EC.url_changes(URL))
driver.find_element_by_id("inscription_Etudiant").click() driver.find_element_by_xpath(
time.sleep(1) "//a[contains(@href, 'formsemestre_inscription_with_modules_form')]"
self.assertTrue("<h3>Choisir un semestre:</h3>" in driver.page_source) ).click()
driver.find_elements_by_id("semestreInscription")[0].click() self.wait.until(EC.url_changes(URL))
time.sleep(1) try:
semestres = driver.find_elements_by_xpath(
"//a[contains(@id,'inscription_Semestre_')]"
)
print(semestres)
except NoSuchElementException:
self.assertFalse(True)
semestres[0].click()
# self.wait.until(EC.url_changes(URL))
driver.find_element_by_xpath("//input[@value='Inscrire']").click() driver.find_element_by_xpath("//input[@value='Inscrire']").click()
self.wait.until(EC.url_changes(url)) # self.wait.until(EC.url_changes(url))
self.assertTrue("Inscrire" in driver.page_source) self.assertTrue("inscrit" in driver.page_source)
time.sleep(1) time.sleep(1)
# Test Supprime un étudiant # Test Supprime un étudiant
@ -129,7 +148,7 @@ class PythonOrgSearch(unittest.TestCase):
driver = self.driver driver = self.driver
urlRecherche = ( urlRecherche = (
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" "https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
+ nomDPT + NOM_DPT
+ "/Scolarite/search_etud_in_dept" + "/Scolarite/search_etud_in_dept"
) )
driver.get(urlRecherche) driver.get(urlRecherche)
@ -140,7 +159,7 @@ class PythonOrgSearch(unittest.TestCase):
etudid = driver.find_element_by_id("euid") etudid = driver.find_element_by_id("euid")
url = ( url = (
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" "https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
+ nomDPT + NOM_DPT
+ "/Scolarite/etudident_delete?etudid=" + "/Scolarite/etudident_delete?etudid="
+ etudid.text + etudid.text
) )

View File

@ -1,57 +0,0 @@
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
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"
oldnip = "11122234"
newnip = "12345678"
eid = "EID1"
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"
)
self.driver.get("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc")
# Test changer les données d'un étudiant
# @expected : Le nip sur la page informations de l'étudiant est mis à jour
def test_changement_info_etudiant(self):
url = (
BASE_URL
+ NOM_DPT
+ "/Scolarite/etudident_edit_form?etudid="
+ eid
)
driver = self.driver
driver.get(url)
driver.find_element_by_id("tf_code_nip").clear()
driver.find_element_by_id("tf_code_nip").send_keys(newnip)
driver.find_element_by_id("tf_submit").click()
self.wait.until(EC.url_changes(url))
time.sleep(5)
self.assertTrue(newnip in driver.page_source)
# ferme la fenetre
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()

View File

@ -9,15 +9,21 @@ from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select from selenium.webdriver.support.select import Select
nomEtu = "UnAutreEtudiant" URL = BASE_URL + NOM_DPT + "/Scolarite"
prenomEtu = "Normal"
nip = "11122234"
dateDebutAbsenceJustifiee = "12/04/2021"
dateDebutAbsenceNonJustifiee = "13/04/2021"
class PythonOrgSearch(unittest.TestCase): class PythonOrgSearch(unittest.TestCase):
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()
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self): def setUp(self):
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
@ -27,15 +33,15 @@ class PythonOrgSearch(unittest.TestCase):
+ SCODOC_ADMIN_ID + SCODOC_ADMIN_ID
+ ":" + ":"
+ SCODOC_ADMIN_PASS + SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication" + "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
) )
global URL
self.driver.get(URL)
driver = self.driver driver = self.driver
driver.implicitly_wait(10) driver.implicitly_wait(10)
url = ( url = BASE_URL + NOM_DPT + "/Scolarite/Absences/search_etud_in_dept"
BASE_URL
+ NOM_DPT
+ "/Scolarite/Absences/search_etud_in_dept"
)
driver.get(url) driver.get(url)
element = driver.find_element_by_name("expnom") element = driver.find_element_by_name("expnom")
element.send_keys(nomEtu) element.send_keys(nomEtu)

File diff suppressed because it is too large Load Diff