forked from aurelien.plancke/ScodocTestClient
tests 02 (formation) ok
This commit is contained in:
parent
2a57748959
commit
b66631cdcc
@ -1,93 +1,94 @@
|
||||
# coding: utf8
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
import suppressionSiteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
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
|
||||
|
||||
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"))
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
auth_page = URL_AUTH + "?next=%2F" + next_page
|
||||
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()
|
||||
self.driver.get(URL_SCODOC8)
|
||||
|
||||
# Test : Verification de la connexion admin effective
|
||||
# @expected : "Bonjour admin" est présent sur la page d'accueil
|
||||
def test_01_connexion_admin(self):
|
||||
driver = self.driver
|
||||
self.assertTrue("admin" in driver.page_source)
|
||||
|
||||
# Test : Creer un département
|
||||
# @expected : Le département est présent sur la page d'accueil
|
||||
def test_02_create_departement(self):
|
||||
driver = self.driver
|
||||
driver.get(SCHEMA + "://" + BASE_URL + "/scodoc_admin")
|
||||
time.sleep(2)
|
||||
select = Select(driver.find_element_by_id("create-dept"))
|
||||
select.select_by_visible_text(NOM_DPT)
|
||||
driver.find_element_by_id("create-dept").submit()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.get(URL_HOME)
|
||||
self.assertTrue(NOM_DPT in driver.page_source)
|
||||
|
||||
# Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données
|
||||
# @expected : Le département n'apparait plus sur la page d'accueil
|
||||
def test_03_delete_departement(self):
|
||||
driver = self.driver
|
||||
driver.get(SCHEMA + "://" + BASE_URL + "/scodoc_admin")
|
||||
select = Select(driver.find_element_by_id("delete-dept"))
|
||||
select.select_by_visible_text(NOM_DPT)
|
||||
driver.find_element_by_id("delete-dept").submit()
|
||||
driver.get(SCHEMA + "://" + BASE_URL)
|
||||
self.assertTrue(NOM_DPT not in driver.page_source)
|
||||
|
||||
# ferme la fenetre à chaque fin de test
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
suppressionSiteDepartement.main()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="01_création_département",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
# coding: utf8
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
import suppressionSiteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
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
|
||||
|
||||
URL_ROOT = SCHEMA + "://" + + + ":" + SCODOC_PORT
|
||||
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"))
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
auth_page = URL_AUTH + "?next=%2F" + next_page
|
||||
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()
|
||||
self.driver.get(URL_SCODOC8)
|
||||
|
||||
# Test : Verification de la connexion admin effective
|
||||
# @expected : "Bonjour admin" est présent sur la page d'accueil
|
||||
def test_01_connexion_admin(self):
|
||||
driver = self.driver
|
||||
self.assertTrue("admin" in driver.page_source)
|
||||
|
||||
# Test : Creer un département
|
||||
# @expected : Le département est présent sur la page d'accueil
|
||||
def test_02_create_departement(self):
|
||||
driver = self.driver
|
||||
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
|
||||
time.sleep(2)
|
||||
select = Select(driver.find_element_by_id("create-dept"))
|
||||
select.select_by_visible_text(NOM_DPT)
|
||||
driver.find_element_by_id("create-dept").submit()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.get(URL_HOME)
|
||||
self.assertTrue(NOM_DPT in driver.page_source)
|
||||
|
||||
# Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données
|
||||
# @expected : Le département n'apparait plus sur la page d'accueil
|
||||
def test_03_delete_departement(self):
|
||||
driver = self.driver
|
||||
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
|
||||
select = Select(driver.find_element_by_id("delete-dept"))
|
||||
select.select_by_visible_text(NOM_DPT)
|
||||
driver.find_element_by_id("delete-dept").submit()
|
||||
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
|
||||
self.assertTrue(NOM_DPT not in driver.page_source)
|
||||
|
||||
# ferme la fenetre à chaque fin de test
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
suppressionSiteDepartement.main()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="01_création_département",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
|
@ -1,272 +1,271 @@
|
||||
# coding: utf8
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
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"))
|
||||
|
||||
ACRONYME_FORMATION = "formationtest"
|
||||
URL = URL_SCODOC8
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
|
||||
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()
|
||||
self.driver.get(URL_HOME)
|
||||
|
||||
# Test Creer une formation
|
||||
# @expected : La formation se trouve dans le tableau de la liste des formations
|
||||
def test_011_create_formation(self):
|
||||
global URL
|
||||
driver = self.driver
|
||||
wait = self.wait
|
||||
driver.get(URL_DEPT)
|
||||
driver.find_element_by_id("link-programmes").click()
|
||||
URL = driver.current_url
|
||||
driver.find_element_by_id("link-create-formation").click()
|
||||
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()
|
||||
driver.get(URL)
|
||||
formations = driver.find_elements_by_class_name("acronyme")
|
||||
textElementAcronyme = []
|
||||
for formation in formations:
|
||||
textElementAcronyme.append(formation.text)
|
||||
self.assertTrue(ACRONYME_FORMATION in textElementAcronyme)
|
||||
|
||||
# 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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
id_edit_formation = "edit-formation-" + ACRONYME_FORMATION.replace(" ","-")
|
||||
driver.find_element_by_id(id_edit_formation).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.get(URL)
|
||||
formations = driver.find_elements_by_class_name("acronyme")
|
||||
text_element_acronyme = []
|
||||
for formation in formations:
|
||||
text_element_acronyme.append(formation.text)
|
||||
self.assertTrue(ACRONYME_FORMATION + ACRONYME_FORMATION in text_element_acronyme)
|
||||
# Remise du nom à celui de départ
|
||||
driver.get(URL)
|
||||
id_edit_formation = "edit-formation-" + ACRONYME_FORMATION + ACRONYME_FORMATION
|
||||
driver.find_element_by_id(id_edit_formation).click()
|
||||
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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
driver.find_element_by_id("link-create-formation").click()
|
||||
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_class_name("error-message")
|
||||
message_erreur_present = True
|
||||
except NoSuchElementException:
|
||||
message_erreur_present = False
|
||||
self.assertTrue(message_erreur_present)
|
||||
|
||||
# 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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
id_titre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
||||
driver.find_element_by_id(id_titre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'ue_create?')]").click()
|
||||
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()
|
||||
time.sleep(1)
|
||||
driver.get(URL)
|
||||
driver.find_element_by_id(id_titre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
self.assertTrue("TEST UE TEST" in driver.page_source)
|
||||
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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
nomMat = "unematieretest"
|
||||
time.sleep(3)
|
||||
idTitre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
||||
driver.find_element_by_id(idTitre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
time.sleep(3)
|
||||
driver.find_element_by_xpath("//a[contains(@href,'matiere_create?')]").click()
|
||||
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)
|
||||
driver.get(URL)
|
||||
driver.find_element_by_id(idTitre).click()
|
||||
time.sleep(3)
|
||||
wait.until(EC.url_changes(URL))
|
||||
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)
|
||||
|
||||
# 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_016_ajout_Semestre(self):
|
||||
driver = self.driver
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
idAddSemestre = "add-semestre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
||||
driver.find_element_by_id(idAddSemestre).click()
|
||||
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("HAUSPIE Michael (bach)")
|
||||
Select(driver.find_element_by_id("tf_semestre_id")).select_by_value("4")
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
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 : 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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
idTitre = "titre-" + ACRONYME_FORMATION
|
||||
driver.find_element_by_id(idTitre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
tmpurl = driver.current_url
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formation_create_new_version?')]"
|
||||
).click()
|
||||
wait.until(EC.url_changes(tmpurl))
|
||||
self.assertTrue("Nouvelle version !" in driver.page_source)
|
||||
driver.get(URL)
|
||||
elements = driver.find_elements_by_class_name("version")
|
||||
version_is_present = False
|
||||
for element in elements:
|
||||
if element.text == "2":
|
||||
version_is_present = True
|
||||
self.assertTrue(version_is_present)
|
||||
|
||||
# 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):
|
||||
driver = self.driver
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
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(
|
||||
"//a[contains(@href, 'formsemestre_status?')]"
|
||||
)
|
||||
for semestre in liste_semestres:
|
||||
semestre.click()
|
||||
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()
|
||||
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(tmp_url_delete)
|
||||
driver.find_element_by_xpath(
|
||||
"//input[@value='Supprimer cette formation']"
|
||||
).click()
|
||||
driver.get(URL)
|
||||
formations = driver.find_elements_by_class_name("version")
|
||||
formation_delete = True
|
||||
for formation in formations:
|
||||
if "1" in formation.text:
|
||||
formation_delete = False
|
||||
self.assertTrue(formation_delete)
|
||||
|
||||
# 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__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="02_creation_formation_test",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
# coding: utf8
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
import creationUtilisateurs
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
NOM_DPT,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
URL_ROOT = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT
|
||||
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"))
|
||||
|
||||
ACRONYME_FORMATION = "formationtest"
|
||||
URL = URL_SCODOC8
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
auth_page = URL_AUTH + ("?next=" + URL_HOME).replace("/", "%2F")
|
||||
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()
|
||||
|
||||
# Test Creer une formation
|
||||
# @expected : La formation se trouve dans le tableau de la liste des formations
|
||||
def test_011_create_formation(self):
|
||||
global URL
|
||||
driver = self.driver
|
||||
wait = self.wait
|
||||
driver.get(URL_DEPT)
|
||||
driver.find_element_by_id("link-programmes").click()
|
||||
URL = driver.current_url
|
||||
driver.find_element_by_id("link-create-formation").click()
|
||||
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()
|
||||
driver.get(URL)
|
||||
formations = driver.find_elements_by_class_name("acronyme")
|
||||
textElementAcronyme = []
|
||||
for formation in formations:
|
||||
textElementAcronyme.append(formation.text)
|
||||
self.assertTrue(ACRONYME_FORMATION in textElementAcronyme)
|
||||
|
||||
# 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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
id_edit_formation = "edit-formation-" + ACRONYME_FORMATION.replace(" ","-")
|
||||
driver.find_element_by_id(id_edit_formation).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.get(URL)
|
||||
formations = driver.find_elements_by_class_name("acronyme")
|
||||
text_element_acronyme = []
|
||||
for formation in formations:
|
||||
text_element_acronyme.append(formation.text)
|
||||
self.assertTrue(ACRONYME_FORMATION + ACRONYME_FORMATION in text_element_acronyme)
|
||||
# Remise du nom à celui de départ
|
||||
driver.get(URL)
|
||||
id_edit_formation = "edit-formation-" + ACRONYME_FORMATION + ACRONYME_FORMATION
|
||||
driver.find_element_by_id(id_edit_formation).click()
|
||||
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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
driver.find_element_by_id("link-create-formation").click()
|
||||
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_class_name("error-message")
|
||||
message_erreur_present = True
|
||||
except NoSuchElementException:
|
||||
message_erreur_present = False
|
||||
self.assertTrue(message_erreur_present)
|
||||
|
||||
# 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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
id_titre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
||||
driver.find_element_by_id(id_titre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'ue_create?')]").click()
|
||||
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()
|
||||
time.sleep(1)
|
||||
driver.get(URL)
|
||||
driver.find_element_by_id(id_titre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
self.assertTrue("TEST UE TEST" in driver.page_source)
|
||||
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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
nomMat = "unematieretest"
|
||||
time.sleep(3)
|
||||
idTitre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
||||
driver.find_element_by_id(idTitre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
time.sleep(3)
|
||||
driver.find_element_by_xpath("//a[contains(@href,'matiere_create?')]").click()
|
||||
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)
|
||||
driver.get(URL)
|
||||
driver.find_element_by_id(idTitre).click()
|
||||
time.sleep(3)
|
||||
wait.until(EC.url_changes(URL))
|
||||
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)
|
||||
|
||||
# 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_016_ajout_Semestre(self):
|
||||
driver = self.driver
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
idAddSemestre = "add-semestre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
|
||||
driver.find_element_by_id(idAddSemestre).click()
|
||||
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 Jean-Sebastien (Bach)")
|
||||
Select(driver.find_element_by_id("tf_semestre_id")).select_by_value("4")
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
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 : 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
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
idTitre = "titre-" + ACRONYME_FORMATION
|
||||
driver.find_element_by_id(idTitre).click()
|
||||
wait.until(EC.url_changes(URL))
|
||||
tmpurl = driver.current_url
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formation_create_new_version?')]"
|
||||
).click()
|
||||
wait.until(EC.url_changes(tmpurl))
|
||||
self.assertTrue("Nouvelle version !" in driver.page_source)
|
||||
driver.get(URL)
|
||||
elements = driver.find_elements_by_class_name("version")
|
||||
version_is_present = False
|
||||
for element in elements:
|
||||
if element.text == "2":
|
||||
version_is_present = True
|
||||
self.assertTrue(version_is_present)
|
||||
|
||||
# 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):
|
||||
driver = self.driver
|
||||
wait = self.wait
|
||||
driver.get(URL)
|
||||
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(
|
||||
"//a[contains(@href, 'formsemestre_status?')]"
|
||||
)
|
||||
for semestre in liste_semestres:
|
||||
semestre.click()
|
||||
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()
|
||||
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(tmp_url_delete)
|
||||
driver.find_element_by_xpath(
|
||||
"//input[@value='Supprimer cette formation']"
|
||||
).click()
|
||||
driver.get(URL)
|
||||
formations = driver.find_elements_by_class_name("version")
|
||||
formation_delete = True
|
||||
for formation in formations:
|
||||
if "1" in formation.text:
|
||||
formation_delete = False
|
||||
self.assertTrue(formation_delete)
|
||||
|
||||
# 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__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
creationUtilisateurs.main()
|
||||
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="02_creation_formation_test",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
|
@ -1,206 +1,215 @@
|
||||
import unittest
|
||||
import time
|
||||
import HtmlTestRunner
|
||||
import subprocess
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
import urllib.parse as urlparse
|
||||
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.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
|
||||
nomEtu = "Semestre11"
|
||||
prenomEtu = "Etudiant1"
|
||||
nip = "11122234"
|
||||
domicile = "50 rue de la marmite"
|
||||
codepostaldomicile = "59000"
|
||||
paysdomicile = "Lille"
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
|
||||
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()
|
||||
self.driver.get(SCHEMA + "://" + BASE_URL)
|
||||
|
||||
# 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
|
||||
def test_01_creation_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("link-create-student").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
URL = driver.current_url
|
||||
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_annee").send_keys("2021")
|
||||
driver.find_element_by_id("tf_code_nip").send_keys(nip)
|
||||
driver.find_element_by_name("dont_check_homonyms:list").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
self.assertTrue("M. " + prenomEtu + " " + nomEtu.upper() in driver.page_source)
|
||||
self.assertTrue(nip in driver.page_source)
|
||||
|
||||
# Test : Creer un étudiant avec un nip qui est déjà présent dans la base Scodoc
|
||||
# @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):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
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_annee").send_keys("2021")
|
||||
driver.find_element_by_id("tf_code_nip").send_keys(nip)
|
||||
driver.find_element_by_name("dont_check_homonyms:list").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Code étudiant (code_nip) dupliqué !"
|
||||
in driver.find_element_by_class_name("title-error").text
|
||||
)
|
||||
|
||||
# Test Modification de l'adresse étudiant
|
||||
# expected : La nouvelle adresse est mise à jour sur la page information de l'étudiant
|
||||
def test_03_modification_adresse_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
element = driver.find_element_by_id("in-expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formChangeCoordonnees')]"
|
||||
).click()
|
||||
time.sleep(1)
|
||||
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_paysdomicile").send_keys(paysdomicile)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
codepostaldomicile in driver.find_element_by_id("student-address").text
|
||||
)
|
||||
|
||||
# Test Inscription d'un étudiant dans un semestre
|
||||
# @expected :
|
||||
def test_04_inscription_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
element = driver.find_element_by_id("in-expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href, 'formsemestre_inscription_with_modules_form')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
try:
|
||||
semestres = driver.find_elements_by_xpath(
|
||||
"//a[contains(@id,'inscription-semestre-')]"
|
||||
)
|
||||
except NoSuchElementException:
|
||||
self.assertFalse(True)
|
||||
semestres[0].click()
|
||||
driver.find_element_by_xpath("//input[@value='Inscrire']").click()
|
||||
time.sleep(2)
|
||||
boutonInscrireIsNotPresent = False
|
||||
try:
|
||||
driver.find_element_by_partial_link_text("inscrire")
|
||||
except:
|
||||
boutonInscrireIsNotPresent = True
|
||||
self.assertTrue(boutonInscrireIsNotPresent)
|
||||
|
||||
# Test Supprime un étudiant
|
||||
# @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait
|
||||
def test_05_suppresion_etudiant(self):
|
||||
driver = self.driver
|
||||
urlRecherche = (
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ BASE_URL
|
||||
+ "ScoDoc/"
|
||||
+ NOM_DPT
|
||||
+ "/Scolarite/search_etud_in_dept"
|
||||
)
|
||||
driver.get(urlRecherche)
|
||||
element = driver.find_element_by_name("expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
time.sleep(1)
|
||||
etudid = driver.find_element_by_id("euid")
|
||||
url = (
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ BASE_URL
|
||||
+ "ScoDoc/"
|
||||
+ NOM_DPT
|
||||
+ "/Scolarite/etudident_delete?etudid="
|
||||
+ etudid.text
|
||||
)
|
||||
driver.get(url)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_xpath(
|
||||
"//input[@value='Supprimer définitivement cet étudiant']"
|
||||
).click()
|
||||
driver.get(urlRecherche)
|
||||
element = driver.find_element_by_name("expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
time.sleep(1)
|
||||
try:
|
||||
element = driver.find_element_by_id("title-no-result")
|
||||
self.assertTrue("Aucun résultat" in element.text)
|
||||
except:
|
||||
self.assertFalse(True)
|
||||
|
||||
# ferme la fenetre
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario1_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="03_Etudiant_test",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
import unittest
|
||||
import time
|
||||
import HtmlTestRunner
|
||||
import subprocess
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
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.select import Select
|
||||
|
||||
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
|
||||
nomEtu = "Semestre11"
|
||||
prenomEtu = "Etudiant1"
|
||||
nip = "11122234"
|
||||
domicile = "50 rue de la marmite"
|
||||
codepostaldomicile = "59000"
|
||||
paysdomicile = "Lille"
|
||||
|
||||
URL_ROOT = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT
|
||||
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"))
|
||||
|
||||
ACRONYME_FORMATION = "formationtest"
|
||||
URL = URL_SCODOC8
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
|
||||
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()
|
||||
self.driver.get(URL_HOME)
|
||||
|
||||
# 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
|
||||
def test_01_creation_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("link-create-student").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
URL = driver.current_url
|
||||
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_annee").send_keys("2021")
|
||||
driver.find_element_by_id("tf_code_nip").send_keys(nip)
|
||||
driver.find_element_by_name("dont_check_homonyms:list").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
self.assertTrue("M. " + prenomEtu + " " + nomEtu.upper() in driver.page_source)
|
||||
self.assertTrue(nip in driver.page_source)
|
||||
|
||||
# Test : Creer un étudiant avec un nip qui est déjà présent dans la base Scodoc
|
||||
# @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):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
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_annee").send_keys("2021")
|
||||
driver.find_element_by_id("tf_code_nip").send_keys(nip)
|
||||
driver.find_element_by_name("dont_check_homonyms:list").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Code étudiant (code_nip) dupliqué !"
|
||||
in driver.find_element_by_class_name("title-error").text
|
||||
)
|
||||
|
||||
# Test Modification de l'adresse étudiant
|
||||
# expected : La nouvelle adresse est mise à jour sur la page information de l'étudiant
|
||||
def test_03_modification_adresse_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
element = driver.find_element_by_id("in-expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formChangeCoordonnees')]"
|
||||
).click()
|
||||
time.sleep(1)
|
||||
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_paysdomicile").send_keys(paysdomicile)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
codepostaldomicile in driver.find_element_by_id("student-address").text
|
||||
)
|
||||
|
||||
# Test Inscription d'un étudiant dans un semestre
|
||||
# @expected :
|
||||
def test_04_inscription_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
element = driver.find_element_by_id("in-expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href, 'formsemestre_inscription_with_modules_form')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
try:
|
||||
semestres = driver.find_elements_by_xpath(
|
||||
"//a[contains(@id,'inscription-semestre-')]"
|
||||
)
|
||||
except NoSuchElementException:
|
||||
self.assertFalse(True)
|
||||
semestres[0].click()
|
||||
driver.find_element_by_xpath("//input[@value='Inscrire']").click()
|
||||
time.sleep(2)
|
||||
bouton_inscrire_is_not_present = False
|
||||
try:
|
||||
driver.find_element_by_partial_link_text("inscrire")
|
||||
except:
|
||||
bouton_inscrire_is_not_present = True
|
||||
self.assertTrue(bouton_inscrire_is_not_present)
|
||||
|
||||
# Test Supprime un étudiant
|
||||
# @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait
|
||||
def test_05_suppresion_etudiant(self):
|
||||
driver = self.driver
|
||||
urlRecherche = (
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_SERVER + ":" + SCODOC_PORT
|
||||
+ "ScoDoc/"
|
||||
+ NOM_DPT
|
||||
+ "/Scolarite/search_etud_in_dept"
|
||||
)
|
||||
driver.get(urlRecherche)
|
||||
element = driver.find_element_by_name("expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
time.sleep(1)
|
||||
etudid = driver.find_element_by_id("euid")
|
||||
url = (
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_SERVER + ":" + SCODOC_PORT
|
||||
+ "ScoDoc/"
|
||||
+ NOM_DPT
|
||||
+ "/Scolarite/etudident_delete?etudid="
|
||||
+ etudid.text
|
||||
)
|
||||
driver.get(url)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_xpath(
|
||||
"//input[@value='Supprimer définitivement cet étudiant']"
|
||||
).click()
|
||||
driver.get(urlRecherche)
|
||||
element = driver.find_element_by_name("expnom")
|
||||
element.send_keys(nomEtu)
|
||||
element.submit()
|
||||
time.sleep(1)
|
||||
try:
|
||||
element = driver.find_element_by_id("title-no-result")
|
||||
self.assertTrue("Aucun résultat" in element.text)
|
||||
except:
|
||||
self.assertFalse(True)
|
||||
|
||||
# ferme la fenetre
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario1_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="03_Etudiant_test",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
|
@ -1,170 +1,171 @@
|
||||
import unittest
|
||||
import time
|
||||
import urllib.parse as urlparse
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
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
|
||||
|
||||
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
|
||||
NOM_ETU = "Semestre11"
|
||||
PRENOM_ETU = "EtudiantNumero1"
|
||||
dateDebutAbsenceNonJustifiee = "31/05/2021"
|
||||
dateDebutAbsenceJustifiee = "25/05/2021"
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
|
||||
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()
|
||||
self.driver.get(SCHEMA + "://" + BASE_URL)
|
||||
|
||||
def test_010_trouver_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
self.driver.get(SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite")
|
||||
element = self.driver.find_element_by_id("in-expnom")
|
||||
element.send_keys(NOM_ETU)
|
||||
element.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
URL = driver.current_url
|
||||
self.assertTrue(NOM_ETU.upper() in driver.page_source)
|
||||
|
||||
# Test : creer une absence non justifiée
|
||||
# @expected : La fiche étudiante est incrémentée avec le nombre d'absence injustifiée correspondant
|
||||
def test_020_ajout_absence_non_justifiee(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("add-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
|
||||
driver.find_element_by_id("butsubmit").submit()
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Ajout de 2 absences <b>NON justifiées</b>" in driver.page_source
|
||||
)
|
||||
|
||||
driver = self.driver
|
||||
driver.find_element_by_link_text("Liste").click()
|
||||
self.assertTrue("2 absences non justifiées:" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_absence_non_justifiee(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("2 absences non justifiées:" in driver.page_source)
|
||||
|
||||
# Test pour ajouter deux absences justifiées
|
||||
# @expected : La fiche d'information de l'étudiant concerné à son compteur d'absence augmenté de 2
|
||||
def test_021_ajout_absence_justifiee(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("add-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
||||
driver.find_element_by_name("estjust").click()
|
||||
driver.find_element_by_id("butsubmit").submit()
|
||||
time.sleep(1)
|
||||
self.assertTrue("Ajout de 2 absences <b>justifiées</b>" in driver.page_source)
|
||||
driver = self.driver
|
||||
driver.find_element_by_link_text("Liste").click()
|
||||
self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_absence_justifiee(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
|
||||
# Test Justification d'une absence non justifiée
|
||||
# @expected : Le champs des absences non justifiées diminue et celui des justifiés augmente du nombre d'absence
|
||||
def test_022_ajout_justification(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("justify-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
||||
driver.find_element_by_name("description").send_keys("Un test selenium")
|
||||
driver.find_element_by_xpath("//input[@value='Envoyer']").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
self.assertTrue("Ajout de 2 <b>justifications</b>" in driver.page_source)
|
||||
driver = self.driver
|
||||
driver.find_element_by_link_text("Liste").click()
|
||||
self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
self.assertTrue("absences non justifiées:" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_ajout_justification(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("4 absences justifiées:" in driver.page_source)
|
||||
# self.assertTrue("absences non justifiées:" not in driver.page_source)
|
||||
|
||||
# Test Suppression des absences pour un élève
|
||||
# @expected : Les compteurs d'absences sont remplacés par "Pas d'absences"
|
||||
def test_024_supprimer_absence(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("delete-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
||||
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
self.assertTrue("Annulation sur 2 demi-journées " in driver.page_source)
|
||||
driver.find_element_by_id("delete-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
|
||||
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_id("display-list-absence").click()
|
||||
self.assertTrue("Pas d'absences justifiées" in driver.page_source)
|
||||
self.assertTrue("Pas d'absences non justifiées" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_supression_absence(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
# self.assertTrue("absences non justifiées:" not in driver.page_source)
|
||||
|
||||
# ferme la fenetre
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario2_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="04_Absences_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
import unittest
|
||||
import time
|
||||
import urllib.parse as urlparse
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
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
|
||||
|
||||
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
|
||||
NOM_ETU = "Semestre11"
|
||||
PRENOM_ETU = "EtudiantNumero1"
|
||||
dateDebutAbsenceNonJustifiee = "31/05/2021"
|
||||
dateDebutAbsenceJustifiee = "25/05/2021"
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
|
||||
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()
|
||||
self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
|
||||
|
||||
def test_010_trouver_etudiant(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite")
|
||||
element = self.driver.find_element_by_id("in-expnom")
|
||||
element.send_keys(NOM_ETU)
|
||||
element.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
URL = driver.current_url
|
||||
self.assertTrue(NOM_ETU.upper() in driver.page_source)
|
||||
|
||||
# Test : creer une absence non justifiée
|
||||
# @expected : La fiche étudiante est incrémentée avec le nombre d'absence injustifiée correspondant
|
||||
def test_020_ajout_absence_non_justifiee(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("add-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
|
||||
driver.find_element_by_id("butsubmit").submit()
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Ajout de 2 absences <b>NON justifiées</b>" in driver.page_source
|
||||
)
|
||||
|
||||
driver = self.driver
|
||||
driver.find_element_by_link_text("Liste").click()
|
||||
self.assertTrue("2 absences non justifiées:" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_absence_non_justifiee(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("2 absences non justifiées:" in driver.page_source)
|
||||
|
||||
# Test pour ajouter deux absences justifiées
|
||||
# @expected : La fiche d'information de l'étudiant concerné à son compteur d'absence augmenté de 2
|
||||
def test_021_ajout_absence_justifiee(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("add-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
||||
driver.find_element_by_name("estjust").click()
|
||||
driver.find_element_by_id("butsubmit").submit()
|
||||
time.sleep(1)
|
||||
self.assertTrue("Ajout de 2 absences <b>justifiées</b>" in driver.page_source)
|
||||
driver = self.driver
|
||||
driver.find_element_by_link_text("Liste").click()
|
||||
self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_absence_justifiee(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
|
||||
# Test Justification d'une absence non justifiée
|
||||
# @expected : Le champs des absences non justifiées diminue et celui des justifiés augmente du nombre d'absence
|
||||
def test_022_ajout_justification(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("justify-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
||||
driver.find_element_by_name("description").send_keys("Un test selenium")
|
||||
driver.find_element_by_xpath("//input[@value='Envoyer']").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
self.assertTrue("Ajout de 2 <b>justifications</b>" in driver.page_source)
|
||||
driver = self.driver
|
||||
driver.find_element_by_link_text("Liste").click()
|
||||
self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
self.assertTrue("absences non justifiées:" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_ajout_justification(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("4 absences justifiées:" in driver.page_source)
|
||||
# self.assertTrue("absences non justifiées:" not in driver.page_source)
|
||||
|
||||
# Test Suppression des absences pour un élève
|
||||
# @expected : Les compteurs d'absences sont remplacés par "Pas d'absences"
|
||||
def test_024_supprimer_absence(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.find_element_by_id("delete-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
|
||||
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
self.assertTrue("Annulation sur 2 demi-journées " in driver.page_source)
|
||||
driver.find_element_by_id("delete-absence").click()
|
||||
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
|
||||
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_id("display-list-absence").click()
|
||||
self.assertTrue("Pas d'absences justifiées" in driver.page_source)
|
||||
self.assertTrue("Pas d'absences non justifiées" in driver.page_source)
|
||||
|
||||
# def test_modification_liste_supression_absence(self):
|
||||
# driver = self.driver
|
||||
# driver.find_element_by_link_text("Liste").click()
|
||||
# self.assertTrue("2 absences justifiées:" in driver.page_source)
|
||||
# self.assertTrue("absences non justifiées:" not in driver.page_source)
|
||||
|
||||
# ferme la fenetre
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario2_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="04_Absences_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
|
@ -1,403 +1,404 @@
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import urllib.parse as urlparse
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
NOM_DPT,
|
||||
SCODOC_ENS_ID,
|
||||
SCODOC_ENS_PASS,
|
||||
SCODOC_CHEF_ID,
|
||||
SCODOC_CHEF_PASS,
|
||||
NAVIGATEUR,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
)
|
||||
from urllib.parse import parse_qs
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
URL_MATIERE = ""
|
||||
URL_SEMESTRE = ""
|
||||
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
|
||||
PRENOM_ENS = "Ens"
|
||||
PRENOM_CHEF = "Chef"
|
||||
isAdmin = True
|
||||
isChef = False
|
||||
isEns = False
|
||||
# Prérequis
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
|
||||
self.driver.get(auth_page)
|
||||
if isAdmin:
|
||||
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)
|
||||
elif isChef:
|
||||
self.driver.find_element_by_id("user_name").send_keys(SCODOC_CHEF_ID)
|
||||
self.driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
|
||||
elif isEns:
|
||||
self.driver.find_element_by_id("user_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()
|
||||
self.driver.get(SCHEMA + "://" + BASE_URL)
|
||||
|
||||
# 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_010_semestre_en_cours(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
# time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Sessions en cours" in driver.find_element_by_class_name("listesems").text
|
||||
)
|
||||
|
||||
# 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_020_matiere_existante(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
driver.find_element_by_link_text("semestre 4").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
matiereExist = False
|
||||
try:
|
||||
driver.find_element_by_class_name("formsemestre_status_ue")
|
||||
global URL_SEMESTRE
|
||||
URL_SEMESTRE = driver.current_url
|
||||
matiereExist = True
|
||||
except NoSuchElementException:
|
||||
matiereExist = False
|
||||
self.assertTrue(matiereExist)
|
||||
|
||||
#Test : Changement de responsable sur module
|
||||
# @expected : Le nom du responsable choisi apparait désormais sur le module concerné
|
||||
def test_030_changement_responsable_sur_module(self):
|
||||
driver = self.driver
|
||||
isThere = False
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M4101C").click()
|
||||
time.sleep(1)
|
||||
global URL_MATIERE
|
||||
URL_MATIERE = driver.current_url
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'edit_moduleimpl_resp?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_MATIERE))
|
||||
constructIdResponsable = (
|
||||
SCODOC_CHEF_ID.upper()
|
||||
+ " "
|
||||
+ PRENOM_CHEF
|
||||
+ " ("
|
||||
+ SCODOC_CHEF_ID.lower()
|
||||
+ ")"
|
||||
)
|
||||
idInput = driver.find_element_by_name("responsable_id")
|
||||
idInput.clear()
|
||||
idInput.send_keys(constructIdResponsable)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.get(URL_MATIERE)
|
||||
nomResponsable = driver.find_element_by_id("ens-responsable")
|
||||
self.assertTrue(SCODOC_CHEF_ID.lower() in nomResponsable.text.lower())
|
||||
global isAdmin
|
||||
isAdmin = False
|
||||
global isChef
|
||||
isChef = True
|
||||
|
||||
# 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_031_ajout_enseignant_sur_module(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(2)
|
||||
driver.find_element_by_partial_link_text("modifier les enseignants").click()
|
||||
time.sleep(1)
|
||||
constructIDEns = (
|
||||
SCODOC_ENS_ID.upper() + " " + PRENOM_ENS + " (" + SCODOC_ENS_ID + ")"
|
||||
)
|
||||
driver.find_element_by_id("ens_id").send_keys(constructIDEns)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.get(URL_MATIERE)
|
||||
professeurDansModule = driver.find_elements_by_class_name("ens-in-module")
|
||||
time.sleep(5)
|
||||
professeurString = []
|
||||
for professeur in professeurDansModule:
|
||||
professeurString.append(professeur.text)
|
||||
for professeurS in professeurString:
|
||||
if SCODOC_ENS_ID.lower() in professeurS.lower():
|
||||
isThere = True
|
||||
self.assertTrue(isThere)
|
||||
|
||||
# Test : Création d'une interrogation en tant que chef des études
|
||||
# @eexpected : L'interrogation apparait désormais dans ce module
|
||||
def test_040_creation_interrogation(self):
|
||||
descriptionInterrogation = "Interrogation numero 2"
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
# driver.get(SCHEMA + "://" + BASE_URL)
|
||||
# driver.find_element_by_link_text("déconnecter").click()
|
||||
# driver.get(SCHEMA + "://" + 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_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_name("jour").clear()
|
||||
driver.find_element_by_name("jour").send_keys("31/05/2021")
|
||||
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)
|
||||
global isChef
|
||||
isChef = False
|
||||
global isEns
|
||||
isEns = True
|
||||
self.assertTrue(descriptionInterrogation in driver.page_source)
|
||||
|
||||
# Test Vérifie si une interrogation existe sur un module
|
||||
# @expected "Module" est présent dans le "formsemetre"
|
||||
def test_050_interro_existante(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Module" in driver.find_element_by_class_name("formsemestre").text
|
||||
)
|
||||
|
||||
# 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_060_entree_note(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
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.assertTrue(
|
||||
driver.find_element_by_link_text("afficher").text in driver.page_source
|
||||
)
|
||||
|
||||
# Test : Ajoute les notes manquante poru les étudiants concernés dans une interrogation
|
||||
# @expected : Tout les étudiants on une note
|
||||
def test_070_ajout_note_incomplete(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_class_name("notes_img").click()
|
||||
elements = driver.find_elements_by_class_name("note")
|
||||
for element in elements:
|
||||
if element.get_attribute("value") == "":
|
||||
element.send_keys(15)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
time.sleep(5)
|
||||
element = driver.find_element_by_id("in-expnom")
|
||||
element.send_keys("SEMESTRE47")
|
||||
element.submit()
|
||||
time.sleep(5)
|
||||
self.assertTrue("12" in driver.find_element_by_class_name("rcp_moy").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_080_suppression_note(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_class_name("notes_img").click()
|
||||
time.sleep(1)
|
||||
elements = driver.find_elements_by_class_name("note")
|
||||
for element in elements:
|
||||
element.clear()
|
||||
element.send_keys("SUPR")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
time.sleep(1)
|
||||
interro_non_Presente = False
|
||||
try:
|
||||
driver.find_element_by_link_text("afficher")
|
||||
interro_non_Presente = False
|
||||
except NoSuchElementException:
|
||||
interro_non_Presente = True
|
||||
self.assertTrue(interro_non_Presente)
|
||||
global isChef
|
||||
isChef = True
|
||||
global isEns
|
||||
isEns = False
|
||||
|
||||
# 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_090_suppresion_interrogation(self):
|
||||
global URL_MATIERE
|
||||
descriptionInterrogation = "Interrogation à supprimer"
|
||||
driver = self.driver
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_name("jour").clear()
|
||||
driver.find_element_by_name("jour").send_keys("30/05/2021")
|
||||
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()
|
||||
# global isAdmin
|
||||
# isAdmin = True
|
||||
# global isEns
|
||||
# isEns = False
|
||||
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_200_suppression_enseignant_sur_module(self):
|
||||
driver = self.driver
|
||||
driver.get(URL_MATIERE)
|
||||
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)
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(5)
|
||||
self.assertTrue(SCODOC_ENS_ID not in driver.page_source)
|
||||
|
||||
# Test : Suppresion du reste des interrogations sans notes
|
||||
# @expected Tout les interrogation sans notes sont supprimées
|
||||
def test_910_suppresion_interrogation_restante(self):
|
||||
driver = self.driver
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
elements = driver.find_elements_by_xpath(
|
||||
"//a[contains(@href,'evaluation_delete?')]"
|
||||
)
|
||||
while elements:
|
||||
elements[0].click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_partial_link_text("Continuer").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
elements = driver.find_elements_by_xpath(
|
||||
"//a[contains(@href,'evaluation_delete?')]"
|
||||
)
|
||||
|
||||
# ferme la fenetre et fais du clean up
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if NAVIGATEUR == "firefox":
|
||||
driver = webdriver.Firefox()
|
||||
else:
|
||||
driver = webdriver.Chrome()
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario2_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
time.sleep(5)
|
||||
driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
driver.get(SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite")
|
||||
driver.find_element_by_id("link-view-users").click()
|
||||
time.sleep(5)
|
||||
noms = driver.find_elements_by_class_name("nom_fmt")
|
||||
chefCree = False
|
||||
ensCree = False
|
||||
for nom in noms:
|
||||
if nom.text.lower() == SCODOC_CHEF_ID.lower():
|
||||
chefCree = True
|
||||
if nom.text.lower() == SCODOC_ENS_ID.lower():
|
||||
ensCree = True
|
||||
if not chefCree:
|
||||
time.sleep(2)
|
||||
constructValue = "Ens" + NOM_DPT
|
||||
driver.find_element_by_id("create-user").click()
|
||||
driver.find_element_by_id("tf_nom").send_keys(SCODOC_CHEF_ID)
|
||||
driver.find_element_by_id("tf_user_name").send_keys(SCODOC_CHEF_ID)
|
||||
driver.find_element_by_id("tf_prenom").send_keys("chef")
|
||||
driver.find_element_by_id("tf_passwd").send_keys(SCODOC_CHEF_PASS)
|
||||
driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_CHEF_PASS)
|
||||
driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click()
|
||||
driver.find_element_by_xpath("//input[@name='force:list']").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.find_element_by_id("link-view-users").click()
|
||||
if not ensCree:
|
||||
time.sleep(2)
|
||||
constructValue = "Ens" + NOM_DPT
|
||||
driver.find_element_by_id("create-user").click()
|
||||
driver.find_element_by_id("tf_nom").send_keys(SCODOC_ENS_ID)
|
||||
driver.find_element_by_id("tf_user_name").send_keys(SCODOC_ENS_ID)
|
||||
driver.find_element_by_id("tf_prenom").send_keys(PRENOM_ENS)
|
||||
driver.find_element_by_id("tf_passwd").send_keys(SCODOC_ENS_PASS)
|
||||
driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_ENS_PASS)
|
||||
driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click()
|
||||
driver.find_element_by_xpath("//input[@name='force:list']").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.find_element_by_id("link-view-users").click()
|
||||
driver.close()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="05_Saisie_note_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import urllib.parse as urlparse
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
NOM_DPT,
|
||||
SCODOC_ENS_ID,
|
||||
SCODOC_ENS_PASS,
|
||||
SCODOC_CHEF_ID,
|
||||
SCODOC_CHEF_PASS,
|
||||
NAVIGATEUR,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
)
|
||||
from urllib.parse import parse_qs
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
URL_MATIERE = ""
|
||||
URL_SEMESTRE = ""
|
||||
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
|
||||
PRENOM_ENS = "Ens"
|
||||
PRENOM_CHEF = "Chef"
|
||||
isAdmin = True
|
||||
isChef = False
|
||||
isEns = False
|
||||
# Prérequis
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
next_page = ""
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Chrome()
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
|
||||
self.driver.get(auth_page)
|
||||
if isAdmin:
|
||||
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)
|
||||
elif isChef:
|
||||
self.driver.find_element_by_id("user_name").send_keys(SCODOC_CHEF_ID)
|
||||
self.driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
|
||||
elif isEns:
|
||||
self.driver.find_element_by_id("user_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()
|
||||
self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
|
||||
|
||||
# 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_010_semestre_en_cours(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
# time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Sessions en cours" in driver.find_element_by_class_name("listesems").text
|
||||
)
|
||||
|
||||
# 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_020_matiere_existante(self):
|
||||
driver = self.driver
|
||||
global URL
|
||||
driver.get(URL)
|
||||
driver.find_element_by_link_text("semestre 4").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
matiereExist = False
|
||||
try:
|
||||
driver.find_element_by_class_name("formsemestre_status_ue")
|
||||
global URL_SEMESTRE
|
||||
URL_SEMESTRE = driver.current_url
|
||||
matiereExist = True
|
||||
except NoSuchElementException:
|
||||
matiereExist = False
|
||||
self.assertTrue(matiereExist)
|
||||
|
||||
#Test : Changement de responsable sur module
|
||||
# @expected : Le nom du responsable choisi apparait désormais sur le module concerné
|
||||
def test_030_changement_responsable_sur_module(self):
|
||||
driver = self.driver
|
||||
isThere = False
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M4101C").click()
|
||||
time.sleep(1)
|
||||
global URL_MATIERE
|
||||
URL_MATIERE = driver.current_url
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'edit_moduleimpl_resp?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_MATIERE))
|
||||
constructIdResponsable = (
|
||||
SCODOC_CHEF_ID.upper()
|
||||
+ " "
|
||||
+ PRENOM_CHEF
|
||||
+ " ("
|
||||
+ SCODOC_CHEF_ID.lower()
|
||||
+ ")"
|
||||
)
|
||||
idInput = driver.find_element_by_name("responsable_id")
|
||||
idInput.clear()
|
||||
idInput.send_keys(constructIdResponsable)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.get(URL_MATIERE)
|
||||
nomResponsable = driver.find_element_by_id("ens-responsable")
|
||||
self.assertTrue(SCODOC_CHEF_ID.lower() in nomResponsable.text.lower())
|
||||
global isAdmin
|
||||
isAdmin = False
|
||||
global isChef
|
||||
isChef = True
|
||||
|
||||
# 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_031_ajout_enseignant_sur_module(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(2)
|
||||
driver.find_element_by_partial_link_text("modifier les enseignants").click()
|
||||
time.sleep(1)
|
||||
constructIDEns = (
|
||||
SCODOC_ENS_ID.upper() + " " + PRENOM_ENS + " (" + SCODOC_ENS_ID + ")"
|
||||
)
|
||||
driver.find_element_by_id("ens_id").send_keys(constructIDEns)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.get(URL_MATIERE)
|
||||
professeurDansModule = driver.find_elements_by_class_name("ens-in-module")
|
||||
time.sleep(5)
|
||||
professeurString = []
|
||||
for professeur in professeurDansModule:
|
||||
professeurString.append(professeur.text)
|
||||
for professeurS in professeurString:
|
||||
if SCODOC_ENS_ID.lower() in professeurS.lower():
|
||||
isThere = True
|
||||
self.assertTrue(isThere)
|
||||
|
||||
# Test : Création d'une interrogation en tant que chef des études
|
||||
# @eexpected : L'interrogation apparait désormais dans ce module
|
||||
def test_040_creation_interrogation(self):
|
||||
descriptionInterrogation = "Interrogation numero 2"
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
# driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
|
||||
# driver.find_element_by_link_text("déconnecter").click()
|
||||
# driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
|
||||
# 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_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_name("jour").clear()
|
||||
driver.find_element_by_name("jour").send_keys("31/05/2021")
|
||||
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)
|
||||
global isChef
|
||||
isChef = False
|
||||
global isEns
|
||||
isEns = True
|
||||
self.assertTrue(descriptionInterrogation in driver.page_source)
|
||||
|
||||
# Test Vérifie si une interrogation existe sur un module
|
||||
# @expected "Module" est présent dans le "formsemetre"
|
||||
def test_050_interro_existante(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
self.assertTrue(
|
||||
"Module" in driver.find_element_by_class_name("formsemestre").text
|
||||
)
|
||||
|
||||
# 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_060_entree_note(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
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.assertTrue(
|
||||
driver.find_element_by_link_text("afficher").text in driver.page_source
|
||||
)
|
||||
|
||||
# Test : Ajoute les notes manquante poru les étudiants concernés dans une interrogation
|
||||
# @expected : Tout les étudiants on une note
|
||||
def test_070_ajout_note_incomplete(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_class_name("notes_img").click()
|
||||
elements = driver.find_elements_by_class_name("note")
|
||||
for element in elements:
|
||||
if element.get_attribute("value") == "":
|
||||
element.send_keys(15)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
time.sleep(5)
|
||||
element = driver.find_element_by_id("in-expnom")
|
||||
element.send_keys("SEMESTRE47")
|
||||
element.submit()
|
||||
time.sleep(5)
|
||||
self.assertTrue("12" in driver.find_element_by_class_name("rcp_moy").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_080_suppression_note(self):
|
||||
driver = self.driver
|
||||
global URL_MATIERE
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_class_name("notes_img").click()
|
||||
time.sleep(1)
|
||||
elements = driver.find_elements_by_class_name("note")
|
||||
for element in elements:
|
||||
element.clear()
|
||||
element.send_keys("SUPR")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
time.sleep(1)
|
||||
interro_non_Presente = False
|
||||
try:
|
||||
driver.find_element_by_link_text("afficher")
|
||||
interro_non_Presente = False
|
||||
except NoSuchElementException:
|
||||
interro_non_Presente = True
|
||||
self.assertTrue(interro_non_Presente)
|
||||
global isChef
|
||||
isChef = True
|
||||
global isEns
|
||||
isEns = False
|
||||
|
||||
# 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_090_suppresion_interrogation(self):
|
||||
global URL_MATIERE
|
||||
descriptionInterrogation = "Interrogation à supprimer"
|
||||
driver = self.driver
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_name("jour").clear()
|
||||
driver.find_element_by_name("jour").send_keys("30/05/2021")
|
||||
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()
|
||||
# global isAdmin
|
||||
# isAdmin = True
|
||||
# global isEns
|
||||
# isEns = False
|
||||
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_200_suppression_enseignant_sur_module(self):
|
||||
driver = self.driver
|
||||
driver.get(URL_MATIERE)
|
||||
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)
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(5)
|
||||
self.assertTrue(SCODOC_ENS_ID not in driver.page_source)
|
||||
|
||||
# Test : Suppresion du reste des interrogations sans notes
|
||||
# @expected Tout les interrogation sans notes sont supprimées
|
||||
def test_910_suppresion_interrogation_restante(self):
|
||||
driver = self.driver
|
||||
driver.get(URL_MATIERE)
|
||||
time.sleep(1)
|
||||
elements = driver.find_elements_by_xpath(
|
||||
"//a[contains(@href,'evaluation_delete?')]"
|
||||
)
|
||||
while elements:
|
||||
elements[0].click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.find_element_by_partial_link_text("Continuer").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
elements = driver.find_elements_by_xpath(
|
||||
"//a[contains(@href,'evaluation_delete?')]"
|
||||
)
|
||||
|
||||
# ferme la fenetre et fais du clean up
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if NAVIGATEUR == "firefox":
|
||||
driver = webdriver.Firefox()
|
||||
else:
|
||||
driver = webdriver.Chrome()
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario2_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
time.sleep(5)
|
||||
driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite")
|
||||
driver.find_element_by_id("link-view-users").click()
|
||||
time.sleep(5)
|
||||
noms = driver.find_elements_by_class_name("nom_fmt")
|
||||
chefCree = False
|
||||
ensCree = False
|
||||
for nom in noms:
|
||||
if nom.text.lower() == SCODOC_CHEF_ID.lower():
|
||||
chefCree = True
|
||||
if nom.text.lower() == SCODOC_ENS_ID.lower():
|
||||
ensCree = True
|
||||
if not chefCree:
|
||||
time.sleep(2)
|
||||
constructValue = "Ens" + NOM_DPT
|
||||
driver.find_element_by_id("create-user").click()
|
||||
driver.find_element_by_id("tf_nom").send_keys(SCODOC_CHEF_ID)
|
||||
driver.find_element_by_id("tf_user_name").send_keys(SCODOC_CHEF_ID)
|
||||
driver.find_element_by_id("tf_prenom").send_keys("chef")
|
||||
driver.find_element_by_id("tf_passwd").send_keys(SCODOC_CHEF_PASS)
|
||||
driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_CHEF_PASS)
|
||||
driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click()
|
||||
driver.find_element_by_xpath("//input[@name='force:list']").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.find_element_by_id("link-view-users").click()
|
||||
if not ensCree:
|
||||
time.sleep(2)
|
||||
constructValue = "Ens" + NOM_DPT
|
||||
driver.find_element_by_id("create-user").click()
|
||||
driver.find_element_by_id("tf_nom").send_keys(SCODOC_ENS_ID)
|
||||
driver.find_element_by_id("tf_user_name").send_keys(SCODOC_ENS_ID)
|
||||
driver.find_element_by_id("tf_prenom").send_keys(PRENOM_ENS)
|
||||
driver.find_element_by_id("tf_passwd").send_keys(SCODOC_ENS_PASS)
|
||||
driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_ENS_PASS)
|
||||
driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click()
|
||||
driver.find_element_by_xpath("//input[@name='force:list']").click()
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
driver.find_element_by_id("link-view-users").click()
|
||||
driver.close()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="05_Saisie_note_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
|
@ -1,456 +1,457 @@
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import urllib.parse as urlparse
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
BASE_SSH_URL,
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
SCODOC_ENS_ID,
|
||||
SCODOC_ENS_PASS,
|
||||
SCODOC_CHEF_ID,
|
||||
SCODOC_CHEF_PASS,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from urllib.parse import parse_qs
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
urlMatiere = ""
|
||||
listeEtudiant = []
|
||||
global MOY_UE1
|
||||
global MOY_UE2
|
||||
global URL_SEMESTRE
|
||||
global COEFFUE1
|
||||
global COEFFUE2
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
elif NAVIGATEUR == "chrome":
|
||||
self.driver = webdriver.Chrome()
|
||||
self.url = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
self.driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
|
||||
# Test: Ajout de note pour deux élèves dans une seule UE et vérifie si la moyenne de cet UE sur la fiche étudiante correspondant à la valeur rentrée
|
||||
# @expected : La note rentrée et la moyenne sont identiques
|
||||
def test_010_ajout_note_multiple_pour_une_ue(self):
|
||||
global listeEtudiant
|
||||
global MOY_UE1
|
||||
global URL_SEMESTRE
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
linkAddNote = "formnotes_note_"
|
||||
driver.find_element_by_link_text("semestre 1").click()
|
||||
self.wait.until(EC.url_changes(url))
|
||||
URL_SEMESTRE = driver.current_url
|
||||
ue_name = driver.find_elements_by_class_name("status_ue_acro")[0].text
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
URL = driver.current_url
|
||||
for champs in driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
):
|
||||
champs.clear()
|
||||
champs.send_keys(12)
|
||||
idChamp = champs.get_attribute("id")
|
||||
idEtud = idChamp[len(linkAddNote) : len(idChamp)]
|
||||
if idEtud not in listeEtudiant:
|
||||
listeEtudiant.append(idEtud)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.get(URL_SEMESTRE)
|
||||
noteBonne = True
|
||||
# print(listeEtudiant)
|
||||
for etudiant in listeEtudiant:
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
if "12" not in MOY_UE1:
|
||||
noteBonne = False
|
||||
self.assertTrue(noteBonne)
|
||||
|
||||
# Test : Ajoute une note à la seconde UE pour les deux élèves
|
||||
# @expected : La moyenne de la seconde UE apparait et corresponds à la note rentrée
|
||||
def test_020_ajout_note_seconde_ue(self):
|
||||
global listeEtudiant
|
||||
global MOY_UE2
|
||||
global URL_SEMESTRE
|
||||
linkAddNote = "formnotes_note_"
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(URL_SEMESTRE)
|
||||
ue_name = driver.find_elements_by_class_name("status_ue_acro")[1].text
|
||||
driver.find_element_by_link_text("M1201").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
URL = driver.current_url
|
||||
for champs in driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
):
|
||||
champs.clear()
|
||||
champs.send_keys(8)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.get(URL_SEMESTRE)
|
||||
noteBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
MOY_UE2 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
if "8" not in MOY_UE2:
|
||||
noteBonne = False
|
||||
|
||||
self.assertTrue(noteBonne)
|
||||
|
||||
# Test : Vérification calcul de la moyenne générale
|
||||
# @expected La moyenne prends en compte les deux ue et leur coefficiant
|
||||
def test_030_verification_moyenne_generale(self):
|
||||
global COEFF_UE1
|
||||
global COEFF_UE2
|
||||
COEFF_UE1 = 2
|
||||
COEFF_UE2 = 2
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
moyenneBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
if (
|
||||
(float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
self.assertTrue(moyenneBonne)
|
||||
|
||||
# Test : Changement du coefficiant d'un module et de ce fait, du coefficiant de l'UE
|
||||
# @expected : La moyenne générale se modifie en fonction de ce changement de coefficiant
|
||||
def test_040_modification_coefficiant_module(self):
|
||||
global COEFF_UE1
|
||||
COEFF_UE1 = 3
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
driver.find_element_by_id("link-programmes").click()
|
||||
driver.find_element_by_id("titre-dut-info").click()
|
||||
driver.find_element_by_xpath("//span[contains(text(),'M1101')]").click()
|
||||
driver.find_element_by_id("tf_coefficient").clear()
|
||||
driver.find_element_by_id("tf_coefficient").send_keys(COEFF_UE1)
|
||||
URL = driver.current_url
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
moyenneBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
if (
|
||||
(float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
self.assertTrue(moyenneBonne)
|
||||
|
||||
# Test : Ajout d'une note bonus pour un étudiant et d'une note malus pour un autre
|
||||
# @expected : La moyenne de l'UE où est ajouté la note bonus/malus est impactée par cette dernière, la moyenne générale change avec ce changement de moyenne d'UE
|
||||
def test_050_ajout_note_bonus(self):
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_partial_link_text("malus").click()
|
||||
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_name("jour").clear()
|
||||
driver.find_element_by_name("jour").send_keys("31/01/2021")
|
||||
driver.find_element_by_id("tf_description").send_keys("une interrogation bonus")
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[1].clear()
|
||||
champsNote[0].send_keys("-" + moyenneBonusEtudiant1)
|
||||
champsNote[1].send_keys(moyenneBonusEtudiant2)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
if numeroEtu == 0:
|
||||
if (
|
||||
(
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2
|
||||
)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
elif numeroEtu == 1:
|
||||
if (
|
||||
(
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne)
|
||||
|
||||
# Test : Ajout d'une note en attente pour un étudiant, et d'une note entrée pour un autre sur une même évaluation
|
||||
# @expected :
|
||||
def test_060_note_attente(self):
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
champsNote = []
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
URL = driver.current_url
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[0].send_keys("ATT")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
affichageMoyenne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
ueListElement = driver.find_elements_by_class_name("ue_acro")
|
||||
ueListText = []
|
||||
for ueElement in ueListElement:
|
||||
ueListText.append(ueElement.text)
|
||||
if numeroEtu == 0:
|
||||
moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1)
|
||||
if moyEtudiant1 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" in ueListText:
|
||||
affichageMoyenne = False
|
||||
elif numeroEtu == 1:
|
||||
moyEtudiant2 = (
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
if moyEtudiant2 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" not in ueListText:
|
||||
affichageMoyenne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne and affichageMoyenne)
|
||||
|
||||
def test_070_note_absent(self):
|
||||
ue_name = "UE11"
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
MOY_UE1_EXC = 0
|
||||
champsNote = []
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
URL = driver.current_url
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[0].send_keys("ABS")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
affichageMoyenne = True
|
||||
noteExcuseeEgaleAZero = True
|
||||
ueList = []
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
ueListElement = driver.find_elements_by_class_name("ue_acro")
|
||||
ueListText = []
|
||||
for ueElement in ueListElement:
|
||||
ueListText.append(ueElement.text)
|
||||
if numeroEtu == 0:
|
||||
moyEtudiant1 = (
|
||||
float(MOY_UE1_EXC) * COEFF_UE1
|
||||
+ ((float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2)
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
# print(format(moyEtudiant1, "2.2f"))
|
||||
# print(
|
||||
# format(
|
||||
# float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
|
||||
# )
|
||||
# )
|
||||
if format(moyEtudiant1, "2.2f") != format(
|
||||
float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
|
||||
):
|
||||
moyenneBonne = False
|
||||
if ue_name not in ueListText:
|
||||
affichageMoyenne = False
|
||||
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
if float(0) != float(MOY_UE1):
|
||||
noteExcuseeEgaleAZero = False
|
||||
elif numeroEtu == 1:
|
||||
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
moyEtudiant2 = (
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
if moyEtudiant2 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" not in ueListText:
|
||||
affichageMoyenne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne and affichageMoyenne and noteExcuseeEgaleAZero)
|
||||
|
||||
def test_080_note_excuse(self):
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
champsNote = []
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
URL = driver.current_url
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[0].send_keys("EXC")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
affichageMoyenne = True
|
||||
ueList = []
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
ueListElement = driver.find_elements_by_class_name("ue_acro")
|
||||
ueListText = []
|
||||
for ueElement in ueListElement:
|
||||
ueListText.append(ueElement.text)
|
||||
if numeroEtu == 0:
|
||||
moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1)
|
||||
if moyEtudiant1 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" in ueListText:
|
||||
affichageMoyenne = False
|
||||
elif numeroEtu == 1:
|
||||
moyEtudiant2 = (
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
if moyEtudiant2 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" not in ueListText:
|
||||
affichageMoyenne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne and affichageMoyenne)
|
||||
|
||||
# TOdo
|
||||
def test_090_note_bonus(self):
|
||||
global listeEtudiant
|
||||
global COEFF_UE1
|
||||
global COEFF_UE2
|
||||
global URL_SEMESTRE
|
||||
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario3_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="06_Moyenne_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import urllib.parse as urlparse
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
BASE_SSH_URL,
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
SCODOC_ENS_ID,
|
||||
SCODOC_ENS_PASS,
|
||||
SCODOC_CHEF_ID,
|
||||
SCODOC_CHEF_PASS,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from urllib.parse import parse_qs
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
urlMatiere = ""
|
||||
listeEtudiant = []
|
||||
global MOY_UE1
|
||||
global MOY_UE2
|
||||
global URL_SEMESTRE
|
||||
global COEFFUE1
|
||||
global COEFFUE2
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
elif NAVIGATEUR == "chrome":
|
||||
self.driver = webdriver.Chrome()
|
||||
self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
self.driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
|
||||
# Test: Ajout de note pour deux élèves dans une seule UE et vérifie si la moyenne de cet UE sur la fiche étudiante correspondant à la valeur rentrée
|
||||
# @expected : La note rentrée et la moyenne sont identiques
|
||||
def test_010_ajout_note_multiple_pour_une_ue(self):
|
||||
global listeEtudiant
|
||||
global MOY_UE1
|
||||
global URL_SEMESTRE
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
linkAddNote = "formnotes_note_"
|
||||
driver.find_element_by_link_text("semestre 1").click()
|
||||
self.wait.until(EC.url_changes(url))
|
||||
URL_SEMESTRE = driver.current_url
|
||||
ue_name = driver.find_elements_by_class_name("status_ue_acro")[0].text
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
URL = driver.current_url
|
||||
for champs in driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
):
|
||||
champs.clear()
|
||||
champs.send_keys(12)
|
||||
idChamp = champs.get_attribute("id")
|
||||
idEtud = idChamp[len(linkAddNote) : len(idChamp)]
|
||||
if idEtud not in listeEtudiant:
|
||||
listeEtudiant.append(idEtud)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.get(URL_SEMESTRE)
|
||||
noteBonne = True
|
||||
# print(listeEtudiant)
|
||||
for etudiant in listeEtudiant:
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
if "12" not in MOY_UE1:
|
||||
noteBonne = False
|
||||
self.assertTrue(noteBonne)
|
||||
|
||||
# Test : Ajoute une note à la seconde UE pour les deux élèves
|
||||
# @expected : La moyenne de la seconde UE apparait et corresponds à la note rentrée
|
||||
def test_020_ajout_note_seconde_ue(self):
|
||||
global listeEtudiant
|
||||
global MOY_UE2
|
||||
global URL_SEMESTRE
|
||||
linkAddNote = "formnotes_note_"
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(URL_SEMESTRE)
|
||||
ue_name = driver.find_elements_by_class_name("status_ue_acro")[1].text
|
||||
driver.find_element_by_link_text("M1201").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
URL = driver.current_url
|
||||
for champs in driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
):
|
||||
champs.clear()
|
||||
champs.send_keys(8)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
driver.get(URL_SEMESTRE)
|
||||
noteBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
MOY_UE2 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
if "8" not in MOY_UE2:
|
||||
noteBonne = False
|
||||
|
||||
self.assertTrue(noteBonne)
|
||||
|
||||
# Test : Vérification calcul de la moyenne générale
|
||||
# @expected La moyenne prends en compte les deux ue et leur coefficiant
|
||||
def test_030_verification_moyenne_generale(self):
|
||||
global COEFF_UE1
|
||||
global COEFF_UE2
|
||||
COEFF_UE1 = 2
|
||||
COEFF_UE2 = 2
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
moyenneBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
if (
|
||||
(float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
self.assertTrue(moyenneBonne)
|
||||
|
||||
# Test : Changement du coefficiant d'un module et de ce fait, du coefficiant de l'UE
|
||||
# @expected : La moyenne générale se modifie en fonction de ce changement de coefficiant
|
||||
def test_040_modification_coefficiant_module(self):
|
||||
global COEFF_UE1
|
||||
COEFF_UE1 = 3
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
driver.find_element_by_id("link-programmes").click()
|
||||
driver.find_element_by_id("titre-dut-info").click()
|
||||
driver.find_element_by_xpath("//span[contains(text(),'M1101')]").click()
|
||||
driver.find_element_by_id("tf_coefficient").clear()
|
||||
driver.find_element_by_id("tf_coefficient").send_keys(COEFF_UE1)
|
||||
URL = driver.current_url
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
moyenneBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
if (
|
||||
(float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
self.assertTrue(moyenneBonne)
|
||||
|
||||
# Test : Ajout d'une note bonus pour un étudiant et d'une note malus pour un autre
|
||||
# @expected : La moyenne de l'UE où est ajouté la note bonus/malus est impactée par cette dernière, la moyenne générale change avec ce changement de moyenne d'UE
|
||||
def test_050_ajout_note_bonus(self):
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_partial_link_text("malus").click()
|
||||
driver.find_element_by_link_text("Créer nouvelle évaluation").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_name("jour").clear()
|
||||
driver.find_element_by_name("jour").send_keys("31/01/2021")
|
||||
driver.find_element_by_id("tf_description").send_keys("une interrogation bonus")
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[1].clear()
|
||||
champsNote[0].send_keys("-" + moyenneBonusEtudiant1)
|
||||
champsNote[1].send_keys(moyenneBonusEtudiant2)
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
if numeroEtu == 0:
|
||||
if (
|
||||
(
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2
|
||||
)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
elif numeroEtu == 1:
|
||||
if (
|
||||
(
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
)
|
||||
/ (COEFF_UE1 + COEFF_UE2)
|
||||
) != float(driver.find_element_by_class_name("rcp_moy").text):
|
||||
moyenneBonne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne)
|
||||
|
||||
# Test : Ajout d'une note en attente pour un étudiant, et d'une note entrée pour un autre sur une même évaluation
|
||||
# @expected :
|
||||
def test_060_note_attente(self):
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
champsNote = []
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
URL = driver.current_url
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[0].send_keys("ATT")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
affichageMoyenne = True
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
ueListElement = driver.find_elements_by_class_name("ue_acro")
|
||||
ueListText = []
|
||||
for ueElement in ueListElement:
|
||||
ueListText.append(ueElement.text)
|
||||
if numeroEtu == 0:
|
||||
moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1)
|
||||
if moyEtudiant1 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" in ueListText:
|
||||
affichageMoyenne = False
|
||||
elif numeroEtu == 1:
|
||||
moyEtudiant2 = (
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
if moyEtudiant2 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" not in ueListText:
|
||||
affichageMoyenne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne and affichageMoyenne)
|
||||
|
||||
def test_070_note_absent(self):
|
||||
ue_name = "UE11"
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
MOY_UE1_EXC = 0
|
||||
champsNote = []
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
URL = driver.current_url
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[0].send_keys("ABS")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
affichageMoyenne = True
|
||||
noteExcuseeEgaleAZero = True
|
||||
ueList = []
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
ueListElement = driver.find_elements_by_class_name("ue_acro")
|
||||
ueListText = []
|
||||
for ueElement in ueListElement:
|
||||
ueListText.append(ueElement.text)
|
||||
if numeroEtu == 0:
|
||||
moyEtudiant1 = (
|
||||
float(MOY_UE1_EXC) * COEFF_UE1
|
||||
+ ((float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2)
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
# print(format(moyEtudiant1, "2.2f"))
|
||||
# print(
|
||||
# format(
|
||||
# float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
|
||||
# )
|
||||
# )
|
||||
if format(moyEtudiant1, "2.2f") != format(
|
||||
float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
|
||||
):
|
||||
moyenneBonne = False
|
||||
if ue_name not in ueListText:
|
||||
affichageMoyenne = False
|
||||
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
if float(0) != float(MOY_UE1):
|
||||
noteExcuseeEgaleAZero = False
|
||||
elif numeroEtu == 1:
|
||||
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
|
||||
moyEtudiant2 = (
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
if moyEtudiant2 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" not in ueListText:
|
||||
affichageMoyenne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne and affichageMoyenne and noteExcuseeEgaleAZero)
|
||||
|
||||
def test_080_note_excuse(self):
|
||||
moyenneBonusEtudiant1 = "0.25"
|
||||
moyenneBonusEtudiant2 = "0.25"
|
||||
linkAddNote = "formnotes_note_"
|
||||
champsNote = []
|
||||
driver = self.driver
|
||||
driver.get(URL_SEMESTRE)
|
||||
driver.find_element_by_link_text("M1101").click()
|
||||
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
||||
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
||||
URL = driver.current_url
|
||||
champsNote = driver.find_elements_by_xpath(
|
||||
"//input[contains(@id,'" + linkAddNote + "')]"
|
||||
)
|
||||
champsNote[0].clear()
|
||||
champsNote[0].send_keys("EXC")
|
||||
driver.find_element_by_id("formnotes_submit").click()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
numeroEtu = 0
|
||||
moyenneBonne = True
|
||||
affichageMoyenne = True
|
||||
ueList = []
|
||||
for etudiant in listeEtudiant:
|
||||
URL = driver.current_url
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys(etudiant)
|
||||
searchBar.submit()
|
||||
self.wait.until(EC.url_changes(URL))
|
||||
ueListElement = driver.find_elements_by_class_name("ue_acro")
|
||||
ueListText = []
|
||||
for ueElement in ueListElement:
|
||||
ueListText.append(ueElement.text)
|
||||
if numeroEtu == 0:
|
||||
moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1)
|
||||
if moyEtudiant1 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" in ueListText:
|
||||
affichageMoyenne = False
|
||||
elif numeroEtu == 1:
|
||||
moyEtudiant2 = (
|
||||
float(MOY_UE1) * COEFF_UE1
|
||||
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
|
||||
) / (COEFF_UE1 + COEFF_UE2)
|
||||
if moyEtudiant2 != float(
|
||||
driver.find_element_by_class_name("rcp_moy").text
|
||||
):
|
||||
moyenneBonne = False
|
||||
if "UE11" not in ueListText:
|
||||
affichageMoyenne = False
|
||||
numeroEtu = numeroEtu + 1
|
||||
self.assertTrue(moyenneBonne and affichageMoyenne)
|
||||
|
||||
# TOdo
|
||||
def test_090_note_bonus(self):
|
||||
global listeEtudiant
|
||||
global COEFF_UE1
|
||||
global COEFF_UE2
|
||||
global URL_SEMESTRE
|
||||
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario3_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="06_Moyenne_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
|
@ -1,244 +1,245 @@
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import urllib.parse as urlparse
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
BASE_SSH_URL,
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
SCODOC_ENS_ID,
|
||||
SCODOC_ENS_PASS,
|
||||
SCODOC_CHEF_ID,
|
||||
SCODOC_CHEF_PASS,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from urllib.parse import parse_qs
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
|
||||
URL_ETUDIANT = ""
|
||||
URL_DECISION = ""
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
elif NAVIGATEUR == "chrome":
|
||||
self.driver = webdriver.Chrome()
|
||||
self.url = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
self.driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
|
||||
def test_010_etudiantS1_assidu_avec_moy_admis(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID1")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-10").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
time.sleep(1)
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_020_etudiantS1_non_assidu_avec_moy_semestre_non_valide(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID1")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-40").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_030_etudiantS1_assidu_sous_la_moy_semestre_valide(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID4")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-30").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-580").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_040_etudiantS1_non_assidu_sous_la_moy_semestre_valide(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID4")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-40").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-580").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_050_calcul_automatiqueS2_jury(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
driver.find_element_by_link_text("semestre 2").click()
|
||||
self.wait.until(EC.url_changes(url))
|
||||
urlTmp = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Jury')]").click()
|
||||
driver.find_element_by_link_text("Saisie des décisions du jury").click()
|
||||
self.wait.until(EC.url_changes(urlTmp))
|
||||
urlTmp = driver.current_url
|
||||
driver.find_element_by_partial_link_text("Calcul automatique").click()
|
||||
self.wait.until(EC.url_changes(urlTmp))
|
||||
urlTmp = driver.current_url
|
||||
driver.find_element_by_xpath("//input[@type='submit']").click()
|
||||
self.wait.until(EC.url_changes(urlTmp))
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID7")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID10")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
self.assertTrue("en cours" in driver.page_source)
|
||||
|
||||
def test_060_declarer_defaillance(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID10")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath("//a[contains(@href,'formDef?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
input = driver.find_element_by_name("event_date")
|
||||
input.clear()
|
||||
input.send_keys("11/06/2021")
|
||||
driver.find_element_by_xpath("//input[@type='submit']").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("Défaillant" in driver.page_source)
|
||||
|
||||
def test_070_declarer_demission(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID10")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath("//a[contains(@href,'formDem?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
input = driver.find_element_by_name("event_date")
|
||||
input.clear()
|
||||
input.send_keys("11/06/2021")
|
||||
driver.find_element_by_xpath("//input[@type='submit']").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("Démission le " in driver.page_source)
|
||||
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario4_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="07_Admission_et_passages_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import urllib.parse as urlparse
|
||||
import HtmlTestRunner
|
||||
import createDepartement
|
||||
import creationSiteDepartement
|
||||
import deleteDepartement
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
BASE_SSH_URL,
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
SCODOC_ENS_ID,
|
||||
SCODOC_ENS_PASS,
|
||||
SCODOC_CHEF_ID,
|
||||
SCODOC_CHEF_PASS,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from urllib.parse import parse_qs
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
|
||||
URL_ETUDIANT = ""
|
||||
URL_DECISION = ""
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
||||
def setUp(self):
|
||||
if NAVIGATEUR == "firefox":
|
||||
self.driver = webdriver.Firefox()
|
||||
elif NAVIGATEUR == "chrome":
|
||||
self.driver = webdriver.Chrome()
|
||||
self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
|
||||
self.wait = WebDriverWait(self.driver, 10)
|
||||
self.driver.get(
|
||||
SCHEMA
|
||||
+ "://"
|
||||
+ SCODOC_ADMIN_ID
|
||||
+ ":"
|
||||
+ SCODOC_ADMIN_PASS
|
||||
+ "@"
|
||||
+ BASE_SSH_URL
|
||||
+ "force_admin_authentication"
|
||||
)
|
||||
|
||||
def test_010_etudiantS1_assidu_avec_moy_admis(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID1")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-10").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
time.sleep(1)
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_020_etudiantS1_non_assidu_avec_moy_semestre_non_valide(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID1")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-40").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_030_etudiantS1_assidu_sous_la_moy_semestre_valide(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID4")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-30").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-580").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_040_etudiantS1_non_assidu_sous_la_moy_semestre_valide(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID4")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-40").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath(
|
||||
"//a[contains(@href,'formsemestre_validation_etud_form?')]"
|
||||
).click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
URL_DECISION = driver.current_url
|
||||
driver.find_element_by_id("input-choice-580").click()
|
||||
driver.find_element_by_id("subut").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
|
||||
def test_050_calcul_automatiqueS2_jury(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
driver.find_element_by_link_text("semestre 2").click()
|
||||
self.wait.until(EC.url_changes(url))
|
||||
urlTmp = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Jury')]").click()
|
||||
driver.find_element_by_link_text("Saisie des décisions du jury").click()
|
||||
self.wait.until(EC.url_changes(urlTmp))
|
||||
urlTmp = driver.current_url
|
||||
driver.find_element_by_partial_link_text("Calcul automatique").click()
|
||||
self.wait.until(EC.url_changes(urlTmp))
|
||||
urlTmp = driver.current_url
|
||||
driver.find_element_by_xpath("//input[@type='submit']").click()
|
||||
self.wait.until(EC.url_changes(urlTmp))
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID7")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID10")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
self.assertTrue("en cours" in driver.page_source)
|
||||
|
||||
def test_060_declarer_defaillance(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID10")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath("//a[contains(@href,'formDef?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
input = driver.find_element_by_name("event_date")
|
||||
input.clear()
|
||||
input.send_keys("11/06/2021")
|
||||
driver.find_element_by_xpath("//input[@type='submit']").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("Défaillant" in driver.page_source)
|
||||
|
||||
def test_070_declarer_demission(self):
|
||||
driver = self.driver
|
||||
url = self.url
|
||||
driver.get(url)
|
||||
searchBar = driver.find_element_by_id("in-expnom")
|
||||
searchBar.send_keys("EID10")
|
||||
searchBar.submit()
|
||||
time.sleep(5)
|
||||
URL_ETUDIANT = driver.current_url
|
||||
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
|
||||
driver.find_element_by_xpath("//a[contains(@href,'formDem?')]").click()
|
||||
self.wait.until(EC.url_changes(URL_ETUDIANT))
|
||||
input = driver.find_element_by_name("event_date")
|
||||
input.clear()
|
||||
input.send_keys("11/06/2021")
|
||||
driver.find_element_by_xpath("//input[@type='submit']").click()
|
||||
driver.get(URL_ETUDIANT)
|
||||
self.assertTrue("Démission le " in driver.page_source)
|
||||
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
deleteDepartement.main()
|
||||
createDepartement.main()
|
||||
creationSiteDepartement.main()
|
||||
cmdProcess = [
|
||||
"./scriptExecution.sh",
|
||||
LINK_SCODOC_SERVER,
|
||||
NOM_DPT,
|
||||
"test_scenario4_formation.py",
|
||||
]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
||||
unittest.main(
|
||||
testRunner=HtmlTestRunner.HTMLTestRunner(
|
||||
report_name="07_Admission_et_passages_tests",
|
||||
output="./ResultatTest",
|
||||
combine_reports=True,
|
||||
)
|
||||
)
|
||||
|
@ -1,54 +1,55 @@
|
||||
# coding: utf8
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
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"))
|
||||
|
||||
ACRONYME_FORMATION = "FormationTEST"
|
||||
|
||||
def main():
|
||||
next_page = URL_HOME
|
||||
if NAVIGATEUR == "firefox":
|
||||
driver = webdriver.Firefox()
|
||||
else:
|
||||
driver = webdriver.Chrome()
|
||||
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
|
||||
driver.get(auth_page)
|
||||
driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
|
||||
driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
|
||||
driver.find_element_by_id("submit").click()
|
||||
time.sleep(2)
|
||||
try:
|
||||
select = Select(driver.find_element_by_id("create-dept"))
|
||||
select.select_by_visible_text(NOM_DPT)
|
||||
driver.find_element_by_id("create-dept").submit()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.close()
|
||||
except NoSuchElementException:
|
||||
# coding: utf8
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
URL_ROOT = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT
|
||||
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"))
|
||||
|
||||
ACRONYME_FORMATION = "FormationTEST"
|
||||
|
||||
def main():
|
||||
next_page = URL_HOME
|
||||
if NAVIGATEUR == "firefox":
|
||||
driver = webdriver.Firefox()
|
||||
else:
|
||||
driver = webdriver.Chrome()
|
||||
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
|
||||
driver.get(auth_page)
|
||||
driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
|
||||
driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
|
||||
driver.find_element_by_id("submit").click()
|
||||
time.sleep(2)
|
||||
try:
|
||||
select = Select(driver.find_element_by_id("create-dept"))
|
||||
select.select_by_visible_text(NOM_DPT)
|
||||
driver.find_element_by_id("create-dept").submit()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_id("tf_submit").click()
|
||||
time.sleep(1)
|
||||
driver.close()
|
||||
except NoSuchElementException:
|
||||
driver.close()
|
8
importFormationXml.py
Normal file
8
importFormationXml.py
Normal file
@ -0,0 +1,8 @@
|
||||
import subprocess
|
||||
from setting import LINK_SCODOC_SERVER, NOM_DPT
|
||||
|
||||
|
||||
def main():
|
||||
cmdProcess = ["./scriptImportFormation.sh", LINK_SCODOC_SERVER, NOM_DPT]
|
||||
process = subprocess.Popen(cmdProcess)
|
||||
process.wait()
|
214
readme.md
214
readme.md
@ -1,102 +1,112 @@
|
||||
#Tests E2E du logiciel Scodoc
|
||||
|
||||
Ces jeux de tests ont été conçus pour tester automatiquement Scodoc d'un point de vue E2E (End to End). Ils sont en théorie indépendants les uns des autres. Ils ont étés développés en python 3.
|
||||
## I Configuration
|
||||
Dans cette partie je vais détailler les prérequis pour l'environnement de développement
|
||||
### Prérequis Module
|
||||
Ces prérequis peuvent être trouvés dans requirements.txt qui se trouvent à la base du projet.
|
||||
Vous devez avoir pip d'installé, normalement il est fourni avec les versions de python3, sinon vous trouverez les étapes d'installation [ici](https://pip.pypa.io/en/stable/installing/)
|
||||
Les modules suivant sont nécessaire :
|
||||
>selenium==3.141.0
|
||||
>python-dotenv==0.17.1
|
||||
>HtmlTestRunner==0.8.0
|
||||
|
||||
Vous pouvez les installer manuellement avec pip avec la commande suivante :
|
||||
>pip install selenium
|
||||
|
||||
ou alternativement avec
|
||||
>pip install -r requirements.txt
|
||||
### Environnement de test
|
||||
Un modèle de .env est fourni dans ce projet, pour que les tests soient fonctionnel vous devez le remplir et le renommer en .env. Ce dernier servira à remplir différentes informations spécifiques concernant votre environnement Scodoc. Nous allons le voir ici en détail
|
||||
#### .env
|
||||
|
||||
>SCHEMA = "https"
|
||||
>BASE_URL = "scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
|
||||
|
||||
Ici sera le lien vers la page d'accueil de votre Scodoc
|
||||
|
||||
>NOM_DPT = "test01"
|
||||
|
||||
Le nom du département surlequel vous allez effectuer vos tests, il est **FORTEMENT** conseillés de mettre ici un nom de département qui n'existe pas, sous risque de perte de données.
|
||||
|
||||
>SCODOC_ADMIN_ID = "admin_id"
|
||||
|
||||
Le nom d'utilisateur d'un Admin Scodoc.
|
||||
|
||||
>SCODOC_ADMIN_PASS = "admin_password"
|
||||
|
||||
Le mot de passe d'un Admin Scodoc.
|
||||
|
||||
>SCODOC_ENS_ID = "enseignant_id"
|
||||
|
||||
Le nom d'utilisateur d'un enseignant lambda qui servira pour rentrer des notes, soit qui existe, soit qui sera créé.
|
||||
|
||||
>SCODOC_ENS_PASS = "enseignant_password@10"
|
||||
|
||||
Le mot de passe de l'utilisateur précédent, si l'utilisateur précédent n'existe pas, veillez à avoir un mot de passe suffisamenent compliqué pour la création de ce dernier.
|
||||
|
||||
>SCODOC_CHEF_ID = "chef_id"
|
||||
|
||||
Le nom d'utilisateur d'un enseignant lambda qui se verra attribué le rôle de résponsable d'un module afin de créer des interrogations , soit qui existe, soit qui sera créé.
|
||||
|
||||
>SCODOC_CHEF_PASS = "p@ssword42@"
|
||||
|
||||
Le mot de passe de l'utilisateur précédent, si l'utilisateur précédent n'existe pas, veillez à avoir un mot de passe suffisamenent compliqué pour la
|
||||
|
||||
>LINK_SCODOC_SERVER = "root@ssh_server_scodoc"
|
||||
|
||||
Le lien vers votre serveur Scodoc, ce dernier servira à lancer des scripts de mise en place sur le serveur. Veillez donc à avoir une connexion avec les droits root sur votre serveur, de préférences avec échange de clef ssh.
|
||||
|
||||
>BASE_SSH_URL = "scodoc-dev-iutinfo.univ-lille.fr/"
|
||||
|
||||
Le lien vers la page de choix de département, avec le format précisé.
|
||||
|
||||
>NAVIGATEUR = "firefox"
|
||||
|
||||
Ici vous pouvez choisir entre firefox et chrome,choisissez le navigateur dans lequel vous voulez que vos tests se déroulent. Cette ligne permettra au programme de choisir le webdriver correspondant.
|
||||
|
||||
#### Explications du fonctionnement des tests
|
||||
|
||||
Les tests sont prévus pour fonctionner avec firefox ou chrome les webdrivers sont intégrés dans le projet pour éviter de devoir les installer manuellement. Ces webdrivers servent à faire la connexion entre python et le navigateur.
|
||||
|
||||
##Lancement des tests
|
||||
|
||||
Pour lancer les tests, assurez vous d'avoir une connexion possible avec votre serveur. Positionnez vous à la racine de ce projet et il suffit donc de lancer la commande par exemple pour le premier jeux de tests
|
||||
|
||||
>python3 01_creation_departement_test.py
|
||||
|
||||
Alternativement vous pouvez lancer l'ensemble des tests avec la commande
|
||||
|
||||
>./lancement_de_tout_les_tests.sh
|
||||
|
||||
L'option --c ou --cleanup est disponible si vous souhaitez effacer tout les rapports précédents
|
||||
|
||||
###Resultats des tests
|
||||
|
||||
Les tests sont présentés sur une page HTML qui se trouve dans le dossier ResultatTest, il y a une page HTML par jeux de tests créée. Un récapitulatif est également créé par le biais du script
|
||||
|
||||
>./scriptGenerateReportPage.sh
|
||||
|
||||
Celui ci est lancé automatiquement à la fin du script
|
||||
|
||||
>./lancement_de_tout_les_tests.sh
|
||||
|
||||
Vous y retrouverez les liens menant au détails de chaque rapport ainsi qu'un résumé du nombre de test passés/échoués
|
||||
|
||||
##Correctifs
|
||||
|
||||
* Modifier le PATH pour que geckodriver soit executable `export PATH=".:$PATH"`
|
||||
|
||||
* pip install HtmlTestRunner-Python3
|
||||
|
||||
* Créer un utilisateur Nom:BACH Prenom:Test User:Bach TODO: utiliser enseignant_id à la place
|
||||
#Tests E2E du logiciel Scodoc
|
||||
|
||||
Ces jeux de tests ont été conçus pour tester automatiquement Scodoc d'un point de vue E2E (End to End). Ils sont en théorie indépendants les uns des autres. Ils ont étés développés en python 3.
|
||||
## I Configuration
|
||||
Dans cette partie je vais détailler les prérequis pour l'environnement de développement
|
||||
### Prérequis Module
|
||||
Ces prérequis peuvent être trouvés dans requirements.txt qui se trouvent à la base du projet.
|
||||
Vous devez avoir pip d'installé, normalement il est fourni avec les versions de python3, sinon vous trouverez les étapes d'installation [ici](https://pip.pypa.io/en/stable/installing/)
|
||||
Les modules suivant sont nécessaire :
|
||||
>selenium==3.141.0
|
||||
>python-dotenv==0.17.1
|
||||
>HtmlTestRunner==0.8.0
|
||||
|
||||
Vous pouvez les installer manuellement avec pip avec la commande suivante :
|
||||
>pip install selenium
|
||||
|
||||
ou alternativement avec
|
||||
>pip install -r requirements.txt
|
||||
### Environnement de test
|
||||
Un modèle de .env est fourni dans ce projet, pour que les tests soient fonctionnel vous devez le remplir et le renommer en .env. Ce dernier servira à remplir différentes informations spécifiques concernant votre environnement Scodoc. Nous allons le voir ici en détail
|
||||
#### .env
|
||||
|
||||
SCHEMA="http"
|
||||
BASE_URL = "scodoc_server:5000"
|
||||
NOM_DPT = "TEST01"
|
||||
SCODOC_ADMIN_ID = "admin_id"
|
||||
SCODOC_ADMIN_PASS = "admin_password"
|
||||
SCODOC_ENS_ID = "enseignant_id"
|
||||
SCODOC_ENS_PASS = "enseignant_password@10"
|
||||
SCODOC_CHEF_ID = "chef_id"
|
||||
SCODOC_CHEF_PASS = "p@ssword42@"
|
||||
LINK_SCODOC_SERVER = "scodoc_server"
|
||||
BASE_SSH_URL = "scodoc_server:5000/"
|
||||
NAVIGATEUR = "firefox"
|
||||
|
||||
Ici sera le lien vers la page d'accueil de votre Scodoc
|
||||
|
||||
>NOM_DPT = "test01"
|
||||
|
||||
Le nom du département surlequel vous allez effectuer vos tests, il est **FORTEMENT** conseillés de mettre ici un nom de département qui n'existe pas, sous risque de perte de données.
|
||||
|
||||
>SCODOC_ADMIN_ID = "admin_id"
|
||||
|
||||
Le nom d'utilisateur d'un Admin Scodoc.
|
||||
|
||||
>SCODOC_ADMIN_PASS = "admin_password"
|
||||
|
||||
Le mot de passe d'un Admin Scodoc.
|
||||
|
||||
>SCODOC_ENS_ID = "enseignant_id"
|
||||
|
||||
Le nom d'utilisateur d'un enseignant lambda qui servira pour rentrer des notes, soit qui existe, soit qui sera créé.
|
||||
|
||||
>SCODOC_ENS_PASS = "enseignant_password@10"
|
||||
|
||||
Le mot de passe de l'utilisateur précédent, si l'utilisateur précédent n'existe pas, veillez à avoir un mot de passe suffisamenent compliqué pour la création de ce dernier.
|
||||
|
||||
>SCODOC_CHEF_ID = "chef_id"
|
||||
|
||||
Le nom d'utilisateur d'un enseignant lambda qui se verra attribué le rôle de résponsable d'un module afin de créer des interrogations , soit qui existe, soit qui sera créé.
|
||||
|
||||
>SCODOC_CHEF_PASS = "p@ssword42@"
|
||||
|
||||
Le mot de passe de l'utilisateur précédent, si l'utilisateur précédent n'existe pas, veillez à avoir un mot de passe suffisamenent compliqué pour la
|
||||
|
||||
>LINK_SCODOC_SERVER = "root@ssh_server_scodoc"
|
||||
|
||||
Le lien vers votre serveur Scodoc, ce dernier servira à lancer des scripts de mise en place sur le serveur. Veillez donc à avoir une connexion avec les droits root sur votre serveur, de préférences avec échange de clef ssh.
|
||||
|
||||
>BASE_SSH_URL = "scodoc-dev-iutinfo.univ-lille.fr/"
|
||||
|
||||
Le lien vers la page de choix de département, avec le format précisé.
|
||||
|
||||
>NAVIGATEUR = "firefox"
|
||||
|
||||
Ici vous pouvez choisir entre firefox et chrome,choisissez le navigateur dans lequel vous voulez que vos tests se déroulent. Cette ligne permettra au programme de choisir le webdriver correspondant.
|
||||
|
||||
#### Explications du fonctionnement des tests
|
||||
|
||||
Les tests sont prévus pour fonctionner avec firefox ou chrome les webdrivers sont intégrés dans le projet pour éviter de devoir les installer manuellement. Ces webdrivers servent à faire la connexion entre python et le navigateur.
|
||||
|
||||
##Lancement des tests
|
||||
|
||||
Pour lancer les tests, assurez vous d'avoir une connexion possible avec votre serveur. Positionnez vous à la racine de ce projet et il suffit donc de lancer la commande par exemple pour le premier jeux de tests
|
||||
|
||||
>python3 01_creation_departement_test.py
|
||||
|
||||
Alternativement vous pouvez lancer l'ensemble des tests avec la commande
|
||||
|
||||
>./lancement_de_tout_les_tests.sh
|
||||
|
||||
L'option --c ou --cleanup est disponible si vous souhaitez effacer tout les rapports précédents
|
||||
|
||||
###Resultats des tests
|
||||
|
||||
Les tests sont présentés sur une page HTML qui se trouve dans le dossier ResultatTest, il y a une page HTML par jeux de tests créée. Un récapitulatif est également créé par le biais du script
|
||||
|
||||
>./scriptGenerateReportPage.sh
|
||||
|
||||
Celui ci est lancé automatiquement à la fin du script
|
||||
|
||||
>./lancement_de_tout_les_tests.sh
|
||||
|
||||
Vous y retrouverez les liens menant au détails de chaque rapport ainsi qu'un résumé du nombre de test passés/échoués
|
||||
|
||||
##Correctifs
|
||||
|
||||
* Modifier le PATH pour que geckodriver soit executable `export PATH=".:$PATH"`
|
||||
|
||||
* pip install HtmlTestRunner-Python3
|
||||
|
||||
* Créer un utilisateur Nom:BACH Prenom:Test User:Bach TODO: utiliser enseignant_id à la place
|
||||
|
12
scriptCreationUtilisateurs.sh
Executable file
12
scriptCreationUtilisateurs.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
#Ce script se charge de se connecter au serveur scodoc et créer les enseignants requis pour le département donné en paramètre
|
||||
if [ "$#" -ne 2 ];
|
||||
then
|
||||
echo "Pas assez d'arguments"
|
||||
exit 2
|
||||
fi
|
||||
ssh $1 /bin/bash<< EOF
|
||||
cd /opt/scodoc
|
||||
source venv/bin/activate
|
||||
flask user-create -n BACH -p Jean-Sebastien Bach Ens $2
|
||||
EOF
|
12
scriptImportFormation.sh
Executable file
12
scriptImportFormation.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
#Ce script se charge de se connecter au serveur scodoc et créer les enseignants requis pour le département donné en paramètre
|
||||
if [ "$#" -ne 2 ];
|
||||
then
|
||||
echo "Pas assez d'arguments"
|
||||
exit 2
|
||||
fi
|
||||
ssh scodoc@$1 /bin/bash<< EOF
|
||||
cd /opt/scodoc
|
||||
source venv/bin/activate
|
||||
flask import-xml tests/scenario/export_formation1.xml $2
|
||||
EOF
|
37
setting.py
37
setting.py
@ -1,19 +1,20 @@
|
||||
import os
|
||||
from os.path import join, dirname
|
||||
from dotenv import load_dotenv
|
||||
|
||||
dotenv_path = join(dirname(__file__), ".env")
|
||||
load_dotenv(dotenv_path)
|
||||
|
||||
SCHEMA = os.environ.get("SCHEMA")
|
||||
BASE_URL = os.environ.get("BASE_URL")
|
||||
NOM_DPT = os.environ.get("NOM_DPT")
|
||||
SCODOC_ADMIN_ID = os.environ.get("SCODOC_ADMIN_ID")
|
||||
SCODOC_ADMIN_PASS = os.environ.get("SCODOC_ADMIN_PASS")
|
||||
SCODOC_ENS_ID = os.environ.get("SCODOC_ENS_ID")
|
||||
SCODOC_ENS_PASS = os.environ.get("SCODOC_ENS_PASS")
|
||||
SCODOC_CHEF_ID = os.environ.get("SCODOC_CHEF_ID")
|
||||
SCODOC_CHEF_PASS = os.environ.get("SCODOC_CHEF_PASS")
|
||||
LINK_SCODOC_SERVER = os.environ.get("LINK_SCODOC_SERVER")
|
||||
BASE_SSH_URL = os.environ.get("BASE_SSH_URL")
|
||||
import os
|
||||
from os.path import join, dirname
|
||||
from dotenv import load_dotenv
|
||||
|
||||
dotenv_path = join(dirname(__file__), ".env")
|
||||
load_dotenv(dotenv_path)
|
||||
|
||||
SCHEMA = os.environ.get("SCHEMA")
|
||||
SCODOC_SERVER = os.environ.get("SCODOC_SERVER")
|
||||
SCODOC_PORT = os.environ.get("SCODOC_PORT")
|
||||
NOM_DPT = os.environ.get("NOM_DPT")
|
||||
SCODOC_ADMIN_ID = os.environ.get("SCODOC_ADMIN_ID")
|
||||
SCODOC_ADMIN_PASS = os.environ.get("SCODOC_ADMIN_PASS")
|
||||
SCODOC_ENS_ID = os.environ.get("SCODOC_ENS_ID")
|
||||
SCODOC_ENS_PASS = os.environ.get("SCODOC_ENS_PASS")
|
||||
SCODOC_CHEF_ID = os.environ.get("SCODOC_CHEF_ID")
|
||||
SCODOC_CHEF_PASS = os.environ.get("SCODOC_CHEF_PASS")
|
||||
LINK_SCODOC_SERVER = os.environ.get("LINK_SCODOC_SERVER")
|
||||
BASE_SSH_URL = os.environ.get("BASE_SSH_URL")
|
||||
NAVIGATEUR = os.environ.get("NAVIGATEUR")
|
@ -1,48 +1,38 @@
|
||||
# coding: utf8
|
||||
import unittest
|
||||
import time
|
||||
import subprocess
|
||||
import HtmlTestRunner
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
BASE_URL,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
||||
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
|
||||
|
||||
ACRONYME_FORMATION = "FormationTEST"
|
||||
|
||||
|
||||
def main():
|
||||
next_page = "test_vue"
|
||||
if NAVIGATEUR == "firefox":
|
||||
driver = webdriver.Firefox()
|
||||
else:
|
||||
driver = webdriver.Chrome()
|
||||
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
|
||||
driver.get(auth_page)
|
||||
driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
|
||||
driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
|
||||
driver.find_element_by_id("submit").click()
|
||||
# driver.get(SCHEMA + "://" + BASE_URL + "scodoc_admin")
|
||||
# time.sleep(2)
|
||||
# try:
|
||||
# select = Select(driver.find_element_by_id("delete-dept"))
|
||||
# select.select_by_visible_text(NOM_DPT)
|
||||
# driver.find_element_by_id("delete-dept").submit()
|
||||
# driver.close()
|
||||
# except NoSuchElementException:
|
||||
driver.close()
|
||||
# coding: utf8
|
||||
from setting import (
|
||||
SCODOC_ADMIN_ID,
|
||||
SCODOC_ADMIN_PASS,
|
||||
SCHEMA,
|
||||
SCODOC_SERVER,
|
||||
SCODOC_PORT,
|
||||
NOM_DPT,
|
||||
LINK_SCODOC_SERVER,
|
||||
BASE_SSH_URL,
|
||||
NAVIGATEUR,
|
||||
)
|
||||
from selenium import webdriver
|
||||
|
||||
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
|
||||
|
||||
ACRONYME_FORMATION = "FormationTEST"
|
||||
|
||||
|
||||
def main():
|
||||
if NAVIGATEUR == "firefox":
|
||||
driver = webdriver.Firefox()
|
||||
else:
|
||||
driver = webdriver.Chrome()
|
||||
auth_page = URL_AUTH + ("?next=" + URL_HOME).replace("/", "%2F")
|
||||
driver.get(auth_page)
|
||||
driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
|
||||
driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
|
||||
driver.find_element_by_id("submit").click()
|
||||
# driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "scodoc_admin")
|
||||
# time.sleep(2)
|
||||
# try:
|
||||
# select = Select(driver.find_element_by_id("delete-dept"))
|
||||
# select.select_by_visible_text(NOM_DPT)
|
||||
# driver.find_element_by_id("delete-dept").submit()
|
||||
# driver.close()
|
||||
# except NoSuchElementException:
|
||||
driver.close()
|
||||
|
Loading…
Reference in New Issue
Block a user