refractoring + ajout test creation formation
This commit is contained in:
parent
d67d5faf71
commit
1aebf18999
@ -2,7 +2,14 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT, LINK_SCODOC_SERVER
|
from setup import (
|
||||||
|
SCODOC_ADMIN_ID,
|
||||||
|
SCODOC_ADMIN_PASS,
|
||||||
|
BASE_URL,
|
||||||
|
NOM_DPT,
|
||||||
|
LINK_SCODOC_SERVER,
|
||||||
|
BASE_NOT_SECURED_URL,
|
||||||
|
)
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
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
|
||||||
@ -14,13 +21,14 @@ from selenium.webdriver.support.select import Select
|
|||||||
URL = BASE_URL + NOM_DPT + "/Scolarite"
|
URL = BASE_URL + NOM_DPT + "/Scolarite"
|
||||||
|
|
||||||
ACRONYME_FORMATION = "FormationTEST"
|
ACRONYME_FORMATION = "FormationTEST"
|
||||||
|
|
||||||
|
|
||||||
class PythonOrgSearch(unittest.TestCase):
|
class PythonOrgSearch(unittest.TestCase):
|
||||||
cmdProcess = ['./scriptCreationDepartement.sh', LINK_SCODOC_SERVER, NOM_DPT]
|
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
|
||||||
process = subprocess.Popen(cmdProcess)
|
process = subprocess.Popen(cmdProcess)
|
||||||
process.wait()
|
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.url = ''
|
|
||||||
self.driver = webdriver.Firefox()
|
self.driver = webdriver.Firefox()
|
||||||
self.wait = WebDriverWait(self.driver, 10)
|
self.wait = WebDriverWait(self.driver, 10)
|
||||||
self.driver.get(
|
self.driver.get(
|
||||||
@ -28,7 +36,9 @@ 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(BASE_URL + "/ScoDoc")
|
self.driver.get(BASE_URL + "/ScoDoc")
|
||||||
|
|
||||||
@ -36,49 +46,121 @@ class PythonOrgSearch(unittest.TestCase):
|
|||||||
# @expected : La formation se trouve dans le tableau de la liste des formations
|
# @expected : La formation se trouve dans le tableau de la liste des formations
|
||||||
def test_011_create_formation(self):
|
def test_011_create_formation(self):
|
||||||
driver = self.driver
|
driver = self.driver
|
||||||
|
global URL
|
||||||
driver.get(URL)
|
driver.get(URL)
|
||||||
driver.find_element_by_id("ProgrammesLink").click()
|
driver.find_element_by_id("ProgrammesLink").click()
|
||||||
self.url = driver.current_url
|
URL = driver.current_url
|
||||||
driver.find_element_by_id("create_formation_link").click()
|
driver.find_element_by_id("create_formation_link").click()
|
||||||
self.wait.until(EC.url_changes(URL))
|
self.wait.until(EC.url_changes(URL))
|
||||||
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
||||||
driver.find_element_by_id("tf_titre").send_keys("TEST")
|
driver.find_element_by_id("tf_titre").send_keys("TEST")
|
||||||
driver.find_element_by_id("tf_titre_officiel").send_keys("formation de test")
|
driver.find_element_by_id("tf_titre_officiel").send_keys("formation de test")
|
||||||
driver.find_element_by_id("tf_submit").click()
|
driver.find_element_by_id("tf_submit").click()
|
||||||
driver.get(self.url)
|
driver.get(URL)
|
||||||
formations = driver.find_elements_by_class_name("acronyme")
|
formations = driver.find_elements_by_class_name("acronyme")
|
||||||
textElementAcronyme = []
|
textElementAcronyme = []
|
||||||
for formation in formations:
|
for formation in formations:
|
||||||
textElementAcronyme.append(formation.text)
|
textElementAcronyme.append(formation.text)
|
||||||
self.assertTrue(ACRONYME_FORMATION in textElementAcronyme)
|
self.assertTrue(ACRONYME_FORMATION in textElementAcronyme)
|
||||||
|
|
||||||
def test_012_create_formation_with_same_name(self):
|
# Test : Changement du nom d'une formation
|
||||||
|
# @expected : Le nom de la formation est changé sur la page des formations
|
||||||
|
def test_012_change_name_formation(self):
|
||||||
driver = self.driver
|
driver = self.driver
|
||||||
url = self.url
|
global URL
|
||||||
driver.get(url)
|
driver.get(URL)
|
||||||
idEditFormation = "edit_Formation_" + ACRONYME_FORMATION
|
idEditFormation = "edit_Formation_" + ACRONYME_FORMATION
|
||||||
driver.find_element_by_id(idEditFormation).click()
|
driver.find_element_by_id(idEditFormation).click()
|
||||||
self.wait.until(EC.url_changes(URL))
|
self.wait.until(EC.url_changes(URL))
|
||||||
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION + ACRONYME_FORMATION)
|
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
||||||
driver.find_element_by_id("tf_submit").click()
|
driver.find_element_by_id("tf_submit").click()
|
||||||
driver.get(self.url)
|
driver.get(URL)
|
||||||
formations = driver.find_elements_by_class_name(" acronyme")
|
formations = driver.find_elements_by_class_name("acronyme")
|
||||||
textElementAcronyme = []
|
textElementAcronyme = []
|
||||||
for formation in formations:
|
for formation in formations:
|
||||||
textElementAcronyme.append(formation.text)
|
textElementAcronyme.append(formation.text)
|
||||||
self.assertTrue(ACRONYME_FORMATION + ACRONYME_FORMATION in textElementAcronyme)
|
self.assertTrue(ACRONYME_FORMATION + ACRONYME_FORMATION in textElementAcronyme)
|
||||||
|
# Remise du nom à celui de départ
|
||||||
|
driver.get(URL)
|
||||||
|
idEditFormation = "edit_Formation_" + ACRONYME_FORMATION + ACRONYME_FORMATION
|
||||||
|
driver.find_element_by_id(idEditFormation).click()
|
||||||
|
self.wait.until(EC.url_changes(URL))
|
||||||
|
driver.find_element_by_id("tf_acronyme").clear()
|
||||||
|
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
||||||
|
driver.find_element_by_id("tf_submit").click()
|
||||||
|
|
||||||
|
# Test : Création d'une formation avec le même nom qu'une autre déjà existante
|
||||||
|
# @expected : La formation n'as pas pu être créée et on arrive donc sur un message d'erreur à la création
|
||||||
|
def test_013_same_name_formation(self):
|
||||||
|
driver = self.driver
|
||||||
|
global URL
|
||||||
|
driver.get(URL)
|
||||||
|
driver.find_element_by_id("create_formation_link").click()
|
||||||
|
self.wait.until(EC.url_changes(URL))
|
||||||
|
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
||||||
|
driver.find_element_by_id("tf_titre").send_keys("TEST")
|
||||||
|
driver.find_element_by_id("tf_titre_officiel").send_keys("formation de test")
|
||||||
|
driver.find_element_by_id("tf_submit").click()
|
||||||
|
try:
|
||||||
|
driver.find_element_by_id("errorMessage")
|
||||||
|
except NoSuchElementException:
|
||||||
|
self.assertFalse(True)
|
||||||
|
self.assertTrue(True)
|
||||||
|
|
||||||
|
# Test : Ajout d'un semestre dans la formation
|
||||||
|
# @Expected : Le semestre est créé et il apparait désormais dans la table des formations
|
||||||
|
def test_014_ajout_Semestre(self):
|
||||||
|
driver = self.driver
|
||||||
|
global URL
|
||||||
|
driver.get(URL)
|
||||||
|
idAddSemestre = "addSemestre_" + ACRONYME_FORMATION
|
||||||
|
driver.find_element_by_id(idAddSemestre).click()
|
||||||
|
self.wait.until(EC.url_changes(URL))
|
||||||
|
driver.find_element_by_name("date_debut").send_keys("01/01/2021")
|
||||||
|
driver.find_element_by_name("date_fin").send_keys("30/06/2021")
|
||||||
|
driver.find_element_by_name("responsable_id").send_keys("BACH Test (Bach)")
|
||||||
|
Select(driver.find_element_by_id("tf_semestre_id")).select_by_value("4")
|
||||||
|
driver.find_element_by_id("tf_submit").click()
|
||||||
|
self.wait.until(EC.url_changes(URL))
|
||||||
|
self.assertTrue(
|
||||||
|
"Nouveau semestre créé"
|
||||||
|
in driver.find_element_by_class_name("head_message").text
|
||||||
|
)
|
||||||
|
driver.get(URL)
|
||||||
|
|
||||||
|
self.assertTrue((NOM_DPT.upper() + "-" + "DUT" + "--") in driver.page_source)
|
||||||
|
|
||||||
|
# Test : Supprime une formation après avoir supprimé les semestres qui y sont rattachés
|
||||||
|
# @expected : La formation n'apparait plus dans le tableau des formations
|
||||||
def test_020_delete_formation(self):
|
def test_020_delete_formation(self):
|
||||||
driver = self.driver
|
driver = self.driver
|
||||||
url = self.url
|
global URL
|
||||||
driver.get(self.url)
|
driver.get(URL)
|
||||||
driver.find_element_by_id("ProgrammesLink").click()
|
idButtonDelete = "delete_Formation_" + ACRONYME_FORMATION
|
||||||
url = driver.current_url
|
|
||||||
idButtonDelete = "delete_Formation_"+ACRONYME_FORMATION
|
|
||||||
driver.find_element_by_id(idButtonDelete).click()
|
driver.find_element_by_id(idButtonDelete).click()
|
||||||
self.wait.until(EC.url_changes(url))
|
self.wait.until(EC.url_changes(URL))
|
||||||
driver.find_element_by_xpath("//input[@value='Supprimer cette formation']").click()
|
tmpURLDelete = driver.current_url
|
||||||
driver.get(self.url)
|
listeSemestres = driver.find_elements_by_xpath(
|
||||||
|
"//a[contains(@href, 'formsemestre_status?')]"
|
||||||
|
)
|
||||||
|
for semestre in listeSemestres:
|
||||||
|
semestre.click()
|
||||||
|
self.wait.until(EC.url_changes(URL))
|
||||||
|
driver.find_element_by_xpath(
|
||||||
|
"(//a[contains(text(),'Semestre')])[2]"
|
||||||
|
).click()
|
||||||
|
driver.find_element_by_xpath(
|
||||||
|
"//a[contains(@href, 'formsemestre_delete?')]"
|
||||||
|
).click()
|
||||||
|
self.wait.until(EC.url_changes(URL))
|
||||||
|
driver.find_element_by_id("tf_submit").click()
|
||||||
|
time.sleep(2)
|
||||||
|
driver.find_element_by_xpath("//input[@value='OK']").click()
|
||||||
|
driver.get(tmpURLDelete)
|
||||||
|
driver.find_element_by_xpath(
|
||||||
|
"//input[@value='Supprimer cette formation']"
|
||||||
|
).click()
|
||||||
|
driver.get(URL)
|
||||||
try:
|
try:
|
||||||
driver.find_element_by_id(idButtonDelete)
|
driver.find_element_by_id(idButtonDelete)
|
||||||
self.assertTrue(False)
|
self.assertTrue(False)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import time
|
import time
|
||||||
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
|
from setup import SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, BASE_URL, NOM_DPT
|
||||||
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
|
||||||
@ -9,8 +9,6 @@ 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
|
||||||
|
|
||||||
SCODOC_ADMIN_ID = "admin"
|
|
||||||
SCODOC_ADMIN_PASS = "root_pass_42"
|
|
||||||
nomDPT = "AurelienUS"
|
nomDPT = "AurelienUS"
|
||||||
nomEtu = "UnAutreEtudiant"
|
nomEtu = "UnAutreEtudiant"
|
||||||
prenomEtu = "Normal"
|
prenomEtu = "Normal"
|
||||||
|
Binary file not shown.
1199
geckodriver.log
1199
geckodriver.log
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user