2021-05-21 16:29:45 +02:00
|
|
|
# coding: utf8
|
2021-04-21 13:28:58 +02:00
|
|
|
import unittest
|
|
|
|
import time
|
2021-05-21 16:29:45 +02:00
|
|
|
import subprocess
|
2021-06-23 14:27:05 +02:00
|
|
|
import HtmlTestRunner
|
2021-06-24 15:04:22 +02:00
|
|
|
import createDepartement
|
|
|
|
import creationSiteDepartement
|
|
|
|
import deleteDepartement
|
2021-05-28 20:41:04 +02:00
|
|
|
from setting import (
|
2021-05-26 17:09:28 +02:00
|
|
|
SCODOC_ADMIN_ID,
|
|
|
|
SCODOC_ADMIN_PASS,
|
2021-07-24 08:41:26 +02:00
|
|
|
SCHEMA,
|
2021-05-26 17:09:28 +02:00
|
|
|
BASE_URL,
|
|
|
|
NOM_DPT,
|
|
|
|
LINK_SCODOC_SERVER,
|
2021-07-24 08:41:26 +02:00
|
|
|
BASE_SSH_URL,
|
2021-06-01 16:50:45 +02:00
|
|
|
NAVIGATEUR,
|
2021-05-26 17:09:28 +02:00
|
|
|
)
|
2021-04-21 13:28:58 +02:00
|
|
|
from selenium import webdriver
|
2021-05-21 16:29:45 +02:00
|
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
|
|
from selenium.webdriver.support.ui import Select, WebDriverWait
|
|
|
|
from selenium.common.exceptions import NoSuchElementException
|
2021-04-21 13:28:58 +02:00
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
from selenium.webdriver.support.ui import Select
|
|
|
|
from selenium.webdriver.support.select import Select
|
|
|
|
|
2021-08-08 07:39:21 +02:00
|
|
|
URL_ROOT = SCHEMA + "://" + BASE_URL
|
|
|
|
URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
|
|
|
|
URL_SCODOC8 = "/".join((URL_ROOT, "index"))
|
|
|
|
URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
|
|
|
|
URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
|
|
|
|
URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
|
2021-04-21 13:28:58 +02:00
|
|
|
|
2021-06-25 01:07:44 +02:00
|
|
|
ACRONYME_FORMATION = "formationtest"
|
2021-08-08 07:39:21 +02:00
|
|
|
URL = URL_SCODOC8
|
2021-05-26 17:09:28 +02:00
|
|
|
|
2021-04-21 13:28:58 +02:00
|
|
|
class PythonOrgSearch(unittest.TestCase):
|
|
|
|
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
|
|
|
def setUp(self):
|
2021-07-29 08:17:23 +02:00
|
|
|
next_page = ""
|
2021-06-01 16:50:45 +02:00
|
|
|
if NAVIGATEUR == "firefox":
|
|
|
|
self.driver = webdriver.Firefox()
|
|
|
|
else:
|
|
|
|
self.driver = webdriver.Chrome()
|
2021-08-08 07:39:21 +02:00
|
|
|
self.wait = WebDriverWait(self.driver, 10)
|
|
|
|
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
|
2021-08-07 09:34:14 +02:00
|
|
|
self.driver.get(auth_page)
|
|
|
|
self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
|
|
|
|
self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
|
|
|
|
self.driver.find_element_by_id("submit").click()
|
2021-08-08 07:39:21 +02:00
|
|
|
self.driver.get(URL_HOME)
|
2021-04-21 13:28:58 +02:00
|
|
|
|
2021-05-06 20:28:56 +02:00
|
|
|
# Test Creer une formation
|
2021-05-21 16:29:45 +02:00
|
|
|
# @expected : La formation se trouve dans le tableau de la liste des formations
|
|
|
|
def test_011_create_formation(self):
|
2021-05-26 17:09:28 +02:00
|
|
|
global URL
|
2021-08-08 07:39:21 +02:00
|
|
|
driver = self.driver
|
|
|
|
wait = self.wait
|
|
|
|
driver.get(URL_DEPT)
|
2021-06-25 00:45:50 +02:00
|
|
|
driver.find_element_by_id("link-programmes").click()
|
2021-05-26 17:09:28 +02:00
|
|
|
URL = driver.current_url
|
2021-06-25 00:45:50 +02:00
|
|
|
driver.find_element_by_id("link-create-formation").click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-21 16:29:45 +02:00
|
|
|
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()
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.get(URL)
|
2021-05-21 16:29:45 +02:00
|
|
|
formations = driver.find_elements_by_class_name("acronyme")
|
|
|
|
textElementAcronyme = []
|
|
|
|
for formation in formations:
|
|
|
|
textElementAcronyme.append(formation.text)
|
|
|
|
self.assertTrue(ACRONYME_FORMATION in textElementAcronyme)
|
|
|
|
|
2021-05-26 17:09:28 +02:00
|
|
|
# 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):
|
2021-04-21 13:28:58 +02:00
|
|
|
driver = self.driver
|
2021-08-08 07:39:21 +02:00
|
|
|
wait = self.wait
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.get(URL)
|
2021-08-08 07:39:21 +02:00
|
|
|
id_edit_formation = "edit-formation-" + ACRONYME_FORMATION.replace(" ","-")
|
|
|
|
driver.find_element_by_id(id_edit_formation).click()
|
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
2021-05-21 16:29:45 +02:00
|
|
|
driver.find_element_by_id("tf_submit").click()
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.get(URL)
|
|
|
|
formations = driver.find_elements_by_class_name("acronyme")
|
2021-08-08 07:39:21 +02:00
|
|
|
text_element_acronyme = []
|
2021-05-21 16:29:45 +02:00
|
|
|
for formation in formations:
|
2021-08-08 07:39:21 +02:00
|
|
|
text_element_acronyme.append(formation.text)
|
|
|
|
self.assertTrue(ACRONYME_FORMATION + ACRONYME_FORMATION in text_element_acronyme)
|
2021-05-26 17:09:28 +02:00
|
|
|
# Remise du nom à celui de départ
|
|
|
|
driver.get(URL)
|
2021-08-08 07:39:21 +02:00
|
|
|
id_edit_formation = "edit-formation-" + ACRONYME_FORMATION + ACRONYME_FORMATION
|
|
|
|
driver.find_element_by_id(id_edit_formation).click()
|
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-26 17:09:28 +02:00
|
|
|
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
|
2021-08-08 07:39:21 +02:00
|
|
|
wait = self.wait
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.get(URL)
|
2021-06-25 02:12:04 +02:00
|
|
|
driver.find_element_by_id("link-create-formation").click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-26 17:09:28 +02:00
|
|
|
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:
|
2021-06-25 00:45:50 +02:00
|
|
|
driver.find_element_by_class_name("error-message")
|
2021-06-25 16:44:00 +02:00
|
|
|
message_erreur_present = True
|
2021-05-26 17:09:28 +02:00
|
|
|
except NoSuchElementException:
|
2021-06-25 16:44:00 +02:00
|
|
|
message_erreur_present = False
|
|
|
|
self.assertTrue(message_erreur_present)
|
2021-05-26 17:09:28 +02:00
|
|
|
|
2021-06-18 16:32:37 +02:00
|
|
|
# Test : Ajout d'une UE dans la formation
|
|
|
|
# @Expected : L'UE est créée et elle apparait désormais dans la liste d'UE de la formation
|
|
|
|
def test_014_ajout_UE(self):
|
|
|
|
driver = self.driver
|
2021-08-08 07:39:21 +02:00
|
|
|
wait = self.wait
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.get(URL)
|
2021-08-08 07:39:21 +02:00
|
|
|
id_titre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
|
|
|
driver.find_element_by_id(id_titre).click()
|
|
|
|
wait.until(EC.url_changes(URL))
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.find_element_by_xpath("//a[contains(@href,'ue_create?')]").click()
|
2021-06-23 14:27:05 +02:00
|
|
|
driver.find_element_by_id("tf_titre").send_keys("UE TEST")
|
|
|
|
driver.find_element_by_id("tf_acronyme").send_keys("TEST")
|
|
|
|
driver.find_element_by_id("tf_submit").click()
|
2021-06-18 16:32:37 +02:00
|
|
|
time.sleep(1)
|
|
|
|
driver.get(URL)
|
2021-08-08 07:39:21 +02:00
|
|
|
driver.find_element_by_id(id_titre).click()
|
|
|
|
wait.until(EC.url_changes(URL))
|
2021-06-23 14:27:05 +02:00
|
|
|
self.assertTrue("TEST UE TEST" in driver.page_source)
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.get(URL)
|
|
|
|
|
|
|
|
# Test : Ajout d'une matière dans la formation
|
|
|
|
# @Expected : La matière est créée et elle apparait désormais sur la page de détail de la formation
|
|
|
|
def test_015_ajout_matiere(self):
|
|
|
|
driver = self.driver
|
2021-08-08 07:39:21 +02:00
|
|
|
wait = self.wait
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.get(URL)
|
2021-08-08 07:39:21 +02:00
|
|
|
nomMat = "unematieretest"
|
2021-06-23 14:27:05 +02:00
|
|
|
time.sleep(3)
|
2021-08-08 07:39:21 +02:00
|
|
|
idTitre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.find_element_by_id(idTitre).click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-06-23 14:27:05 +02:00
|
|
|
time.sleep(3)
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.find_element_by_xpath("//a[contains(@href,'matiere_create?')]").click()
|
2021-06-23 14:27:05 +02:00
|
|
|
driver.find_element_by_id("tf_titre").send_keys(nomMat)
|
|
|
|
driver.find_element_by_id("tf_numero").send_keys("1")
|
|
|
|
driver.find_element_by_id("tf_submit").click()
|
|
|
|
time.sleep(3)
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.get(URL)
|
|
|
|
driver.find_element_by_id(idTitre).click()
|
2021-06-23 14:27:05 +02:00
|
|
|
time.sleep(3)
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-06-18 16:32:37 +02:00
|
|
|
elements = driver.find_elements_by_xpath("//a[contains(@href,'matiere_edit?')]")
|
|
|
|
matIsPresent = False
|
|
|
|
for element in elements:
|
|
|
|
if element.text == nomMat:
|
|
|
|
matIsPresent = True
|
|
|
|
self.assertTrue(matIsPresent)
|
|
|
|
|
2021-05-26 17:09:28 +02:00
|
|
|
# Test : Ajout d'un semestre dans la formation
|
|
|
|
# @Expected : Le semestre est créé et il apparait désormais dans la table des formations
|
2021-06-18 16:32:37 +02:00
|
|
|
def test_016_ajout_Semestre(self):
|
2021-05-26 17:09:28 +02:00
|
|
|
driver = self.driver
|
2021-08-08 07:39:21 +02:00
|
|
|
wait = self.wait
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.get(URL)
|
2021-08-08 07:39:21 +02:00
|
|
|
idAddSemestre = "add-semestre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.find_element_by_id(idAddSemestre).click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.find_element_by_name("date_debut").send_keys("01/01/2021")
|
|
|
|
driver.find_element_by_name("date_fin").send_keys("30/06/2021")
|
2021-08-08 07:39:21 +02:00
|
|
|
driver.find_element_by_name("responsable_id").send_keys("HAUSPIE Michael (bach)")
|
2021-05-26 17:09:28 +02:00
|
|
|
Select(driver.find_element_by_id("tf_semestre_id")).select_by_value("4")
|
|
|
|
driver.find_element_by_id("tf_submit").click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-26 17:09:28 +02:00
|
|
|
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)
|
2021-06-23 14:27:05 +02:00
|
|
|
|
2021-06-18 16:32:37 +02:00
|
|
|
# Test : Dupplique une formation sous une nouvelle version
|
|
|
|
# @expected : La formation est dupliquée et à la version "2"
|
|
|
|
def test_017_creer_nouvelle_version_formation(self):
|
|
|
|
driver = self.driver
|
2021-08-08 07:39:21 +02:00
|
|
|
wait = self.wait
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.get(URL)
|
2021-06-25 01:07:44 +02:00
|
|
|
idTitre = "titre-" + ACRONYME_FORMATION
|
2021-06-18 16:32:37 +02:00
|
|
|
driver.find_element_by_id(idTitre).click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-06-18 16:32:37 +02:00
|
|
|
tmpurl = driver.current_url
|
2021-06-23 14:27:05 +02:00
|
|
|
driver.find_element_by_xpath(
|
|
|
|
"//a[contains(@href,'formation_create_new_version?')]"
|
|
|
|
).click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(tmpurl))
|
2021-06-18 16:32:37 +02:00
|
|
|
self.assertTrue("Nouvelle version !" in driver.page_source)
|
2021-06-23 14:27:05 +02:00
|
|
|
driver.get(URL)
|
2021-06-18 16:32:37 +02:00
|
|
|
elements = driver.find_elements_by_class_name("version")
|
2021-08-08 07:39:21 +02:00
|
|
|
version_is_present = False
|
2021-06-18 16:32:37 +02:00
|
|
|
for element in elements:
|
2021-06-23 14:27:05 +02:00
|
|
|
if element.text == "2":
|
2021-08-08 07:39:21 +02:00
|
|
|
version_is_present = True
|
|
|
|
self.assertTrue(version_is_present)
|
2021-06-23 14:27:05 +02:00
|
|
|
|
2021-05-26 17:09:28 +02:00
|
|
|
# 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
|
2021-05-21 16:29:45 +02:00
|
|
|
def test_020_delete_formation(self):
|
|
|
|
driver = self.driver
|
2021-08-08 07:39:21 +02:00
|
|
|
wait = self.wait
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.get(URL)
|
2021-08-08 07:39:21 +02:00
|
|
|
id_button_delete = "delete-formation-" + ACRONYME_FORMATION
|
|
|
|
driver.find_element_by_id(id_button_delete).click()
|
|
|
|
wait.until(EC.url_changes(URL))
|
|
|
|
tmp_url_delete = driver.current_url
|
|
|
|
liste_semestres = driver.find_elements_by_xpath(
|
2021-05-26 17:09:28 +02:00
|
|
|
"//a[contains(@href, 'formsemestre_status?')]"
|
|
|
|
)
|
2021-08-08 07:39:21 +02:00
|
|
|
for semestre in liste_semestres:
|
2021-05-26 17:09:28 +02:00
|
|
|
semestre.click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.find_element_by_xpath(
|
|
|
|
"(//a[contains(text(),'Semestre')])[2]"
|
|
|
|
).click()
|
|
|
|
driver.find_element_by_xpath(
|
|
|
|
"//a[contains(@href, 'formsemestre_delete?')]"
|
|
|
|
).click()
|
2021-08-08 07:39:21 +02:00
|
|
|
wait.until(EC.url_changes(URL))
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.find_element_by_id("tf_submit").click()
|
|
|
|
time.sleep(2)
|
|
|
|
driver.find_element_by_xpath("//input[@value='OK']").click()
|
2021-08-08 07:39:21 +02:00
|
|
|
driver.get(tmp_url_delete)
|
2021-05-26 17:09:28 +02:00
|
|
|
driver.find_element_by_xpath(
|
|
|
|
"//input[@value='Supprimer cette formation']"
|
|
|
|
).click()
|
|
|
|
driver.get(URL)
|
2021-06-21 15:19:30 +02:00
|
|
|
formations = driver.find_elements_by_class_name("version")
|
2021-08-08 07:39:21 +02:00
|
|
|
formation_delete = True
|
2021-06-21 15:19:30 +02:00
|
|
|
for formation in formations:
|
|
|
|
if "1" in formation.text:
|
2021-08-08 07:39:21 +02:00
|
|
|
formation_delete = False
|
|
|
|
self.assertTrue(formation_delete)
|
2021-04-21 13:28:58 +02:00
|
|
|
|
|
|
|
# def test_create_module(self):
|
|
|
|
# driver = self.driver
|
|
|
|
# element = driver.find_element_by_name("TESTDPT")
|
|
|
|
|
|
|
|
# ferme la fenetre à chaque fin de test
|
|
|
|
def tearDown(self):
|
|
|
|
self.driver.close()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-06-24 15:04:22 +02:00
|
|
|
deleteDepartement.main()
|
|
|
|
createDepartement.main()
|
|
|
|
creationSiteDepartement.main()
|
|
|
|
|
|
|
|
unittest.main(
|
|
|
|
testRunner=HtmlTestRunner.HTMLTestRunner(
|
|
|
|
report_name="02_creation_formation_test",
|
|
|
|
output="./ResultatTest",
|
|
|
|
combine_reports=True,
|
|
|
|
)
|
2021-06-23 16:15:08 +02:00
|
|
|
)
|