Compare commits

..

11 Commits

20 changed files with 1928 additions and 1875 deletions

View File

@ -1,4 +1,5 @@
BASE_URL = "https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" SCHEMA = "https"
BASE_URL = "scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/"
NOM_DPT = "test01" NOM_DPT = "test01"
SCODOC_ADMIN_ID = "admin_id" SCODOC_ADMIN_ID = "admin_id"
SCODOC_ADMIN_PASS = "admin_password" SCODOC_ADMIN_PASS = "admin_password"
@ -7,5 +8,5 @@ SCODOC_ENS_PASS = "enseignant_password@10"
SCODOC_CHEF_ID = "chef_id" SCODOC_CHEF_ID = "chef_id"
SCODOC_CHEF_PASS = "p@ssword42@" SCODOC_CHEF_PASS = "p@ssword42@"
LINK_SCODOC_SERVER = "root@ssh_server_scodoc" LINK_SCODOC_SERVER = "root@ssh_server_scodoc"
BASE_NOT_SECURED_URL = "scodoc-dev-iutinfo.univ-lille.fr/" BASE_SSH_URL = "scodoc-dev-iutinfo.univ-lille.fr/"
NAVIGATEUR = "firefox" NAVIGATEUR = "firefox"

View File

@ -1,89 +1,94 @@
# coding: utf8 # coding: utf8
import unittest import unittest
import time import time
import subprocess import subprocess
import HtmlTestRunner import HtmlTestRunner
import createDepartement import createDepartement
import creationSiteDepartement import creationSiteDepartement
import deleteDepartement import deleteDepartement
import suppressionSiteDepartement import suppressionSiteDepartement
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
NOM_DPT, SCODOC_SERVER,
LINK_SCODOC_SERVER, SCODOC_PORT,
BASE_NOT_SECURED_URL, NOM_DPT,
NAVIGATEUR, LINK_SCODOC_SERVER,
) BASE_SSH_URL,
from selenium import webdriver NAVIGATEUR,
from selenium.webdriver.common.keys import Keys )
from selenium.webdriver.support.ui import Select from selenium import webdriver
from selenium.webdriver.support.select import Select from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test URL_ROOT = SCHEMA + "://" + + + ":" + SCODOC_PORT
def setUp(self): URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
if NAVIGATEUR == "firefox": URL_SCODOC8 = "/".join((URL_ROOT, "index"))
self.driver = webdriver.Firefox() URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
else: URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
self.driver = webdriver.Chrome() URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
self.driver.get(
"https://" class PythonOrgSearch(unittest.TestCase):
+ SCODOC_ADMIN_ID # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
+ ":" def setUp(self):
+ SCODOC_ADMIN_PASS next_page = ""
+ "@" if NAVIGATEUR == "firefox":
+ BASE_NOT_SECURED_URL self.driver = webdriver.Firefox()
+ "force_admin_authentication" else:
) self.driver = webdriver.Chrome()
self.driver.get(BASE_URL) auth_page = URL_AUTH + "?next=%2F" + next_page
self.driver.get(auth_page)
# Test : Verification de la connexion admin effective self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
# @expected : "Bonjour admin" est présent sur la page d'accueil self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
def test_01_connexion_admin(self): self.driver.find_element_by_id("submit").click()
driver = self.driver self.driver.get(URL_SCODOC8)
self.assertTrue("admin" in driver.page_source)
# Test : Verification de la connexion admin effective
# Test : Creer un département # @expected : "Bonjour admin" est présent sur la page d'accueil
# @expected : Le département est présent sur la page d'accueil def test_01_connexion_admin(self):
def test_02_create_departement(self): driver = self.driver
driver = self.driver self.assertTrue("admin" in driver.page_source)
driver.get(BASE_URL + "/scodoc_admin")
time.sleep(2) # Test : Creer un département
select = Select(driver.find_element_by_id("create-dept")) # @expected : Le département est présent sur la page d'accueil
select.select_by_visible_text(NOM_DPT) def test_02_create_departement(self):
driver.find_element_by_id("create-dept").submit() driver = self.driver
time.sleep(1) driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
driver.find_element_by_id("tf_submit").click() time.sleep(2)
driver.get(BASE_URL) select = Select(driver.find_element_by_id("create-dept"))
self.assertTrue(NOM_DPT in driver.page_source) select.select_by_visible_text(NOM_DPT)
driver.find_element_by_id("create-dept").submit()
# Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données time.sleep(1)
# @expected : Le département n'apparait plus sur la page d'accueil driver.find_element_by_id("tf_submit").click()
def test_03_delete_departement(self): driver.get(URL_HOME)
driver = self.driver self.assertTrue(NOM_DPT in driver.page_source)
driver.get(BASE_URL + "/scodoc_admin")
select = Select(driver.find_element_by_id("delete-dept")) # Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données
select.select_by_visible_text(NOM_DPT) # @expected : Le département n'apparait plus sur la page d'accueil
driver.find_element_by_id("delete-dept").submit() def test_03_delete_departement(self):
driver.get(BASE_URL) driver = self.driver
self.assertTrue(NOM_DPT not in driver.page_source) driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
select = Select(driver.find_element_by_id("delete-dept"))
# ferme la fenetre à chaque fin de test select.select_by_visible_text(NOM_DPT)
def tearDown(self): driver.find_element_by_id("delete-dept").submit()
self.driver.close() driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
self.assertTrue(NOM_DPT not in driver.page_source)
if __name__ == "__main__": # ferme la fenetre à chaque fin de test
deleteDepartement.main() def tearDown(self):
createDepartement.main() self.driver.close()
suppressionSiteDepartement.main()
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner( if __name__ == "__main__":
report_name="01_création_département", deleteDepartement.main()
output="./ResultatTest", createDepartement.main()
combine_reports=True, suppressionSiteDepartement.main()
) unittest.main(
) testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="01_création_département",
output="./ResultatTest",
combine_reports=True,
)
)

View File

@ -6,13 +6,14 @@ import HtmlTestRunner
import createDepartement import createDepartement
import creationSiteDepartement import creationSiteDepartement
import deleteDepartement import deleteDepartement
import creationUtilisateurs
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT, NOM_DPT,
LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL,
NAVIGATEUR, NAVIGATEUR,
) )
from selenium import webdriver from selenium import webdriver
@ -23,9 +24,15 @@ from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select from selenium.webdriver.support.select import Select
URL = BASE_URL + NOM_DPT + "/Scolarite" 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" ACRONYME_FORMATION = "formationtest"
URL = URL_SCODOC8
class PythonOrgSearch(unittest.TestCase): class PythonOrgSearch(unittest.TestCase):
@ -36,27 +43,23 @@ class PythonOrgSearch(unittest.TestCase):
else: else:
self.driver = webdriver.Chrome() self.driver = webdriver.Chrome()
self.wait = WebDriverWait(self.driver, 10) self.wait = WebDriverWait(self.driver, 10)
self.driver.get( auth_page = URL_AUTH
"https://" self.driver.get(auth_page)
+ SCODOC_ADMIN_ID 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)
+ SCODOC_ADMIN_PASS self.driver.find_element_by_id("submit").click()
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
self.driver.get(BASE_URL + "/ScoDoc")
# Test Creer une formation # Test Creer une formation
# @expected : La formation se trouve dans le tableau de la liste des formations # @expected : La formation se trouve dans le tableau de la liste des formations
def test_011_create_formation(self): def test_011_create_formation(self):
driver = self.driver
global URL global URL
driver.get(URL) driver = self.driver
wait = self.wait
driver.get(URL_DEPT)
driver.find_element_by_id("link-programmes").click() driver.find_element_by_id("link-programmes").click()
URL = driver.current_url URL = driver.current_url
driver.find_element_by_id("link-create-formation").click() driver.find_element_by_id("link-create-formation").click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION) driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
driver.find_element_by_id("tf_titre").send_keys("TEST") driver.find_element_by_id("tf_titre").send_keys("TEST")
driver.find_element_by_id("tf_titre_officiel").send_keys("formation de test") driver.find_element_by_id("tf_titre_officiel").send_keys("formation de test")
@ -72,24 +75,26 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : Le nom de la formation est changé sur la page des formations # @expected : Le nom de la formation est changé sur la page des formations
def test_012_change_name_formation(self): def test_012_change_name_formation(self):
driver = self.driver driver = self.driver
global URL wait = self.wait
driver.get(URL) driver.get(URL)
idEditFormation = "edit-formation-" + ACRONYME_FORMATION.replace(" ","-") id_edit_formation = "edit-formation-" + ACRONYME_FORMATION.replace(" ", "-")
driver.find_element_by_id(idEditFormation).click() driver.find_element_by_id(id_edit_formation).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION) driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
driver.get(URL) driver.get(URL)
formations = driver.find_elements_by_class_name("acronyme") formations = driver.find_elements_by_class_name("acronyme")
textElementAcronyme = [] text_element_acronyme = []
for formation in formations: for formation in formations:
textElementAcronyme.append(formation.text) text_element_acronyme.append(formation.text)
self.assertTrue(ACRONYME_FORMATION + ACRONYME_FORMATION in textElementAcronyme) self.assertTrue(
ACRONYME_FORMATION + ACRONYME_FORMATION in text_element_acronyme
)
# Remise du nom à celui de départ # Remise du nom à celui de départ
driver.get(URL) driver.get(URL)
idEditFormation = "edit-formation-" + ACRONYME_FORMATION + ACRONYME_FORMATION id_edit_formation = "edit-formation-" + ACRONYME_FORMATION + ACRONYME_FORMATION
driver.find_element_by_id(idEditFormation).click() driver.find_element_by_id(id_edit_formation).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_id("tf_acronyme").clear() 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_acronyme").send_keys(ACRONYME_FORMATION)
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
@ -98,10 +103,10 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : La formation n'as pas pu être créée et on arrive donc sur un message d'erreur à la création # @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): def test_013_same_name_formation(self):
driver = self.driver driver = self.driver
global URL wait = self.wait
driver.get(URL) driver.get(URL)
driver.find_element_by_id("link-create-formation").click() driver.find_element_by_id("link-create-formation").click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION) driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION)
driver.find_element_by_id("tf_titre").send_keys("TEST") driver.find_element_by_id("tf_titre").send_keys("TEST")
driver.find_element_by_id("tf_titre_officiel").send_keys("formation de test") driver.find_element_by_id("tf_titre_officiel").send_keys("formation de test")
@ -117,19 +122,19 @@ class PythonOrgSearch(unittest.TestCase):
# @Expected : L'UE est créée et elle apparait désormais dans la liste d'UE de 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): def test_014_ajout_UE(self):
driver = self.driver driver = self.driver
global URL wait = self.wait
driver.get(URL) driver.get(URL)
idTitre = "titre-" + ACRONYME_FORMATION.replace(" ", "-") id_titre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(id_titre).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_xpath("//a[contains(@href,'ue_create?')]").click() 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_titre").send_keys("UE TEST")
driver.find_element_by_id("tf_acronyme").send_keys("TEST") driver.find_element_by_id("tf_acronyme").send_keys("TEST")
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
time.sleep(1) time.sleep(1)
driver.get(URL) driver.get(URL)
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(id_titre).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
self.assertTrue("TEST UE TEST" in driver.page_source) self.assertTrue("TEST UE TEST" in driver.page_source)
driver.get(URL) driver.get(URL)
@ -137,13 +142,13 @@ class PythonOrgSearch(unittest.TestCase):
# @Expected : La matière est créée et elle apparait désormais sur la page de détail de 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): def test_015_ajout_matiere(self):
driver = self.driver driver = self.driver
global URL wait = self.wait
nomMat = "unematieretest"
driver.get(URL) driver.get(URL)
nomMat = "unematieretest"
time.sleep(3) time.sleep(3)
idTitre = "titre-" + ACRONYME_FORMATION idTitre = "titre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
time.sleep(3) time.sleep(3)
driver.find_element_by_xpath("//a[contains(@href,'matiere_create?')]").click() 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_titre").send_keys(nomMat)
@ -153,7 +158,7 @@ class PythonOrgSearch(unittest.TestCase):
driver.get(URL) driver.get(URL)
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
time.sleep(3) time.sleep(3)
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
elements = driver.find_elements_by_xpath("//a[contains(@href,'matiere_edit?')]") elements = driver.find_elements_by_xpath("//a[contains(@href,'matiere_edit?')]")
matIsPresent = False matIsPresent = False
for element in elements: for element in elements:
@ -165,17 +170,19 @@ class PythonOrgSearch(unittest.TestCase):
# @Expected : Le semestre est créé et il apparait désormais dans la table des formations # @Expected : Le semestre est créé et il apparait désormais dans la table des formations
def test_016_ajout_Semestre(self): def test_016_ajout_Semestre(self):
driver = self.driver driver = self.driver
global URL wait = self.wait
driver.get(URL) driver.get(URL)
idAddSemestre = "add-semestre-" + ACRONYME_FORMATION.replace(" ", "-") idAddSemestre = "add-semestre-" + ACRONYME_FORMATION.lower().replace(" ", "-")
driver.find_element_by_id(idAddSemestre).click() driver.find_element_by_id(idAddSemestre).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_name("date_debut").send_keys("01/01/2021") 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("date_fin").send_keys("30/06/2021")
driver.find_element_by_name("responsable_id").send_keys("BACH Test (Bach)") 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") Select(driver.find_element_by_id("tf_semestre_id")).select_by_value("4")
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
self.assertTrue( self.assertTrue(
"Nouveau semestre créé" "Nouveau semestre créé"
in driver.find_element_by_class_name("head_message").text in driver.find_element_by_class_name("head_message").text
@ -188,62 +195,62 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : La formation est dupliquée et à la version "2" # @expected : La formation est dupliquée et à la version "2"
def test_017_creer_nouvelle_version_formation(self): def test_017_creer_nouvelle_version_formation(self):
driver = self.driver driver = self.driver
global URL wait = self.wait
driver.get(URL) driver.get(URL)
idTitre = "titre-" + ACRONYME_FORMATION idTitre = "titre-" + ACRONYME_FORMATION
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
tmpurl = driver.current_url tmpurl = driver.current_url
driver.find_element_by_xpath( driver.find_element_by_xpath(
"//a[contains(@href,'formation_create_new_version?')]" "//a[contains(@href,'formation_create_new_version?')]"
).click() ).click()
self.wait.until(EC.url_changes(tmpurl)) wait.until(EC.url_changes(tmpurl))
self.assertTrue("Nouvelle version !" in driver.page_source) self.assertTrue("Nouvelle version !" in driver.page_source)
driver.get(URL) driver.get(URL)
elements = driver.find_elements_by_class_name("version") elements = driver.find_elements_by_class_name("version")
versionIsPresent = False version_is_present = False
for element in elements: for element in elements:
if element.text == "2": if element.text == "2":
versionIsPresent = True version_is_present = True
self.assertTrue(versionIsPresent) self.assertTrue(version_is_present)
# Test : Supprime une formation après avoir supprimé les semestres qui y sont rattachés # 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 # @expected : La formation n'apparait plus dans le tableau des formations
def test_020_delete_formation(self): def test_020_delete_formation(self):
driver = self.driver driver = self.driver
global URL wait = self.wait
driver.get(URL) driver.get(URL)
idButtonDelete = "delete-formation-" + ACRONYME_FORMATION id_button_delete = "delete-formation-" + ACRONYME_FORMATION
driver.find_element_by_id(idButtonDelete).click() driver.find_element_by_id(id_button_delete).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
tmpURLDelete = driver.current_url tmp_url_delete = driver.current_url
listeSemestres = driver.find_elements_by_xpath( liste_semestres = driver.find_elements_by_xpath(
"//a[contains(@href, 'formsemestre_status?')]" "//a[contains(@href, 'formsemestre_status?')]"
) )
for semestre in listeSemestres: for semestre in liste_semestres:
semestre.click() semestre.click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_xpath( driver.find_element_by_xpath(
"(//a[contains(text(),'Semestre')])[2]" "(//a[contains(text(),'Semestre')])[2]"
).click() ).click()
driver.find_element_by_xpath( driver.find_element_by_xpath(
"//a[contains(@href, 'formsemestre_delete?')]" "//a[contains(@href, 'formsemestre_delete?')]"
).click() ).click()
self.wait.until(EC.url_changes(URL)) wait.until(EC.url_changes(URL))
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
time.sleep(2) time.sleep(2)
driver.find_element_by_xpath("//input[@value='OK']").click() driver.find_element_by_xpath("//input[@value='OK']").click()
driver.get(tmpURLDelete) driver.get(tmp_url_delete)
driver.find_element_by_xpath( driver.find_element_by_xpath(
"//input[@value='Supprimer cette formation']" "//input[@value='Supprimer cette formation']"
).click() ).click()
driver.get(URL) driver.get(URL)
formations = driver.find_elements_by_class_name("version") formations = driver.find_elements_by_class_name("version")
formationDelete = True formation_delete = True
for formation in formations: for formation in formations:
if "1" in formation.text: if "1" in formation.text:
formationDelete = False formation_delete = False
self.assertTrue(formationDelete) self.assertTrue(formation_delete)
# def test_create_module(self): # def test_create_module(self):
# driver = self.driver # driver = self.driver
@ -258,6 +265,7 @@ if __name__ == "__main__":
deleteDepartement.main() deleteDepartement.main()
createDepartement.main() createDepartement.main()
creationSiteDepartement.main() creationSiteDepartement.main()
creationUtilisateurs.main()
unittest.main( unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner( testRunner=HtmlTestRunner.HTMLTestRunner(

View File

@ -1,208 +1,215 @@
import unittest import unittest
import time import time
import HtmlTestRunner import HtmlTestRunner
import subprocess import subprocess
import createDepartement import createDepartement
import creationSiteDepartement import creationSiteDepartement
import deleteDepartement import deleteDepartement
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
NOM_DPT, SCODOC_SERVER,
LINK_SCODOC_SERVER, SCODOC_PORT,
BASE_NOT_SECURED_URL, NOM_DPT,
NAVIGATEUR, LINK_SCODOC_SERVER,
) BASE_SSH_URL,
import urllib.parse as urlparse NAVIGATEUR,
from urllib.parse import parse_qs )
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select from selenium.webdriver.support.select import Select
URL = BASE_URL + NOM_DPT + "/Scolarite" URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
nomEtu = "Semestre11" nomEtu = "Semestre11"
prenomEtu = "Etudiant1" prenomEtu = "Etudiant1"
nip = "11122234" nip = "11122234"
domicile = "50 rue de la marmite" domicile = "50 rue de la marmite"
codepostaldomicile = "59000" codepostaldomicile = "59000"
paysdomicile = "Lille" paysdomicile = "Lille"
URL_ROOT = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT
class PythonOrgSearch(unittest.TestCase): URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test URL_SCODOC8 = "/".join((URL_ROOT, "index"))
def setUp(self): URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
if NAVIGATEUR == "firefox": URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
self.driver = webdriver.Firefox() URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
else:
self.driver = webdriver.Chrome() ACRONYME_FORMATION = "formationtest"
self.wait = WebDriverWait(self.driver, 10) URL = URL_SCODOC8
self.driver.get(
"https://" class PythonOrgSearch(unittest.TestCase):
+ SCODOC_ADMIN_ID # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
+ ":" def setUp(self):
+ SCODOC_ADMIN_PASS next_page = ""
+ "@" if NAVIGATEUR == "firefox":
+ BASE_NOT_SECURED_URL self.driver = webdriver.Firefox()
+ "force_admin_authentication" else:
) self.driver = webdriver.Chrome()
global URL self.wait = WebDriverWait(self.driver, 10)
self.driver.get(URL) auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
self.driver.get(auth_page)
# Test : creer un etudiant et verifie si sa fiche etudiante est creee self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
# @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 self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
def test_01_creation_etudiant(self): self.driver.find_element_by_id("submit").click()
driver = self.driver self.driver.get(URL_HOME)
global URL
driver.find_element_by_id("link-create-student").click() # Test : creer un etudiant et verifie si sa fiche etudiante est creee
self.wait.until(EC.url_changes(URL)) # @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
URL = driver.current_url def test_01_creation_etudiant(self):
driver.find_element_by_id("tf_nom").send_keys(nomEtu) driver = self.driver
driver.find_element_by_id("tf_prenom").send_keys(prenomEtu) global URL
driver.find_element_by_id("tf_annee").send_keys("2021") driver.find_element_by_id("link-create-student").click()
driver.find_element_by_id("tf_code_nip").send_keys(nip) self.wait.until(EC.url_changes(URL))
driver.find_element_by_name("dont_check_homonyms:list").click() URL = driver.current_url
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_nom").send_keys(nomEtu)
time.sleep(1) driver.find_element_by_id("tf_prenom").send_keys(prenomEtu)
self.assertTrue("M. " + prenomEtu + " " + nomEtu.upper() in driver.page_source) driver.find_element_by_id("tf_annee").send_keys("2021")
self.assertTrue(nip in driver.page_source) driver.find_element_by_id("tf_code_nip").send_keys(nip)
driver.find_element_by_name("dont_check_homonyms:list").click()
# Test : Creer un étudiant avec un nip qui est déjà présent dans la base Scodoc driver.find_element_by_id("tf_submit").click()
# @expected : La création mène à une page qui affiche "code étudiant dupliqué", l'étudiant n'est pas créé time.sleep(1)
def test_02_creation_etudiant_avec_meme_nip(self): self.assertTrue("M. " + prenomEtu + " " + nomEtu.upper() in driver.page_source)
driver = self.driver self.assertTrue(nip in driver.page_source)
global URL
driver.get(URL) # Test : Creer un étudiant avec un nip qui est déjà présent dans la base Scodoc
driver.find_element_by_id("tf_nom").send_keys(nomEtu) # @expected : La création mène à une page qui affiche "code étudiant dupliqué", l'étudiant n'est pas créé
driver.find_element_by_id("tf_prenom").send_keys(prenomEtu) def test_02_creation_etudiant_avec_meme_nip(self):
driver.find_element_by_id("tf_annee").send_keys("2021") driver = self.driver
driver.find_element_by_id("tf_code_nip").send_keys(nip) global URL
driver.find_element_by_name("dont_check_homonyms:list").click() driver.get(URL)
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_nom").send_keys(nomEtu)
time.sleep(1) driver.find_element_by_id("tf_prenom").send_keys(prenomEtu)
self.assertTrue( driver.find_element_by_id("tf_annee").send_keys("2021")
"Code étudiant (code_nip) dupliqué !" driver.find_element_by_id("tf_code_nip").send_keys(nip)
in driver.find_element_by_class_name("title-error").text driver.find_element_by_name("dont_check_homonyms:list").click()
) driver.find_element_by_id("tf_submit").click()
time.sleep(1)
# Test Modification de l'adresse étudiant self.assertTrue(
# expected : La nouvelle adresse est mise à jour sur la page information de l'étudiant "Code étudiant (code_nip) dupliqué !"
def test_03_modification_adresse_etudiant(self): in driver.find_element_by_class_name("title-error").text
driver = self.driver )
global URL
driver.get(URL) # Test Modification de l'adresse étudiant
element = driver.find_element_by_id("in-expnom") # expected : La nouvelle adresse est mise à jour sur la page information de l'étudiant
element.send_keys(nomEtu) def test_03_modification_adresse_etudiant(self):
element.submit() driver = self.driver
self.wait.until(EC.url_changes(URL)) global URL
driver.find_element_by_xpath( driver.get(URL)
"//a[contains(@href,'formChangeCoordonnees')]" element = driver.find_element_by_id("in-expnom")
).click() element.send_keys(nomEtu)
time.sleep(1) element.submit()
driver.find_element_by_id("tf_domicile").send_keys(domicile) self.wait.until(EC.url_changes(URL))
driver.find_element_by_id("tf_codepostaldomicile").send_keys(codepostaldomicile) driver.find_element_by_xpath(
driver.find_element_by_id("tf_paysdomicile").send_keys(paysdomicile) "//a[contains(@href,'formChangeCoordonnees')]"
driver.find_element_by_id("tf_submit").click() ).click()
time.sleep(1) time.sleep(1)
self.assertTrue( driver.find_element_by_id("tf_domicile").send_keys(domicile)
codepostaldomicile in driver.find_element_by_id("student-address").text 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()
# Test Inscription d'un étudiant dans un semestre time.sleep(1)
# @expected : self.assertTrue(
def test_04_inscription_etudiant(self): codepostaldomicile in driver.find_element_by_id("student-address").text
driver = self.driver )
global URL
driver.get(URL) # Test Inscription d'un étudiant dans un semestre
element = driver.find_element_by_id("in-expnom") # @expected :
element.send_keys(nomEtu) def test_04_inscription_etudiant(self):
element.submit() driver = self.driver
self.wait.until(EC.url_changes(URL)) global URL
driver.find_element_by_xpath( driver.get(URL)
"//a[contains(@href, 'formsemestre_inscription_with_modules_form')]" element = driver.find_element_by_id("in-expnom")
).click() element.send_keys(nomEtu)
self.wait.until(EC.url_changes(URL)) element.submit()
try: self.wait.until(EC.url_changes(URL))
semestres = driver.find_elements_by_xpath( driver.find_element_by_xpath(
"//a[contains(@id,'inscription-semestre-')]" "//a[contains(@href, 'formsemestre_inscription_with_modules_form')]"
) ).click()
except NoSuchElementException: self.wait.until(EC.url_changes(URL))
self.assertFalse(True) try:
semestres[0].click() semestres = driver.find_elements_by_xpath(
driver.find_element_by_xpath("//input[@value='Inscrire']").click() "//a[contains(@id,'inscription-semestre-')]"
time.sleep(2) )
boutonInscrireIsNotPresent = False except NoSuchElementException:
try: self.assertFalse(True)
driver.find_element_by_partial_link_text("inscrire") semestres[0].click()
except: driver.find_element_by_xpath("//input[@value='Inscrire']").click()
boutonInscrireIsNotPresent = True time.sleep(2)
self.assertTrue(boutonInscrireIsNotPresent) bouton_inscrire_is_not_present = False
try:
# Test Supprime un étudiant driver.find_element_by_partial_link_text("inscrire")
# @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait except:
def test_05_suppresion_etudiant(self): bouton_inscrire_is_not_present = True
driver = self.driver self.assertTrue(bouton_inscrire_is_not_present)
urlRecherche = (
"https://" # Test Supprime un étudiant
+ BASE_NOT_SECURED_URL # @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait
+ "ScoDoc/" def test_05_suppresion_etudiant(self):
+ NOM_DPT driver = self.driver
+ "/Scolarite/search_etud_in_dept" urlRecherche = (
) SCHEMA
driver.get(urlRecherche) + "://"
element = driver.find_element_by_name("expnom") + SCODOC_SERVER + ":" + SCODOC_PORT
element.send_keys(nomEtu) + "ScoDoc/"
element.submit() + NOM_DPT
time.sleep(1) + "/Scolarite/search_etud_in_dept"
etudid = driver.find_element_by_id("euid") )
url = ( driver.get(urlRecherche)
"https://" element = driver.find_element_by_name("expnom")
+ BASE_NOT_SECURED_URL element.send_keys(nomEtu)
+ "ScoDoc/" element.submit()
+ NOM_DPT time.sleep(1)
+ "/Scolarite/etudident_delete?etudid=" etudid = driver.find_element_by_id("euid")
+ etudid.text url = (
) SCHEMA
driver.get(url) + "://"
time.sleep(1) + SCODOC_SERVER + ":" + SCODOC_PORT
driver.find_element_by_xpath( + "ScoDoc/"
"//input[@value='Supprimer définitivement cet étudiant']" + NOM_DPT
).click() + "/Scolarite/etudident_delete?etudid="
driver.get(urlRecherche) + etudid.text
element = driver.find_element_by_name("expnom") )
element.send_keys(nomEtu) driver.get(url)
element.submit() time.sleep(1)
time.sleep(1) driver.find_element_by_xpath(
try: "//input[@value='Supprimer définitivement cet étudiant']"
element = driver.find_element_by_id("title-no-result") ).click()
self.assertTrue("Aucun résultat" in element.text) driver.get(urlRecherche)
except: element = driver.find_element_by_name("expnom")
self.assertFalse(True) element.send_keys(nomEtu)
element.submit()
# ferme la fenetre time.sleep(1)
def tearDown(self): try:
self.driver.close() element = driver.find_element_by_id("title-no-result")
self.assertTrue("Aucun résultat" in element.text)
except:
if __name__ == "__main__": self.assertFalse(True)
deleteDepartement.main()
createDepartement.main() # ferme la fenetre
creationSiteDepartement.main() def tearDown(self):
cmdProcess = [ self.driver.close()
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
NOM_DPT, if __name__ == "__main__":
"test_scenario1_formation.py", deleteDepartement.main()
] createDepartement.main()
process = subprocess.Popen(cmdProcess) creationSiteDepartement.main()
process.wait() cmdProcess = [
unittest.main( "./scriptExecution.sh",
testRunner=HtmlTestRunner.HTMLTestRunner( LINK_SCODOC_SERVER,
report_name="03_Etudiant_test", NOM_DPT,
output="./ResultatTest", "test_scenario1_formation.py",
combine_reports=True, ]
) process = subprocess.Popen(cmdProcess)
) process.wait()
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="03_Etudiant_test",
output="./ResultatTest",
combine_reports=True,
)
)

View File

@ -1,174 +1,171 @@
import unittest import unittest
import time import time
import urllib.parse as urlparse import urllib.parse as urlparse
import subprocess import subprocess
import HtmlTestRunner import HtmlTestRunner
import createDepartement import createDepartement
import creationSiteDepartement import creationSiteDepartement
import deleteDepartement import deleteDepartement
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
NOM_DPT, SCODOC_SERVER,
LINK_SCODOC_SERVER, SCODOC_PORT,
BASE_NOT_SECURED_URL, NOM_DPT,
NAVIGATEUR, LINK_SCODOC_SERVER,
) BASE_SSH_URL,
from urllib.parse import parse_qs NAVIGATEUR,
from selenium import webdriver )
from selenium.webdriver.common.keys import Keys from urllib.parse import parse_qs
from selenium.webdriver.support import expected_conditions as EC from selenium import webdriver
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
URL = BASE_URL + NOM_DPT + "/Scolarite" from selenium.webdriver.support.select import Select
NOM_ETU = "Semestre11"
PRENOM_ETU = "EtudiantNumero1" URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
dateDebutAbsenceNonJustifiee = "31/05/2021" NOM_ETU = "Semestre11"
dateDebutAbsenceJustifiee = "25/05/2021" 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): class PythonOrgSearch(unittest.TestCase):
if NAVIGATEUR == "firefox": # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
self.driver = webdriver.Firefox() def setUp(self):
else: next_page = ""
self.driver = webdriver.Chrome() if NAVIGATEUR == "firefox":
self.wait = WebDriverWait(self.driver, 10) self.driver = webdriver.Firefox()
self.driver.get( else:
"https://" self.driver = webdriver.Chrome()
+ SCODOC_ADMIN_ID auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
+ ":" self.driver.get(auth_page)
+ SCODOC_ADMIN_PASS 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)
+ BASE_NOT_SECURED_URL self.driver.find_element_by_id("submit").click()
+ "force_admin_authentication" self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
)
global URL def test_010_trouver_etudiant(self):
self.driver.get(URL) driver = self.driver
global URL
def test_010_trouver_etudiant(self): self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite")
driver = self.driver element = self.driver.find_element_by_id("in-expnom")
global URL element.send_keys(NOM_ETU)
self.driver.get(BASE_URL + NOM_DPT + "/Scolarite") element.submit()
element = self.driver.find_element_by_id("in-expnom") self.wait.until(EC.url_changes(URL))
element.send_keys(NOM_ETU) URL = driver.current_url
element.submit() self.assertTrue(NOM_ETU.upper() in driver.page_source)
self.wait.until(EC.url_changes(URL))
URL = driver.current_url # Test : creer une absence non justifiée
self.assertTrue(NOM_ETU.upper() in driver.page_source) # @expected : La fiche étudiante est incrémentée avec le nombre d'absence injustifiée correspondant
def test_020_ajout_absence_non_justifiee(self):
# Test : creer une absence non justifiée driver = self.driver
# @expected : La fiche étudiante est incrémentée avec le nombre d'absence injustifiée correspondant global URL
def test_020_ajout_absence_non_justifiee(self): driver.find_element_by_id("add-absence").click()
driver = self.driver driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
global URL driver.find_element_by_id("butsubmit").submit()
driver.find_element_by_id("add-absence").click() time.sleep(1)
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee) self.assertTrue(
driver.find_element_by_id("butsubmit").submit() "Ajout de 2 absences <b>NON justifiées</b>" in driver.page_source
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)
driver = self.driver
driver.find_element_by_link_text("Liste").click() # def test_modification_liste_absence_non_justifiee(self):
self.assertTrue("2 absences non justifiées:" in driver.page_source) # driver = self.driver
# driver.find_element_by_link_text("Liste").click()
# def test_modification_liste_absence_non_justifiee(self): # self.assertTrue("2 absences non justifiées:" in driver.page_source)
# driver = self.driver
# driver.find_element_by_link_text("Liste").click() # Test pour ajouter deux absences justifiées
# self.assertTrue("2 absences non justifiées:" in driver.page_source) # @expected : La fiche d'information de l'étudiant concerné à son compteur d'absence augmenté de 2
def test_021_ajout_absence_justifiee(self):
# Test pour ajouter deux absences justifiées driver = self.driver
# @expected : La fiche d'information de l'étudiant concerné à son compteur d'absence augmenté de 2 global URL
def test_021_ajout_absence_justifiee(self): driver.find_element_by_id("add-absence").click()
driver = self.driver driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
global URL driver.find_element_by_name("estjust").click()
driver.find_element_by_id("add-absence").click() driver.find_element_by_id("butsubmit").submit()
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee) time.sleep(1)
driver.find_element_by_name("estjust").click() self.assertTrue("Ajout de 2 absences <b>justifiées</b>" in driver.page_source)
driver.find_element_by_id("butsubmit").submit() driver = self.driver
time.sleep(1) driver.find_element_by_link_text("Liste").click()
self.assertTrue("Ajout de 2 absences <b>justifiées</b>" in driver.page_source) self.assertTrue("2 absences justifiées:" in driver.page_source)
driver = self.driver
driver.find_element_by_link_text("Liste").click() # def test_modification_liste_absence_justifiee(self):
self.assertTrue("2 absences justifiées:" in driver.page_source) # driver = self.driver
# driver.find_element_by_link_text("Liste").click()
# def test_modification_liste_absence_justifiee(self): # self.assertTrue("2 absences justifiées:" in driver.page_source)
# driver = self.driver
# driver.find_element_by_link_text("Liste").click() # Test Justification d'une absence non justifiée
# self.assertTrue("2 absences justifiées:" in driver.page_source) # @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):
# Test Justification d'une absence non justifiée driver = self.driver
# @expected : Le champs des absences non justifiées diminue et celui des justifiés augmente du nombre d'absence global URL
def test_022_ajout_justification(self): driver.find_element_by_id("justify-absence").click()
driver = self.driver driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
global URL driver.find_element_by_name("description").send_keys("Un test selenium")
driver.find_element_by_id("justify-absence").click() driver.find_element_by_xpath("//input[@value='Envoyer']").click()
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee) self.wait.until(EC.url_changes(URL))
driver.find_element_by_name("description").send_keys("Un test selenium") self.assertTrue("Ajout de 2 <b>justifications</b>" in driver.page_source)
driver.find_element_by_xpath("//input[@value='Envoyer']").click() driver = self.driver
self.wait.until(EC.url_changes(URL)) driver.find_element_by_link_text("Liste").click()
self.assertTrue("Ajout de 2 <b>justifications</b>" in driver.page_source) self.assertTrue("2 absences justifiées:" in driver.page_source)
driver = self.driver self.assertTrue("absences non justifiées:" in driver.page_source)
driver.find_element_by_link_text("Liste").click()
self.assertTrue("2 absences justifiées:" in driver.page_source) # def test_modification_liste_ajout_justification(self):
self.assertTrue("absences non justifiées:" in driver.page_source) # driver = self.driver
# driver.find_element_by_link_text("Liste").click()
# def test_modification_liste_ajout_justification(self): # self.assertTrue("4 absences justifiées:" in driver.page_source)
# driver = self.driver # self.assertTrue("absences non justifiées:" not in driver.page_source)
# driver.find_element_by_link_text("Liste").click()
# self.assertTrue("4 absences justifiées:" in driver.page_source) # Test Suppression des absences pour un élève
# self.assertTrue("absences non justifiées:" not in driver.page_source) # @expected : Les compteurs d'absences sont remplacés par "Pas d'absences"
def test_024_supprimer_absence(self):
# Test Suppression des absences pour un élève driver = self.driver
# @expected : Les compteurs d'absences sont remplacés par "Pas d'absences" global URL
def test_024_supprimer_absence(self): driver.find_element_by_id("delete-absence").click()
driver = self.driver driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee)
global URL driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
driver.find_element_by_id("delete-absence").click() self.wait.until(EC.url_changes(URL))
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceJustifiee) self.assertTrue("Annulation sur 2 demi-journées " in driver.page_source)
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click() driver.find_element_by_id("delete-absence").click()
self.wait.until(EC.url_changes(URL)) driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee)
self.assertTrue("Annulation sur 2 demi-journées " in driver.page_source) driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click()
driver.find_element_by_id("delete-absence").click() self.wait.until(EC.url_changes(URL))
driver.find_element_by_name("datedebut").send_keys(dateDebutAbsenceNonJustifiee) driver.find_element_by_id("display-list-absence").click()
driver.find_element_by_xpath("//input[@value='Supprimer les absences']").click() self.assertTrue("Pas d'absences justifiées" in driver.page_source)
self.wait.until(EC.url_changes(URL)) self.assertTrue("Pas d'absences non justifiées" in driver.page_source)
driver.find_element_by_id("display-list-absence").click()
self.assertTrue("Pas d'absences justifiées" in driver.page_source) # def test_modification_liste_supression_absence(self):
self.assertTrue("Pas d'absences non justifiées" in driver.page_source) # driver = self.driver
# driver.find_element_by_link_text("Liste").click()
# def test_modification_liste_supression_absence(self): # self.assertTrue("2 absences justifiées:" in driver.page_source)
# driver = self.driver # self.assertTrue("absences non justifiées:" not in driver.page_source)
# driver.find_element_by_link_text("Liste").click()
# self.assertTrue("2 absences justifiées:" in driver.page_source) # ferme la fenetre
# self.assertTrue("absences non justifiées:" not in driver.page_source) def tearDown(self):
self.driver.close()
# ferme la fenetre
def tearDown(self):
self.driver.close() if __name__ == "__main__":
deleteDepartement.main()
createDepartement.main()
if __name__ == "__main__": creationSiteDepartement.main()
deleteDepartement.main() cmdProcess = [
createDepartement.main() "./scriptExecution.sh",
creationSiteDepartement.main() LINK_SCODOC_SERVER,
cmdProcess = [ NOM_DPT,
"./scriptExecution.sh", "test_scenario2_formation.py",
LINK_SCODOC_SERVER, ]
NOM_DPT, process = subprocess.Popen(cmdProcess)
"test_scenario2_formation.py", process.wait()
] unittest.main(
process = subprocess.Popen(cmdProcess) testRunner=HtmlTestRunner.HTMLTestRunner(
process.wait() report_name="04_Absences_tests",
unittest.main( output="./ResultatTest",
testRunner=HtmlTestRunner.HTMLTestRunner( combine_reports=True,
report_name="04_Absences_tests", )
output="./ResultatTest", )
combine_reports=True,
)
)

View File

@ -1,411 +1,404 @@
import unittest import unittest
import time import time
import subprocess import subprocess
import urllib.parse as urlparse import urllib.parse as urlparse
import HtmlTestRunner import HtmlTestRunner
import createDepartement import createDepartement
import creationSiteDepartement import creationSiteDepartement
import deleteDepartement import deleteDepartement
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
NOM_DPT, SCODOC_SERVER,
SCODOC_ENS_ID, SCODOC_PORT,
SCODOC_ENS_PASS, NOM_DPT,
SCODOC_CHEF_ID, SCODOC_ENS_ID,
SCODOC_CHEF_PASS, SCODOC_ENS_PASS,
NAVIGATEUR, SCODOC_CHEF_ID,
LINK_SCODOC_SERVER, SCODOC_CHEF_PASS,
BASE_NOT_SECURED_URL, NAVIGATEUR,
) LINK_SCODOC_SERVER,
from urllib.parse import parse_qs BASE_SSH_URL,
from selenium import webdriver )
from selenium.webdriver.common.keys import Keys from urllib.parse import parse_qs
from selenium.common.exceptions import NoSuchElementException from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.select import Select from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
URL_MATIERE = "" from selenium.webdriver.support.select import Select
URL_SEMESTRE = ""
URL = BASE_URL + NOM_DPT + "/Scolarite" URL_MATIERE = ""
PRENOM_ENS = "Ens" URL_SEMESTRE = ""
PRENOM_CHEF = "Chef" URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
isAdmin = True PRENOM_ENS = "Ens"
isChef = False PRENOM_CHEF = "Chef"
isEns = False isAdmin = True
# Prérequis isChef = False
class PythonOrgSearch(unittest.TestCase): isEns = False
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test # Prérequis
def setUp(self): class PythonOrgSearch(unittest.TestCase):
if NAVIGATEUR == "firefox": # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
self.driver = webdriver.Firefox() def setUp(self):
else: next_page = ""
self.driver = webdriver.Chrome() if NAVIGATEUR == "firefox":
self.wait = WebDriverWait(self.driver, 10) self.driver = webdriver.Firefox()
if isAdmin: else:
self.driver.get( self.driver = webdriver.Chrome()
"https://" self.wait = WebDriverWait(self.driver, 10)
+ SCODOC_ADMIN_ID auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
+ ":" self.driver.get(auth_page)
+ SCODOC_ADMIN_PASS if isAdmin:
+ "@" self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
+ BASE_NOT_SECURED_URL self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
+ "force_admin_authentication" elif isChef:
) self.driver.find_element_by_id("user_name").send_keys(SCODOC_CHEF_ID)
else: self.driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
self.driver.get(BASE_URL + NOM_DPT + "/Scolarite") elif isEns:
if isChef: self.driver.find_element_by_id("user_name").send_keys(SCODOC_ENS_ID)
self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_CHEF_ID) self.driver.find_element_by_id("password").send_keys(SCODOC_ENS_PASS)
self.driver.find_element_by_name("__ac_password").send_keys( self.driver.find_element_by_id("submit").click()
SCODOC_CHEF_PASS self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
)
time.sleep(3) # Test : Vérifie s'il y a un semestre en cours
self.driver.find_element_by_name("submit").click() # @expected : La class listesems n'est pas vide et contient "Session en cours"
elif isEns: def test_010_semestre_en_cours(self):
self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_ENS_ID) driver = self.driver
self.driver.find_element_by_name("__ac_password").send_keys( global URL
SCODOC_ENS_PASS driver.get(URL)
) # time.sleep(1)
self.driver.find_element_by_name("submit").click() self.assertTrue(
"Sessions en cours" in driver.find_element_by_class_name("listesems").text
# 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): # Test : Vérifie si une matière existe
driver = self.driver # @expected : Le nom de la matière est présent dans le semestre préalablement testé
global URL def test_020_matiere_existante(self):
driver.get(URL) driver = self.driver
# time.sleep(1) global URL
self.assertTrue( driver.get(URL)
"Sessions en cours" in driver.find_element_by_class_name("listesems").text driver.find_element_by_link_text("semestre 4").click()
) self.wait.until(EC.url_changes(URL))
matiereExist = False
# Test : Vérifie si une matière existe try:
# @expected : Le nom de la matière est présent dans le semestre préalablement testé driver.find_element_by_class_name("formsemestre_status_ue")
def test_020_matiere_existante(self): global URL_SEMESTRE
driver = self.driver URL_SEMESTRE = driver.current_url
global URL matiereExist = True
driver.get(URL) except NoSuchElementException:
driver.find_element_by_link_text("semestre 4").click() matiereExist = False
self.wait.until(EC.url_changes(URL)) self.assertTrue(matiereExist)
matiereExist = False
try: #Test : Changement de responsable sur module
driver.find_element_by_class_name("formsemestre_status_ue") # @expected : Le nom du responsable choisi apparait désormais sur le module concerné
global URL_SEMESTRE def test_030_changement_responsable_sur_module(self):
URL_SEMESTRE = driver.current_url driver = self.driver
matiereExist = True isThere = False
except NoSuchElementException: driver.get(URL_SEMESTRE)
matiereExist = False driver.find_element_by_link_text("M4101C").click()
self.assertTrue(matiereExist) time.sleep(1)
global URL_MATIERE
#Test : Changement de responsable sur module URL_MATIERE = driver.current_url
# @expected : Le nom du responsable choisi apparait désormais sur le module concerné driver.find_element_by_xpath(
def test_030_changement_responsable_sur_module(self): "//a[contains(@href,'edit_moduleimpl_resp?')]"
driver = self.driver ).click()
isThere = False self.wait.until(EC.url_changes(URL_MATIERE))
driver.get(URL_SEMESTRE) constructIdResponsable = (
driver.find_element_by_link_text("M4101C").click() SCODOC_CHEF_ID.upper()
time.sleep(1) + " "
global URL_MATIERE + PRENOM_CHEF
URL_MATIERE = driver.current_url + " ("
driver.find_element_by_xpath( + SCODOC_CHEF_ID.lower()
"//a[contains(@href,'edit_moduleimpl_resp?')]" + ")"
).click() )
self.wait.until(EC.url_changes(URL_MATIERE)) idInput = driver.find_element_by_name("responsable_id")
constructIdResponsable = ( idInput.clear()
SCODOC_CHEF_ID.upper() idInput.send_keys(constructIdResponsable)
+ " " driver.find_element_by_id("tf_submit").click()
+ PRENOM_CHEF time.sleep(1)
+ " (" driver.get(URL_MATIERE)
+ SCODOC_CHEF_ID.lower() nomResponsable = driver.find_element_by_id("ens-responsable")
+ ")" self.assertTrue(SCODOC_CHEF_ID.lower() in nomResponsable.text.lower())
) global isAdmin
idInput = driver.find_element_by_name("responsable_id") isAdmin = False
idInput.clear() global isChef
idInput.send_keys(constructIdResponsable) isChef = True
driver.find_element_by_id("tf_submit").click()
time.sleep(1) # Test : Ajout d'un enseignant comme résponsable d'un module
driver.get(URL_MATIERE) # @expected : Le nom de l'enseignant apparait désormais sur la page d'information du module
nomResponsable = driver.find_element_by_id("ens-responsable") def test_031_ajout_enseignant_sur_module(self):
self.assertTrue(SCODOC_CHEF_ID.lower() in nomResponsable.text.lower()) driver = self.driver
global isAdmin global URL_MATIERE
isAdmin = False driver.get(URL_MATIERE)
global isChef time.sleep(2)
isChef = True driver.find_element_by_partial_link_text("modifier les enseignants").click()
time.sleep(1)
# Test : Ajout d'un enseignant comme résponsable d'un module constructIDEns = (
# @expected : Le nom de l'enseignant apparait désormais sur la page d'information du module SCODOC_ENS_ID.upper() + " " + PRENOM_ENS + " (" + SCODOC_ENS_ID + ")"
def test_031_ajout_enseignant_sur_module(self): )
driver = self.driver driver.find_element_by_id("ens_id").send_keys(constructIDEns)
global URL_MATIERE driver.find_element_by_id("tf_submit").click()
driver.get(URL_MATIERE) time.sleep(1)
time.sleep(2) driver.get(URL_MATIERE)
driver.find_element_by_partial_link_text("modifier les enseignants").click() professeurDansModule = driver.find_elements_by_class_name("ens-in-module")
time.sleep(1) time.sleep(5)
constructIDEns = ( professeurString = []
SCODOC_ENS_ID.upper() + " " + PRENOM_ENS + " (" + SCODOC_ENS_ID + ")" for professeur in professeurDansModule:
) professeurString.append(professeur.text)
driver.find_element_by_id("ens_id").send_keys(constructIDEns) for professeurS in professeurString:
driver.find_element_by_id("tf_submit").click() if SCODOC_ENS_ID.lower() in professeurS.lower():
time.sleep(1) isThere = True
driver.get(URL_MATIERE) self.assertTrue(isThere)
professeurDansModule = driver.find_elements_by_class_name("ens-in-module")
time.sleep(5) # Test : Création d'une interrogation en tant que chef des études
professeurString = [] # @eexpected : L'interrogation apparait désormais dans ce module
for professeur in professeurDansModule: def test_040_creation_interrogation(self):
professeurString.append(professeur.text) descriptionInterrogation = "Interrogation numero 2"
for professeurS in professeurString: driver = self.driver
if SCODOC_ENS_ID.lower() in professeurS.lower(): global URL_MATIERE
isThere = True driver.get(
self.assertTrue(isThere) SCHEMA
+ "://"
# Test : Création d'une interrogation en tant que chef des études + SCODOC_ADMIN_ID
# @eexpected : L'interrogation apparait désormais dans ce module + ":"
def test_040_creation_interrogation(self): + SCODOC_ADMIN_PASS
descriptionInterrogation = "Interrogation numero 2" + "@"
driver = self.driver + BASE_SSH_URL
global URL_MATIERE + "force_admin_authentication"
driver.get( )
"https://" # driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
+ SCODOC_ADMIN_ID # driver.find_element_by_link_text("déconnecter").click()
+ ":" # driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
+ SCODOC_ADMIN_PASS # driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID)
+ "@" # driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
+ BASE_NOT_SECURED_URL # driver.find_element_by_id("submit").click()
+ "force_admin_authentication" driver.get(URL_MATIERE)
) time.sleep(1)
# driver.get(BASE_URL) driver.find_element_by_link_text("Créer nouvelle évaluation").click()
# driver.find_element_by_link_text("déconnecter").click() time.sleep(1)
# driver.get(BASE_URL) driver.find_element_by_name("jour").clear()
# driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID) driver.find_element_by_name("jour").send_keys("31/05/2021")
# driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS) driver.find_element_by_id("tf_description").send_keys(descriptionInterrogation)
# driver.find_element_by_id("submit").click() driver.find_element_by_id("tf_coefficient").send_keys("2")
driver.get(URL_MATIERE) driver.find_element_by_id("tf_submit").click()
time.sleep(1) time.sleep(1)
driver.find_element_by_link_text("Créer nouvelle évaluation").click() global isChef
time.sleep(1) isChef = False
driver.find_element_by_name("jour").clear() global isEns
driver.find_element_by_name("jour").send_keys("31/05/2021") isEns = True
driver.find_element_by_id("tf_description").send_keys(descriptionInterrogation) self.assertTrue(descriptionInterrogation in driver.page_source)
driver.find_element_by_id("tf_coefficient").send_keys("2")
driver.find_element_by_id("tf_submit").click() # Test Vérifie si une interrogation existe sur un module
time.sleep(1) # @expected "Module" est présent dans le "formsemetre"
global isChef def test_050_interro_existante(self):
isChef = False driver = self.driver
global isEns global URL_MATIERE
isEns = True driver.get(URL_MATIERE)
self.assertTrue(descriptionInterrogation in driver.page_source) time.sleep(1)
self.assertTrue(
# Test Vérifie si une interrogation existe sur un module "Module" in driver.find_element_by_class_name("formsemestre").text
# @expected "Module" est présent dans le "formsemetre" )
def test_050_interro_existante(self):
driver = self.driver # Test Entree des notes pour le premier étudiant inscrit à un module
global URL_MATIERE # @expected : "saisir note" est remplacé par "afficher" sur la page d'information de l'interrogation concernée
driver.get(URL_MATIERE) def test_060_entree_note(self):
time.sleep(1) driver = self.driver
self.assertTrue( global URL_MATIERE
"Module" in driver.find_element_by_class_name("formsemestre").text driver.get(URL_MATIERE)
) driver.find_element_by_class_name("notes_img").click()
time.sleep(1)
# Test Entree des notes pour le premier étudiant inscrit à un module element = driver.find_element_by_class_name("note")
# @expected : "saisir note" est remplacé par "afficher" sur la page d'information de l'interrogation concernée element.send_keys("12")
def test_060_entree_note(self): driver.find_element_by_id("formnotes_submit").click()
driver = self.driver # self.wait.until(EC.url_changes(url))
global URL_MATIERE self.assertTrue(
driver.get(URL_MATIERE) driver.find_element_by_link_text("afficher").text in driver.page_source
driver.find_element_by_class_name("notes_img").click() )
time.sleep(1)
element = driver.find_element_by_class_name("note") # Test : Ajoute les notes manquante poru les étudiants concernés dans une interrogation
element.send_keys("12") # @expected : Tout les étudiants on une note
driver.find_element_by_id("formnotes_submit").click() def test_070_ajout_note_incomplete(self):
# self.wait.until(EC.url_changes(url)) driver = self.driver
self.assertTrue( global URL_MATIERE
driver.find_element_by_link_text("afficher").text in driver.page_source driver.get(URL_MATIERE)
) time.sleep(1)
driver.find_element_by_class_name("notes_img").click()
# Test : Ajoute les notes manquante poru les étudiants concernés dans une interrogation elements = driver.find_elements_by_class_name("note")
# @expected : Tout les étudiants on une note for element in elements:
def test_070_ajout_note_incomplete(self): if element.get_attribute("value") == "":
driver = self.driver element.send_keys(15)
global URL_MATIERE driver.find_element_by_id("formnotes_submit").click()
driver.get(URL_MATIERE) time.sleep(5)
time.sleep(1) element = driver.find_element_by_id("in-expnom")
driver.find_element_by_class_name("notes_img").click() element.send_keys("SEMESTRE47")
elements = driver.find_elements_by_class_name("note") element.submit()
for element in elements: time.sleep(5)
if element.get_attribute("value") == "": self.assertTrue("12" in driver.find_element_by_class_name("rcp_moy").text)
element.send_keys(15)
driver.find_element_by_id("formnotes_submit").click() # Test : Suppresion des notes pour tout les étudiants concernés dans une interrogation
time.sleep(5) # @expected : La moyenne ne s'affiche plus, "afficher" disparait de la page d'information de l'interrogation
element = driver.find_element_by_id("in-expnom") def test_080_suppression_note(self):
element.send_keys("SEMESTRE47") driver = self.driver
element.submit() global URL_MATIERE
time.sleep(5) driver.get(URL_MATIERE)
self.assertTrue("12" in driver.find_element_by_class_name("rcp_moy").text) time.sleep(1)
driver.find_element_by_class_name("notes_img").click()
# Test : Suppresion des notes pour tout les étudiants concernés dans une interrogation time.sleep(1)
# @expected : La moyenne ne s'affiche plus, "afficher" disparait de la page d'information de l'interrogation elements = driver.find_elements_by_class_name("note")
def test_080_suppression_note(self): for element in elements:
driver = self.driver element.clear()
global URL_MATIERE element.send_keys("SUPR")
driver.get(URL_MATIERE) driver.find_element_by_id("formnotes_submit").click()
time.sleep(1) time.sleep(1)
driver.find_element_by_class_name("notes_img").click() interro_non_Presente = False
time.sleep(1) try:
elements = driver.find_elements_by_class_name("note") driver.find_element_by_link_text("afficher")
for element in elements: interro_non_Presente = False
element.clear() except NoSuchElementException:
element.send_keys("SUPR") interro_non_Presente = True
driver.find_element_by_id("formnotes_submit").click() self.assertTrue(interro_non_Presente)
time.sleep(1) global isChef
interro_non_Presente = False isChef = True
try: global isEns
driver.find_element_by_link_text("afficher") isEns = False
interro_non_Presente = False
except NoSuchElementException: # Test : SUppression d'une interrogation par le chef des études
interro_non_Presente = True # @expected : L'interrogation n'apparait plus sur le module, les notes sont supprimées également
self.assertTrue(interro_non_Presente) def test_090_suppresion_interrogation(self):
global isChef global URL_MATIERE
isChef = True descriptionInterrogation = "Interrogation à supprimer"
global isEns driver = self.driver
isEns = False driver.get(URL_MATIERE)
time.sleep(1)
# Test : SUppression d'une interrogation par le chef des études driver.find_element_by_link_text("Créer nouvelle évaluation").click()
# @expected : L'interrogation n'apparait plus sur le module, les notes sont supprimées également time.sleep(1)
def test_090_suppresion_interrogation(self): driver.find_element_by_name("jour").clear()
global URL_MATIERE driver.find_element_by_name("jour").send_keys("30/05/2021")
descriptionInterrogation = "Interrogation à supprimer" driver.find_element_by_id("tf_description").send_keys(descriptionInterrogation)
driver = self.driver driver.find_element_by_id("tf_coefficient").send_keys("2")
driver.get(URL_MATIERE) driver.find_element_by_id("tf_submit").click()
time.sleep(1) time.sleep(1)
driver.find_element_by_link_text("Créer nouvelle évaluation").click() self.assertTrue(descriptionInterrogation in driver.page_source)
time.sleep(1) driver.find_element_by_class_name("delete_img").click()
driver.find_element_by_name("jour").clear() time.sleep(1)
driver.find_element_by_name("jour").send_keys("30/05/2021") driver.find_element_by_id("tf_submit").click()
driver.find_element_by_id("tf_description").send_keys(descriptionInterrogation) # global isAdmin
driver.find_element_by_id("tf_coefficient").send_keys("2") # isAdmin = True
driver.find_element_by_id("tf_submit").click() # global isEns
time.sleep(1) # isEns = False
self.assertTrue(descriptionInterrogation in driver.page_source) self.assertFalse(descriptionInterrogation in driver.page_source)
driver.find_element_by_class_name("delete_img").click()
time.sleep(1) # Test : Suppression d'un enseignant responsable d'un module
driver.find_element_by_id("tf_submit").click() # @expected : L'enseignant n'apparait plus comme responsable dans ce module
# global isAdmin def test_200_suppression_enseignant_sur_module(self):
# isAdmin = True driver = self.driver
# global isEns driver.get(URL_MATIERE)
# isEns = False time.sleep(1)
self.assertFalse(descriptionInterrogation in driver.page_source) driver.find_element_by_partial_link_text("modifier les enseignants").click()
time.sleep(1)
# Test : Suppression d'un enseignant responsable d'un module elements = driver.find_elements_by_link_text("supprimer")
# @expected : L'enseignant n'apparait plus comme responsable dans ce module for element in elements:
def test_200_suppression_enseignant_sur_module(self): element.click()
driver = self.driver time.sleep(1)
driver.get(URL_MATIERE) time.sleep(1)
time.sleep(1) driver.get(URL_MATIERE)
driver.find_element_by_partial_link_text("modifier les enseignants").click() time.sleep(5)
time.sleep(1) self.assertTrue(SCODOC_ENS_ID not in driver.page_source)
elements = driver.find_elements_by_link_text("supprimer")
for element in elements: # Test : Suppresion du reste des interrogations sans notes
element.click() # @expected Tout les interrogation sans notes sont supprimées
time.sleep(1) def test_910_suppresion_interrogation_restante(self):
time.sleep(1) driver = self.driver
driver.get(URL_MATIERE) driver.get(URL_MATIERE)
time.sleep(5) time.sleep(1)
self.assertTrue(SCODOC_ENS_ID not in driver.page_source) elements = driver.find_elements_by_xpath(
"//a[contains(@href,'evaluation_delete?')]"
# Test : Suppresion du reste des interrogations sans notes )
# @expected Tout les interrogation sans notes sont supprimées while elements:
def test_910_suppresion_interrogation_restante(self): elements[0].click()
driver = self.driver driver.find_element_by_id("tf_submit").click()
driver.get(URL_MATIERE) self.wait.until(EC.url_changes(URL))
time.sleep(1) driver.find_element_by_partial_link_text("Continuer").click()
elements = driver.find_elements_by_xpath( self.wait.until(EC.url_changes(URL))
"//a[contains(@href,'evaluation_delete?')]" elements = driver.find_elements_by_xpath(
) "//a[contains(@href,'evaluation_delete?')]"
while elements: )
elements[0].click()
driver.find_element_by_id("tf_submit").click() # ferme la fenetre et fais du clean up
self.wait.until(EC.url_changes(URL)) def tearDown(self):
driver.find_element_by_partial_link_text("Continuer").click() self.driver.close()
self.wait.until(EC.url_changes(URL))
elements = driver.find_elements_by_xpath(
"//a[contains(@href,'evaluation_delete?')]" if __name__ == "__main__":
) if NAVIGATEUR == "firefox":
driver = webdriver.Firefox()
# ferme la fenetre et fais du clean up else:
def tearDown(self): driver = webdriver.Chrome()
self.driver.close() deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
if __name__ == "__main__": cmdProcess = [
if NAVIGATEUR == "firefox": "./scriptExecution.sh",
driver = webdriver.Firefox() LINK_SCODOC_SERVER,
else: NOM_DPT,
driver = webdriver.Chrome() "test_scenario2_formation.py",
deleteDepartement.main() ]
createDepartement.main() process = subprocess.Popen(cmdProcess)
creationSiteDepartement.main() process.wait()
cmdProcess = [ time.sleep(5)
"./scriptExecution.sh", driver.get(
LINK_SCODOC_SERVER, SCHEMA
NOM_DPT, + "://"
"test_scenario2_formation.py", + SCODOC_ADMIN_ID
] + ":"
process = subprocess.Popen(cmdProcess) + SCODOC_ADMIN_PASS
process.wait() + "@"
time.sleep(5) + BASE_SSH_URL
driver.get( + "force_admin_authentication"
"https://" )
+ SCODOC_ADMIN_ID driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite")
+ ":" driver.find_element_by_id("link-view-users").click()
+ SCODOC_ADMIN_PASS time.sleep(5)
+ "@" noms = driver.find_elements_by_class_name("nom_fmt")
+ BASE_NOT_SECURED_URL chefCree = False
+ "force_admin_authentication" ensCree = False
) for nom in noms:
driver.get(BASE_URL + NOM_DPT + "/Scolarite") if nom.text.lower() == SCODOC_CHEF_ID.lower():
driver.find_element_by_id("link-view-users").click() chefCree = True
time.sleep(5) if nom.text.lower() == SCODOC_ENS_ID.lower():
noms = driver.find_elements_by_class_name("nom_fmt") ensCree = True
chefCree = False if not chefCree:
ensCree = False time.sleep(2)
for nom in noms: constructValue = "Ens" + NOM_DPT
if nom.text.lower() == SCODOC_CHEF_ID.lower(): driver.find_element_by_id("create-user").click()
chefCree = True driver.find_element_by_id("tf_nom").send_keys(SCODOC_CHEF_ID)
if nom.text.lower() == SCODOC_ENS_ID.lower(): driver.find_element_by_id("tf_user_name").send_keys(SCODOC_CHEF_ID)
ensCree = True driver.find_element_by_id("tf_prenom").send_keys("chef")
if not chefCree: driver.find_element_by_id("tf_passwd").send_keys(SCODOC_CHEF_PASS)
time.sleep(2) driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_CHEF_PASS)
constructValue = "Ens" + NOM_DPT driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click()
driver.find_element_by_id("create-user").click() driver.find_element_by_xpath("//input[@name='force:list']").click()
driver.find_element_by_id("tf_nom").send_keys(SCODOC_CHEF_ID) driver.find_element_by_id("tf_submit").click()
driver.find_element_by_id("tf_user_name").send_keys(SCODOC_CHEF_ID) driver.find_element_by_id("link-view-users").click()
driver.find_element_by_id("tf_prenom").send_keys("chef") if not ensCree:
driver.find_element_by_id("tf_passwd").send_keys(SCODOC_CHEF_PASS) time.sleep(2)
driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_CHEF_PASS) constructValue = "Ens" + NOM_DPT
driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click() driver.find_element_by_id("create-user").click()
driver.find_element_by_xpath("//input[@name='force:list']").click() driver.find_element_by_id("tf_nom").send_keys(SCODOC_ENS_ID)
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_user_name").send_keys(SCODOC_ENS_ID)
driver.find_element_by_id("link-view-users").click() driver.find_element_by_id("tf_prenom").send_keys(PRENOM_ENS)
if not ensCree: driver.find_element_by_id("tf_passwd").send_keys(SCODOC_ENS_PASS)
time.sleep(2) driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_ENS_PASS)
constructValue = "Ens" + NOM_DPT driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click()
driver.find_element_by_id("create-user").click() driver.find_element_by_xpath("//input[@name='force:list']").click()
driver.find_element_by_id("tf_nom").send_keys(SCODOC_ENS_ID) driver.find_element_by_id("tf_submit").click()
driver.find_element_by_id("tf_user_name").send_keys(SCODOC_ENS_ID) driver.find_element_by_id("link-view-users").click()
driver.find_element_by_id("tf_prenom").send_keys(PRENOM_ENS) driver.close()
driver.find_element_by_id("tf_passwd").send_keys(SCODOC_ENS_PASS) unittest.main(
driver.find_element_by_id("tf_passwd2").send_keys(SCODOC_ENS_PASS) testRunner=HtmlTestRunner.HTMLTestRunner(
driver.find_element_by_xpath("//input[@value='" + constructValue + "']").click() report_name="05_Saisie_note_tests",
driver.find_element_by_xpath("//input[@name='force:list']").click() output="./ResultatTest",
driver.find_element_by_id("tf_submit").click() combine_reports=True,
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,
)
)

View File

@ -1,454 +1,457 @@
import unittest import unittest
import time import time
import subprocess import subprocess
import urllib.parse as urlparse import urllib.parse as urlparse
import HtmlTestRunner import HtmlTestRunner
import createDepartement import createDepartement
import creationSiteDepartement import creationSiteDepartement
import deleteDepartement import deleteDepartement
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
BASE_NOT_SECURED_URL, SCODOC_SERVER,
LINK_SCODOC_SERVER, SCODOC_PORT,
NOM_DPT, BASE_SSH_URL,
SCODOC_ENS_ID, LINK_SCODOC_SERVER,
SCODOC_ENS_PASS, NOM_DPT,
SCODOC_CHEF_ID, SCODOC_ENS_ID,
SCODOC_CHEF_PASS, SCODOC_ENS_PASS,
NAVIGATEUR, SCODOC_CHEF_ID,
) SCODOC_CHEF_PASS,
from urllib.parse import parse_qs NAVIGATEUR,
from selenium import webdriver )
from selenium.webdriver.common.keys import Keys from urllib.parse import parse_qs
from selenium.common.exceptions import NoSuchElementException from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.select import Select from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
urlMatiere = "" from selenium.webdriver.support.select import Select
listeEtudiant = []
global MOY_UE1 urlMatiere = ""
global MOY_UE2 listeEtudiant = []
global URL_SEMESTRE global MOY_UE1
global COEFFUE1 global MOY_UE2
global COEFFUE2 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): class PythonOrgSearch(unittest.TestCase):
if NAVIGATEUR == "firefox": # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
self.driver = webdriver.Firefox() def setUp(self):
elif NAVIGATEUR == "chrome": if NAVIGATEUR == "firefox":
self.driver = webdriver.Chrome() self.driver = webdriver.Firefox()
self.url = BASE_URL + NOM_DPT + "/Scolarite" elif NAVIGATEUR == "chrome":
self.wait = WebDriverWait(self.driver, 10) self.driver = webdriver.Chrome()
self.driver.get( self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
"https://" self.wait = WebDriverWait(self.driver, 10)
+ SCODOC_ADMIN_ID self.driver.get(
+ ":" SCHEMA
+ SCODOC_ADMIN_PASS + "://"
+ "@" + SCODOC_ADMIN_ID
+ BASE_NOT_SECURED_URL + ":"
+ "force_admin_authentication" + SCODOC_ADMIN_PASS
) + "@"
+ BASE_SSH_URL
# 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 + "force_admin_authentication"
# @expected : La note rentrée et la moyenne sont identiques )
def test_010_ajout_note_multiple_pour_une_ue(self):
global listeEtudiant # 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
global MOY_UE1 # @expected : La note rentrée et la moyenne sont identiques
global URL_SEMESTRE def test_010_ajout_note_multiple_pour_une_ue(self):
driver = self.driver global listeEtudiant
url = self.url global MOY_UE1
driver.get(url) global URL_SEMESTRE
linkAddNote = "formnotes_note_" driver = self.driver
driver.find_element_by_link_text("semestre 1").click() url = self.url
self.wait.until(EC.url_changes(url)) driver.get(url)
URL_SEMESTRE = driver.current_url linkAddNote = "formnotes_note_"
ue_name = driver.find_elements_by_class_name("status_ue_acro")[0].text driver.find_element_by_link_text("semestre 1").click()
driver.find_element_by_link_text("M1101").click() self.wait.until(EC.url_changes(url))
self.wait.until(EC.url_changes(URL_SEMESTRE)) URL_SEMESTRE = driver.current_url
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click() ue_name = driver.find_elements_by_class_name("status_ue_acro")[0].text
self.wait.until(EC.url_changes(URL_SEMESTRE)) driver.find_element_by_link_text("M1101").click()
URL = driver.current_url self.wait.until(EC.url_changes(URL_SEMESTRE))
for champs in driver.find_elements_by_xpath( driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
"//input[contains(@id,'" + linkAddNote + "')]" self.wait.until(EC.url_changes(URL_SEMESTRE))
): URL = driver.current_url
champs.clear() for champs in driver.find_elements_by_xpath(
champs.send_keys(12) "//input[contains(@id,'" + linkAddNote + "')]"
idChamp = champs.get_attribute("id") ):
idEtud = idChamp[len(linkAddNote) : len(idChamp)] champs.clear()
if idEtud not in listeEtudiant: champs.send_keys(12)
listeEtudiant.append(idEtud) idChamp = champs.get_attribute("id")
driver.find_element_by_id("formnotes_submit").click() idEtud = idChamp[len(linkAddNote) : len(idChamp)]
self.wait.until(EC.url_changes(URL)) if idEtud not in listeEtudiant:
driver.get(URL_SEMESTRE) listeEtudiant.append(idEtud)
noteBonne = True driver.find_element_by_id("formnotes_submit").click()
# print(listeEtudiant) self.wait.until(EC.url_changes(URL))
for etudiant in listeEtudiant: driver.get(URL_SEMESTRE)
searchBar = driver.find_element_by_id("in-expnom") noteBonne = True
searchBar.send_keys(etudiant) # print(listeEtudiant)
searchBar.submit() for etudiant in listeEtudiant:
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text searchBar.send_keys(etudiant)
if "12" not in MOY_UE1: searchBar.submit()
noteBonne = False time.sleep(5)
self.assertTrue(noteBonne) MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
if "12" not in MOY_UE1:
# Test : Ajoute une note à la seconde UE pour les deux élèves noteBonne = False
# @expected : La moyenne de la seconde UE apparait et corresponds à la note rentrée self.assertTrue(noteBonne)
def test_020_ajout_note_seconde_ue(self):
global listeEtudiant # Test : Ajoute une note à la seconde UE pour les deux élèves
global MOY_UE2 # @expected : La moyenne de la seconde UE apparait et corresponds à la note rentrée
global URL_SEMESTRE def test_020_ajout_note_seconde_ue(self):
linkAddNote = "formnotes_note_" global listeEtudiant
driver = self.driver global MOY_UE2
url = self.url global URL_SEMESTRE
driver.get(URL_SEMESTRE) linkAddNote = "formnotes_note_"
ue_name = driver.find_elements_by_class_name("status_ue_acro")[1].text driver = self.driver
driver.find_element_by_link_text("M1201").click() url = self.url
self.wait.until(EC.url_changes(URL_SEMESTRE)) driver.get(URL_SEMESTRE)
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click() ue_name = driver.find_elements_by_class_name("status_ue_acro")[1].text
self.wait.until(EC.url_changes(URL_SEMESTRE)) driver.find_element_by_link_text("M1201").click()
URL = driver.current_url self.wait.until(EC.url_changes(URL_SEMESTRE))
for champs in driver.find_elements_by_xpath( driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
"//input[contains(@id,'" + linkAddNote + "')]" self.wait.until(EC.url_changes(URL_SEMESTRE))
): URL = driver.current_url
champs.clear() for champs in driver.find_elements_by_xpath(
champs.send_keys(8) "//input[contains(@id,'" + linkAddNote + "')]"
driver.find_element_by_id("formnotes_submit").click() ):
self.wait.until(EC.url_changes(URL)) champs.clear()
driver.get(URL_SEMESTRE) champs.send_keys(8)
noteBonne = True driver.find_element_by_id("formnotes_submit").click()
for etudiant in listeEtudiant: self.wait.until(EC.url_changes(URL))
URL = driver.current_url driver.get(URL_SEMESTRE)
searchBar = driver.find_element_by_id("in-expnom") noteBonne = True
searchBar.send_keys(etudiant) for etudiant in listeEtudiant:
searchBar.submit() URL = driver.current_url
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
MOY_UE2 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text searchBar.send_keys(etudiant)
if "8" not in MOY_UE2: searchBar.submit()
noteBonne = False time.sleep(5)
MOY_UE2 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
self.assertTrue(noteBonne) if "8" not in MOY_UE2:
noteBonne = False
# Test : Vérification calcul de la moyenne générale
# @expected La moyenne prends en compte les deux ue et leur coefficiant self.assertTrue(noteBonne)
def test_030_verification_moyenne_generale(self):
global COEFF_UE1 # Test : Vérification calcul de la moyenne générale
global COEFF_UE2 # @expected La moyenne prends en compte les deux ue et leur coefficiant
COEFF_UE1 = 2 def test_030_verification_moyenne_generale(self):
COEFF_UE2 = 2 global COEFF_UE1
driver = self.driver global COEFF_UE2
url = self.url COEFF_UE1 = 2
driver.get(url) COEFF_UE2 = 2
moyenneBonne = True driver = self.driver
for etudiant in listeEtudiant: url = self.url
searchBar = driver.find_element_by_id("in-expnom") driver.get(url)
searchBar.send_keys(etudiant) moyenneBonne = True
searchBar.submit() for etudiant in listeEtudiant:
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
if ( searchBar.send_keys(etudiant)
(float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2) searchBar.submit()
/ (COEFF_UE1 + COEFF_UE2) time.sleep(5)
) != float(driver.find_element_by_class_name("rcp_moy").text): if (
moyenneBonne = False (float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2)
self.assertTrue(moyenneBonne) / (COEFF_UE1 + COEFF_UE2)
) != float(driver.find_element_by_class_name("rcp_moy").text):
# Test : Changement du coefficiant d'un module et de ce fait, du coefficiant de l'UE moyenneBonne = False
# @expected : La moyenne générale se modifie en fonction de ce changement de coefficiant self.assertTrue(moyenneBonne)
def test_040_modification_coefficiant_module(self):
global COEFF_UE1 # Test : Changement du coefficiant d'un module et de ce fait, du coefficiant de l'UE
COEFF_UE1 = 3 # @expected : La moyenne générale se modifie en fonction de ce changement de coefficiant
driver = self.driver def test_040_modification_coefficiant_module(self):
url = self.url global COEFF_UE1
driver.get(url) COEFF_UE1 = 3
driver.find_element_by_id("link-programmes").click() driver = self.driver
driver.find_element_by_id("titre-dut-info").click() url = self.url
driver.find_element_by_xpath("//span[contains(text(),'M1101')]").click() driver.get(url)
driver.find_element_by_id("tf_coefficient").clear() driver.find_element_by_id("link-programmes").click()
driver.find_element_by_id("tf_coefficient").send_keys(COEFF_UE1) driver.find_element_by_id("titre-dut-info").click()
URL = driver.current_url driver.find_element_by_xpath("//span[contains(text(),'M1101')]").click()
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_coefficient").clear()
self.wait.until(EC.url_changes(URL)) driver.find_element_by_id("tf_coefficient").send_keys(COEFF_UE1)
moyenneBonne = True URL = driver.current_url
for etudiant in listeEtudiant: driver.find_element_by_id("tf_submit").click()
URL = driver.current_url self.wait.until(EC.url_changes(URL))
searchBar = driver.find_element_by_id("in-expnom") moyenneBonne = True
searchBar.send_keys(etudiant) for etudiant in listeEtudiant:
searchBar.submit() URL = driver.current_url
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
if ( searchBar.send_keys(etudiant)
(float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2) searchBar.submit()
/ (COEFF_UE1 + COEFF_UE2) time.sleep(5)
) != float(driver.find_element_by_class_name("rcp_moy").text): if (
moyenneBonne = False (float(MOY_UE1) * COEFF_UE1 + float(MOY_UE2) * COEFF_UE2)
self.assertTrue(moyenneBonne) / (COEFF_UE1 + COEFF_UE2)
) != float(driver.find_element_by_class_name("rcp_moy").text):
# Test : Ajout d'une note bonus pour un étudiant et d'une note malus pour un autre moyenneBonne = False
# @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 self.assertTrue(moyenneBonne)
def test_050_ajout_note_bonus(self):
moyenneBonusEtudiant1 = "0.25" # Test : Ajout d'une note bonus pour un étudiant et d'une note malus pour un autre
moyenneBonusEtudiant2 = "0.25" # @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
linkAddNote = "formnotes_note_" def test_050_ajout_note_bonus(self):
driver = self.driver moyenneBonusEtudiant1 = "0.25"
driver.get(URL_SEMESTRE) moyenneBonusEtudiant2 = "0.25"
driver.find_element_by_partial_link_text("malus").click() linkAddNote = "formnotes_note_"
driver.find_element_by_link_text("Créer nouvelle évaluation").click() driver = self.driver
time.sleep(1) driver.get(URL_SEMESTRE)
driver.find_element_by_name("jour").clear() driver.find_element_by_partial_link_text("malus").click()
driver.find_element_by_name("jour").send_keys("31/01/2021") driver.find_element_by_link_text("Créer nouvelle évaluation").click()
driver.find_element_by_id("tf_description").send_keys("une interrogation bonus") time.sleep(1)
driver.find_element_by_id("tf_submit").click() driver.find_element_by_name("jour").clear()
time.sleep(1) driver.find_element_by_name("jour").send_keys("31/01/2021")
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click() driver.find_element_by_id("tf_description").send_keys("une interrogation bonus")
self.wait.until(EC.url_changes(URL_SEMESTRE)) driver.find_element_by_id("tf_submit").click()
champsNote = driver.find_elements_by_xpath( time.sleep(1)
"//input[contains(@id,'" + linkAddNote + "')]" driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
) self.wait.until(EC.url_changes(URL_SEMESTRE))
champsNote[0].clear() champsNote = driver.find_elements_by_xpath(
champsNote[1].clear() "//input[contains(@id,'" + linkAddNote + "')]"
champsNote[0].send_keys("-" + moyenneBonusEtudiant1) )
champsNote[1].send_keys(moyenneBonusEtudiant2) champsNote[0].clear()
driver.find_element_by_id("formnotes_submit").click() champsNote[1].clear()
numeroEtu = 0 champsNote[0].send_keys("-" + moyenneBonusEtudiant1)
moyenneBonne = True champsNote[1].send_keys(moyenneBonusEtudiant2)
for etudiant in listeEtudiant: driver.find_element_by_id("formnotes_submit").click()
URL = driver.current_url numeroEtu = 0
searchBar = driver.find_element_by_id("in-expnom") moyenneBonne = True
searchBar.send_keys(etudiant) for etudiant in listeEtudiant:
searchBar.submit() URL = driver.current_url
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
if numeroEtu == 0: searchBar.send_keys(etudiant)
if ( searchBar.submit()
( time.sleep(5)
float(MOY_UE1) * COEFF_UE1 if numeroEtu == 0:
+ (float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2 if (
) (
/ (COEFF_UE1 + COEFF_UE2) float(MOY_UE1) * COEFF_UE1
) != float(driver.find_element_by_class_name("rcp_moy").text): + (float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2
moyenneBonne = False )
elif numeroEtu == 1: / (COEFF_UE1 + COEFF_UE2)
if ( ) != float(driver.find_element_by_class_name("rcp_moy").text):
( moyenneBonne = False
float(MOY_UE1) * COEFF_UE1 elif numeroEtu == 1:
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2 if (
) (
/ (COEFF_UE1 + COEFF_UE2) float(MOY_UE1) * COEFF_UE1
) != float(driver.find_element_by_class_name("rcp_moy").text): + (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
moyenneBonne = False )
numeroEtu = numeroEtu + 1 / (COEFF_UE1 + COEFF_UE2)
self.assertTrue(moyenneBonne) ) != float(driver.find_element_by_class_name("rcp_moy").text):
moyenneBonne = False
# Test : Ajout d'une note en attente pour un étudiant, et d'une note entrée pour un autre sur une même évaluation numeroEtu = numeroEtu + 1
# @expected : self.assertTrue(moyenneBonne)
def test_060_note_attente(self):
moyenneBonusEtudiant1 = "0.25" # Test : Ajout d'une note en attente pour un étudiant, et d'une note entrée pour un autre sur une même évaluation
moyenneBonusEtudiant2 = "0.25" # @expected :
linkAddNote = "formnotes_note_" def test_060_note_attente(self):
champsNote = [] moyenneBonusEtudiant1 = "0.25"
driver = self.driver moyenneBonusEtudiant2 = "0.25"
driver.get(URL_SEMESTRE) linkAddNote = "formnotes_note_"
driver.find_element_by_link_text("M1101").click() champsNote = []
self.wait.until(EC.url_changes(URL_SEMESTRE)) driver = self.driver
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click() driver.get(URL_SEMESTRE)
URL = driver.current_url driver.find_element_by_link_text("M1101").click()
champsNote = driver.find_elements_by_xpath( self.wait.until(EC.url_changes(URL_SEMESTRE))
"//input[contains(@id,'" + linkAddNote + "')]" driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
) URL = driver.current_url
champsNote[0].clear() champsNote = driver.find_elements_by_xpath(
champsNote[0].send_keys("ATT") "//input[contains(@id,'" + linkAddNote + "')]"
driver.find_element_by_id("formnotes_submit").click() )
self.wait.until(EC.url_changes(URL)) champsNote[0].clear()
numeroEtu = 0 champsNote[0].send_keys("ATT")
moyenneBonne = True driver.find_element_by_id("formnotes_submit").click()
affichageMoyenne = True self.wait.until(EC.url_changes(URL))
for etudiant in listeEtudiant: numeroEtu = 0
URL = driver.current_url moyenneBonne = True
searchBar = driver.find_element_by_id("in-expnom") affichageMoyenne = True
searchBar.send_keys(etudiant) for etudiant in listeEtudiant:
searchBar.submit() URL = driver.current_url
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
ueListElement = driver.find_elements_by_class_name("ue_acro") searchBar.send_keys(etudiant)
ueListText = [] searchBar.submit()
for ueElement in ueListElement: time.sleep(5)
ueListText.append(ueElement.text) ueListElement = driver.find_elements_by_class_name("ue_acro")
if numeroEtu == 0: ueListText = []
moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1) for ueElement in ueListElement:
if moyEtudiant1 != float( ueListText.append(ueElement.text)
driver.find_element_by_class_name("rcp_moy").text if numeroEtu == 0:
): moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1)
moyenneBonne = False if moyEtudiant1 != float(
if "UE11" in ueListText: driver.find_element_by_class_name("rcp_moy").text
affichageMoyenne = False ):
elif numeroEtu == 1: moyenneBonne = False
moyEtudiant2 = ( if "UE11" in ueListText:
float(MOY_UE1) * COEFF_UE1 affichageMoyenne = False
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2 elif numeroEtu == 1:
) / (COEFF_UE1 + COEFF_UE2) moyEtudiant2 = (
if moyEtudiant2 != float( float(MOY_UE1) * COEFF_UE1
driver.find_element_by_class_name("rcp_moy").text + (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
): ) / (COEFF_UE1 + COEFF_UE2)
moyenneBonne = False if moyEtudiant2 != float(
if "UE11" not in ueListText: driver.find_element_by_class_name("rcp_moy").text
affichageMoyenne = False ):
numeroEtu = numeroEtu + 1 moyenneBonne = False
self.assertTrue(moyenneBonne and affichageMoyenne) if "UE11" not in ueListText:
affichageMoyenne = False
def test_070_note_absent(self): numeroEtu = numeroEtu + 1
ue_name = "UE11" self.assertTrue(moyenneBonne and affichageMoyenne)
moyenneBonusEtudiant1 = "0.25"
moyenneBonusEtudiant2 = "0.25" def test_070_note_absent(self):
linkAddNote = "formnotes_note_" ue_name = "UE11"
MOY_UE1_EXC = 0 moyenneBonusEtudiant1 = "0.25"
champsNote = [] moyenneBonusEtudiant2 = "0.25"
driver = self.driver linkAddNote = "formnotes_note_"
driver.get(URL_SEMESTRE) MOY_UE1_EXC = 0
driver.find_element_by_link_text("M1101").click() champsNote = []
self.wait.until(EC.url_changes(URL_SEMESTRE)) driver = self.driver
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click() driver.get(URL_SEMESTRE)
URL = driver.current_url driver.find_element_by_link_text("M1101").click()
champsNote = driver.find_elements_by_xpath( self.wait.until(EC.url_changes(URL_SEMESTRE))
"//input[contains(@id,'" + linkAddNote + "')]" driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
) URL = driver.current_url
champsNote[0].clear() champsNote = driver.find_elements_by_xpath(
champsNote[0].send_keys("ABS") "//input[contains(@id,'" + linkAddNote + "')]"
driver.find_element_by_id("formnotes_submit").click() )
self.wait.until(EC.url_changes(URL)) champsNote[0].clear()
numeroEtu = 0 champsNote[0].send_keys("ABS")
moyenneBonne = True driver.find_element_by_id("formnotes_submit").click()
affichageMoyenne = True self.wait.until(EC.url_changes(URL))
noteExcuseeEgaleAZero = True numeroEtu = 0
ueList = [] moyenneBonne = True
for etudiant in listeEtudiant: affichageMoyenne = True
URL = driver.current_url noteExcuseeEgaleAZero = True
searchBar = driver.find_element_by_id("in-expnom") ueList = []
searchBar.send_keys(etudiant) for etudiant in listeEtudiant:
searchBar.submit() URL = driver.current_url
self.wait.until(EC.url_changes(URL)) searchBar = driver.find_element_by_id("in-expnom")
ueListElement = driver.find_elements_by_class_name("ue_acro") searchBar.send_keys(etudiant)
ueListText = [] searchBar.submit()
for ueElement in ueListElement: self.wait.until(EC.url_changes(URL))
ueListText.append(ueElement.text) ueListElement = driver.find_elements_by_class_name("ue_acro")
if numeroEtu == 0: ueListText = []
moyEtudiant1 = ( for ueElement in ueListElement:
float(MOY_UE1_EXC) * COEFF_UE1 ueListText.append(ueElement.text)
+ ((float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2) if numeroEtu == 0:
) / (COEFF_UE1 + COEFF_UE2) moyEtudiant1 = (
# print(format(moyEtudiant1, "2.2f")) float(MOY_UE1_EXC) * COEFF_UE1
# print( + ((float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2)
# format( ) / (COEFF_UE1 + COEFF_UE2)
# float(driver.find_element_by_class_name("rcp_moy").text), "2.2f" # print(format(moyEtudiant1, "2.2f"))
# ) # print(
# ) # format(
if format(moyEtudiant1, "2.2f") != format( # float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
float(driver.find_element_by_class_name("rcp_moy").text), "2.2f" # )
): # )
moyenneBonne = False if format(moyEtudiant1, "2.2f") != format(
if ue_name not in ueListText: float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
affichageMoyenne = False ):
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text moyenneBonne = False
if float(0) != float(MOY_UE1): if ue_name not in ueListText:
noteExcuseeEgaleAZero = False affichageMoyenne = False
elif numeroEtu == 1: MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text if float(0) != float(MOY_UE1):
moyEtudiant2 = ( noteExcuseeEgaleAZero = False
float(MOY_UE1) * COEFF_UE1 elif numeroEtu == 1:
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2 MOY_UE1 = driver.find_element_by_id("ue-" + ue_name.lower().replace(" ","-")).text
) / (COEFF_UE1 + COEFF_UE2) moyEtudiant2 = (
if moyEtudiant2 != float( float(MOY_UE1) * COEFF_UE1
driver.find_element_by_class_name("rcp_moy").text + (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
): ) / (COEFF_UE1 + COEFF_UE2)
moyenneBonne = False if moyEtudiant2 != float(
if "UE11" not in ueListText: driver.find_element_by_class_name("rcp_moy").text
affichageMoyenne = False ):
numeroEtu = numeroEtu + 1 moyenneBonne = False
self.assertTrue(moyenneBonne and affichageMoyenne and noteExcuseeEgaleAZero) if "UE11" not in ueListText:
affichageMoyenne = False
def test_080_note_excuse(self): numeroEtu = numeroEtu + 1
moyenneBonusEtudiant1 = "0.25" self.assertTrue(moyenneBonne and affichageMoyenne and noteExcuseeEgaleAZero)
moyenneBonusEtudiant2 = "0.25"
linkAddNote = "formnotes_note_" def test_080_note_excuse(self):
champsNote = [] moyenneBonusEtudiant1 = "0.25"
driver = self.driver moyenneBonusEtudiant2 = "0.25"
driver.get(URL_SEMESTRE) linkAddNote = "formnotes_note_"
driver.find_element_by_link_text("M1101").click() champsNote = []
self.wait.until(EC.url_changes(URL_SEMESTRE)) driver = self.driver
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click() driver.get(URL_SEMESTRE)
URL = driver.current_url driver.find_element_by_link_text("M1101").click()
champsNote = driver.find_elements_by_xpath( self.wait.until(EC.url_changes(URL_SEMESTRE))
"//input[contains(@id,'" + linkAddNote + "')]" driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
) URL = driver.current_url
champsNote[0].clear() champsNote = driver.find_elements_by_xpath(
champsNote[0].send_keys("EXC") "//input[contains(@id,'" + linkAddNote + "')]"
driver.find_element_by_id("formnotes_submit").click() )
self.wait.until(EC.url_changes(URL)) champsNote[0].clear()
numeroEtu = 0 champsNote[0].send_keys("EXC")
moyenneBonne = True driver.find_element_by_id("formnotes_submit").click()
affichageMoyenne = True self.wait.until(EC.url_changes(URL))
ueList = [] numeroEtu = 0
for etudiant in listeEtudiant: moyenneBonne = True
URL = driver.current_url affichageMoyenne = True
searchBar = driver.find_element_by_id("in-expnom") ueList = []
searchBar.send_keys(etudiant) for etudiant in listeEtudiant:
searchBar.submit() URL = driver.current_url
self.wait.until(EC.url_changes(URL)) searchBar = driver.find_element_by_id("in-expnom")
ueListElement = driver.find_elements_by_class_name("ue_acro") searchBar.send_keys(etudiant)
ueListText = [] searchBar.submit()
for ueElement in ueListElement: self.wait.until(EC.url_changes(URL))
ueListText.append(ueElement.text) ueListElement = driver.find_elements_by_class_name("ue_acro")
if numeroEtu == 0: ueListText = []
moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1) for ueElement in ueListElement:
if moyEtudiant1 != float( ueListText.append(ueElement.text)
driver.find_element_by_class_name("rcp_moy").text if numeroEtu == 0:
): moyEtudiant1 = float(MOY_UE2) + float(moyenneBonusEtudiant1)
moyenneBonne = False if moyEtudiant1 != float(
if "UE11" in ueListText: driver.find_element_by_class_name("rcp_moy").text
affichageMoyenne = False ):
elif numeroEtu == 1: moyenneBonne = False
moyEtudiant2 = ( if "UE11" in ueListText:
float(MOY_UE1) * COEFF_UE1 affichageMoyenne = False
+ (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2 elif numeroEtu == 1:
) / (COEFF_UE1 + COEFF_UE2) moyEtudiant2 = (
if moyEtudiant2 != float( float(MOY_UE1) * COEFF_UE1
driver.find_element_by_class_name("rcp_moy").text + (float(MOY_UE2) - float(moyenneBonusEtudiant2)) * COEFF_UE2
): ) / (COEFF_UE1 + COEFF_UE2)
moyenneBonne = False if moyEtudiant2 != float(
if "UE11" not in ueListText: driver.find_element_by_class_name("rcp_moy").text
affichageMoyenne = False ):
numeroEtu = numeroEtu + 1 moyenneBonne = False
self.assertTrue(moyenneBonne and affichageMoyenne) if "UE11" not in ueListText:
affichageMoyenne = False
# TOdo numeroEtu = numeroEtu + 1
def test_090_note_bonus(self): self.assertTrue(moyenneBonne and affichageMoyenne)
global listeEtudiant
global COEFF_UE1 # TOdo
global COEFF_UE2 def test_090_note_bonus(self):
global URL_SEMESTRE global listeEtudiant
global COEFF_UE1
def tearDown(self): global COEFF_UE2
self.driver.close() global URL_SEMESTRE
def tearDown(self):
if __name__ == "__main__": self.driver.close()
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main() if __name__ == "__main__":
cmdProcess = [ deleteDepartement.main()
"./scriptExecution.sh", createDepartement.main()
LINK_SCODOC_SERVER, creationSiteDepartement.main()
NOM_DPT, cmdProcess = [
"test_scenario3_formation.py", "./scriptExecution.sh",
] LINK_SCODOC_SERVER,
process = subprocess.Popen(cmdProcess) NOM_DPT,
process.wait() "test_scenario3_formation.py",
unittest.main( ]
testRunner=HtmlTestRunner.HTMLTestRunner( process = subprocess.Popen(cmdProcess)
report_name="06_Moyenne_tests", process.wait()
output="./ResultatTest", unittest.main(
combine_reports=True, testRunner=HtmlTestRunner.HTMLTestRunner(
) report_name="06_Moyenne_tests",
) output="./ResultatTest",
combine_reports=True,
)
)

View File

@ -1,242 +1,245 @@
import unittest import unittest
import time import time
import subprocess import subprocess
import urllib.parse as urlparse import urllib.parse as urlparse
import HtmlTestRunner import HtmlTestRunner
import createDepartement import createDepartement
import creationSiteDepartement import creationSiteDepartement
import deleteDepartement import deleteDepartement
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
BASE_NOT_SECURED_URL, SCODOC_SERVER,
LINK_SCODOC_SERVER, SCODOC_PORT,
NOM_DPT, BASE_SSH_URL,
SCODOC_ENS_ID, LINK_SCODOC_SERVER,
SCODOC_ENS_PASS, NOM_DPT,
SCODOC_CHEF_ID, SCODOC_ENS_ID,
SCODOC_CHEF_PASS, SCODOC_ENS_PASS,
NAVIGATEUR, SCODOC_CHEF_ID,
) SCODOC_CHEF_PASS,
from urllib.parse import parse_qs NAVIGATEUR,
from selenium import webdriver )
from selenium.webdriver.common.keys import Keys from urllib.parse import parse_qs
from selenium.common.exceptions import NoSuchElementException from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.select import Select 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 = ""
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): class PythonOrgSearch(unittest.TestCase):
if NAVIGATEUR == "firefox": # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
self.driver = webdriver.Firefox() def setUp(self):
elif NAVIGATEUR == "chrome": if NAVIGATEUR == "firefox":
self.driver = webdriver.Chrome() self.driver = webdriver.Firefox()
self.url = BASE_URL + NOM_DPT + "/Scolarite" elif NAVIGATEUR == "chrome":
self.wait = WebDriverWait(self.driver, 10) self.driver = webdriver.Chrome()
self.driver.get( self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
"https://" self.wait = WebDriverWait(self.driver, 10)
+ SCODOC_ADMIN_ID self.driver.get(
+ ":" SCHEMA
+ SCODOC_ADMIN_PASS + "://"
+ "@" + SCODOC_ADMIN_ID
+ BASE_NOT_SECURED_URL + ":"
+ "force_admin_authentication" + SCODOC_ADMIN_PASS
) + "@"
+ BASE_SSH_URL
def test_010_etudiantS1_assidu_avec_moy_admis(self): + "force_admin_authentication"
driver = self.driver )
url = self.url
driver.get(url) def test_010_etudiantS1_assidu_avec_moy_admis(self):
searchBar = driver.find_element_by_id("in-expnom") driver = self.driver
searchBar.send_keys("EID1") url = self.url
searchBar.submit() driver.get(url)
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
URL_ETUDIANT = driver.current_url searchBar.send_keys("EID1")
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() searchBar.submit()
driver.find_element_by_xpath( time.sleep(5)
"//a[contains(@href,'formsemestre_validation_etud_form?')]" URL_ETUDIANT = driver.current_url
).click() driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
self.wait.until(EC.url_changes(URL_ETUDIANT)) driver.find_element_by_xpath(
URL_DECISION = driver.current_url "//a[contains(@href,'formsemestre_validation_etud_form?')]"
driver.find_element_by_id("input-choice-10").click() ).click()
driver.find_element_by_id("subut").click() self.wait.until(EC.url_changes(URL_ETUDIANT))
time.sleep(1) URL_DECISION = driver.current_url
driver.get(URL_ETUDIANT) driver.find_element_by_id("input-choice-10").click()
self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text) driver.find_element_by_id("subut").click()
time.sleep(1)
def test_020_etudiantS1_non_assidu_avec_moy_semestre_non_valide(self): driver.get(URL_ETUDIANT)
driver = self.driver self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text)
url = self.url
driver.get(url) def test_020_etudiantS1_non_assidu_avec_moy_semestre_non_valide(self):
searchBar = driver.find_element_by_id("in-expnom") driver = self.driver
searchBar.send_keys("EID1") url = self.url
searchBar.submit() driver.get(url)
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
URL_ETUDIANT = driver.current_url searchBar.send_keys("EID1")
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() searchBar.submit()
driver.find_element_by_xpath( time.sleep(5)
"//a[contains(@href,'formsemestre_validation_etud_form?')]" URL_ETUDIANT = driver.current_url
).click() driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
self.wait.until(EC.url_changes(URL_ETUDIANT)) driver.find_element_by_xpath(
URL_DECISION = driver.current_url "//a[contains(@href,'formsemestre_validation_etud_form?')]"
driver.find_element_by_id("input-choice-40").click() ).click()
driver.find_element_by_id("subut").click() self.wait.until(EC.url_changes(URL_ETUDIANT))
driver.get(URL_ETUDIANT) URL_DECISION = driver.current_url
self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text) driver.find_element_by_id("input-choice-40").click()
driver.find_element_by_id("subut").click()
def test_030_etudiantS1_assidu_sous_la_moy_semestre_valide(self): driver.get(URL_ETUDIANT)
driver = self.driver self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text)
url = self.url
driver.get(url) def test_030_etudiantS1_assidu_sous_la_moy_semestre_valide(self):
searchBar = driver.find_element_by_id("in-expnom") driver = self.driver
searchBar.send_keys("EID4") url = self.url
searchBar.submit() driver.get(url)
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
URL_ETUDIANT = driver.current_url searchBar.send_keys("EID4")
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() searchBar.submit()
driver.find_element_by_xpath( time.sleep(5)
"//a[contains(@href,'formsemestre_validation_etud_form?')]" URL_ETUDIANT = driver.current_url
).click() driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
self.wait.until(EC.url_changes(URL_ETUDIANT)) driver.find_element_by_xpath(
URL_DECISION = driver.current_url "//a[contains(@href,'formsemestre_validation_etud_form?')]"
driver.find_element_by_id("input-choice-30").click() ).click()
driver.find_element_by_id("subut").click() self.wait.until(EC.url_changes(URL_ETUDIANT))
driver.get(URL_ETUDIANT) URL_DECISION = driver.current_url
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text) driver.find_element_by_id("input-choice-30").click()
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() driver.find_element_by_id("subut").click()
driver.find_element_by_xpath( driver.get(URL_ETUDIANT)
"//a[contains(@href,'formsemestre_validation_etud_form?')]" self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
).click() driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
self.wait.until(EC.url_changes(URL_ETUDIANT)) driver.find_element_by_xpath(
URL_DECISION = driver.current_url "//a[contains(@href,'formsemestre_validation_etud_form?')]"
driver.find_element_by_id("input-choice-580").click() ).click()
driver.find_element_by_id("subut").click() self.wait.until(EC.url_changes(URL_ETUDIANT))
driver.get(URL_ETUDIANT) URL_DECISION = driver.current_url
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text) driver.find_element_by_id("input-choice-580").click()
driver.find_element_by_id("subut").click()
def test_040_etudiantS1_non_assidu_sous_la_moy_semestre_valide(self): driver.get(URL_ETUDIANT)
driver = self.driver self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
url = self.url
driver.get(url) def test_040_etudiantS1_non_assidu_sous_la_moy_semestre_valide(self):
searchBar = driver.find_element_by_id("in-expnom") driver = self.driver
searchBar.send_keys("EID4") url = self.url
searchBar.submit() driver.get(url)
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
URL_ETUDIANT = driver.current_url searchBar.send_keys("EID4")
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() searchBar.submit()
driver.find_element_by_xpath( time.sleep(5)
"//a[contains(@href,'formsemestre_validation_etud_form?')]" URL_ETUDIANT = driver.current_url
).click() driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
self.wait.until(EC.url_changes(URL_ETUDIANT)) driver.find_element_by_xpath(
URL_DECISION = driver.current_url "//a[contains(@href,'formsemestre_validation_etud_form?')]"
driver.find_element_by_id("input-choice-40").click() ).click()
driver.find_element_by_id("subut").click() self.wait.until(EC.url_changes(URL_ETUDIANT))
driver.get(URL_ETUDIANT) URL_DECISION = driver.current_url
self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text) driver.find_element_by_id("input-choice-40").click()
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() driver.find_element_by_id("subut").click()
driver.find_element_by_xpath( driver.get(URL_ETUDIANT)
"//a[contains(@href,'formsemestre_validation_etud_form?')]" self.assertTrue("ATJ" in driver.find_element_by_class_name("rcp_dec").text)
).click() driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
self.wait.until(EC.url_changes(URL_ETUDIANT)) driver.find_element_by_xpath(
URL_DECISION = driver.current_url "//a[contains(@href,'formsemestre_validation_etud_form?')]"
driver.find_element_by_id("input-choice-580").click() ).click()
driver.find_element_by_id("subut").click() self.wait.until(EC.url_changes(URL_ETUDIANT))
driver.get(URL_ETUDIANT) URL_DECISION = driver.current_url
self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text) driver.find_element_by_id("input-choice-580").click()
driver.find_element_by_id("subut").click()
def test_050_calcul_automatiqueS2_jury(self): driver.get(URL_ETUDIANT)
driver = self.driver self.assertTrue("ATB" in driver.find_element_by_class_name("rcp_dec").text)
url = self.url
driver.get(url) def test_050_calcul_automatiqueS2_jury(self):
driver.find_element_by_link_text("semestre 2").click() driver = self.driver
self.wait.until(EC.url_changes(url)) url = self.url
urlTmp = driver.current_url driver.get(url)
driver.find_element_by_xpath("//a[contains(text(),'Jury')]").click() driver.find_element_by_link_text("semestre 2").click()
driver.find_element_by_link_text("Saisie des décisions du jury").click() self.wait.until(EC.url_changes(url))
self.wait.until(EC.url_changes(urlTmp)) urlTmp = driver.current_url
urlTmp = driver.current_url driver.find_element_by_xpath("//a[contains(text(),'Jury')]").click()
driver.find_element_by_partial_link_text("Calcul automatique").click() driver.find_element_by_link_text("Saisie des décisions du jury").click()
self.wait.until(EC.url_changes(urlTmp)) self.wait.until(EC.url_changes(urlTmp))
urlTmp = driver.current_url urlTmp = driver.current_url
driver.find_element_by_xpath("//input[@type='submit']").click() driver.find_element_by_partial_link_text("Calcul automatique").click()
self.wait.until(EC.url_changes(urlTmp)) self.wait.until(EC.url_changes(urlTmp))
searchBar = driver.find_element_by_id("in-expnom") urlTmp = driver.current_url
searchBar.send_keys("EID7") driver.find_element_by_xpath("//input[@type='submit']").click()
searchBar.submit() self.wait.until(EC.url_changes(urlTmp))
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text) searchBar.send_keys("EID7")
searchBar = driver.find_element_by_id("in-expnom") searchBar.submit()
searchBar.send_keys("EID10") time.sleep(5)
searchBar.submit() self.assertTrue("ADM" in driver.find_element_by_class_name("rcp_dec").text)
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
self.assertTrue("en cours" in driver.page_source) searchBar.send_keys("EID10")
searchBar.submit()
def test_060_declarer_defaillance(self): time.sleep(5)
driver = self.driver self.assertTrue("en cours" in driver.page_source)
url = self.url
driver.get(url) def test_060_declarer_defaillance(self):
searchBar = driver.find_element_by_id("in-expnom") driver = self.driver
searchBar.send_keys("EID10") url = self.url
searchBar.submit() driver.get(url)
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
URL_ETUDIANT = driver.current_url searchBar.send_keys("EID10")
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() searchBar.submit()
driver.find_element_by_xpath("//a[contains(@href,'formDef?')]").click() time.sleep(5)
self.wait.until(EC.url_changes(URL_ETUDIANT)) URL_ETUDIANT = driver.current_url
input = driver.find_element_by_name("event_date") driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
input.clear() driver.find_element_by_xpath("//a[contains(@href,'formDef?')]").click()
input.send_keys("11/06/2021") self.wait.until(EC.url_changes(URL_ETUDIANT))
driver.find_element_by_xpath("//input[@type='submit']").click() input = driver.find_element_by_name("event_date")
driver.get(URL_ETUDIANT) input.clear()
self.assertTrue("Défaillant" in driver.page_source) input.send_keys("11/06/2021")
driver.find_element_by_xpath("//input[@type='submit']").click()
def test_070_declarer_demission(self): driver.get(URL_ETUDIANT)
driver = self.driver self.assertTrue("Défaillant" in driver.page_source)
url = self.url
driver.get(url) def test_070_declarer_demission(self):
searchBar = driver.find_element_by_id("in-expnom") driver = self.driver
searchBar.send_keys("EID10") url = self.url
searchBar.submit() driver.get(url)
time.sleep(5) searchBar = driver.find_element_by_id("in-expnom")
URL_ETUDIANT = driver.current_url searchBar.send_keys("EID10")
driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click() searchBar.submit()
driver.find_element_by_xpath("//a[contains(@href,'formDem?')]").click() time.sleep(5)
self.wait.until(EC.url_changes(URL_ETUDIANT)) URL_ETUDIANT = driver.current_url
input = driver.find_element_by_name("event_date") driver.find_element_by_xpath("//a[contains(text(),'Scolarité')]").click()
input.clear() driver.find_element_by_xpath("//a[contains(@href,'formDem?')]").click()
input.send_keys("11/06/2021") self.wait.until(EC.url_changes(URL_ETUDIANT))
driver.find_element_by_xpath("//input[@type='submit']").click() input = driver.find_element_by_name("event_date")
driver.get(URL_ETUDIANT) input.clear()
self.assertTrue("Démission le " in driver.page_source) input.send_keys("11/06/2021")
driver.find_element_by_xpath("//input[@type='submit']").click()
def tearDown(self): driver.get(URL_ETUDIANT)
self.driver.close() self.assertTrue("Démission le " in driver.page_source)
def tearDown(self):
if __name__ == "__main__": self.driver.close()
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main() if __name__ == "__main__":
cmdProcess = [ deleteDepartement.main()
"./scriptExecution.sh", createDepartement.main()
LINK_SCODOC_SERVER, creationSiteDepartement.main()
NOM_DPT, cmdProcess = [
"test_scenario4_formation.py", "./scriptExecution.sh",
] LINK_SCODOC_SERVER,
process = subprocess.Popen(cmdProcess) NOM_DPT,
process.wait() "test_scenario4_formation.py",
unittest.main( ]
testRunner=HtmlTestRunner.HTMLTestRunner( process = subprocess.Popen(cmdProcess)
report_name="07_Admission_et_passages_tests", process.wait()
output="./ResultatTest", unittest.main(
combine_reports=True, testRunner=HtmlTestRunner.HTMLTestRunner(
) report_name="07_Admission_et_passages_tests",
) output="./ResultatTest",
combine_reports=True,
)
)

Binary file not shown.

Binary file not shown.

View File

@ -1,53 +1,55 @@
# coding: utf8 # coding: utf8
import unittest import unittest
import time import time
import subprocess import subprocess
import HtmlTestRunner import HtmlTestRunner
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
BASE_URL, SCHEMA,
NOM_DPT, SCODOC_SERVER,
LINK_SCODOC_SERVER, SCODOC_PORT,
BASE_NOT_SECURED_URL, NOM_DPT,
NAVIGATEUR, LINK_SCODOC_SERVER,
) BASE_SSH_URL,
from selenium import webdriver NAVIGATEUR,
from selenium.webdriver.support import expected_conditions as EC )
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.select import Select from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
URL = BASE_URL + NOM_DPT + "/Scolarite" from selenium.webdriver.support.select import Select
ACRONYME_FORMATION = "FormationTEST" URL_ROOT = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT
URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
URL_SCODOC8 = "/".join((URL_ROOT, "index"))
def main(): URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
if NAVIGATEUR == "firefox": URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
driver = webdriver.Firefox() URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
else:
driver = webdriver.Chrome() ACRONYME_FORMATION = "FormationTEST"
driver.get(
"https://" def main():
+ SCODOC_ADMIN_ID next_page = URL_HOME
+ ":" if NAVIGATEUR == "firefox":
+ SCODOC_ADMIN_PASS driver = webdriver.Firefox()
+ "@" else:
+ BASE_NOT_SECURED_URL driver = webdriver.Chrome()
+ "force_admin_authentication" auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
) driver.get(auth_page)
driver.get(BASE_URL + "scodoc_admin") driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
time.sleep(2) driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
try: driver.find_element_by_id("submit").click()
select = Select(driver.find_element_by_id("create-dept")) time.sleep(2)
select.select_by_visible_text(NOM_DPT) try:
driver.find_element_by_id("create-dept").submit() select = Select(driver.find_element_by_id("create-dept"))
time.sleep(1) select.select_by_visible_text(NOM_DPT)
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("create-dept").submit()
time.sleep(1) time.sleep(1)
driver.close() driver.find_element_by_id("tf_submit").click()
except NoSuchElementException: time.sleep(1)
driver.close()
except NoSuchElementException:
driver.close() driver.close()

8
importFormationXml.py Normal file
View 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
View File

@ -1,102 +1,112 @@
#Tests E2E du logiciel Scodoc #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. 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 ## I Configuration
Dans cette partie je vais détailler les prérequis pour l'environnement de développement Dans cette partie je vais détailler les prérequis pour l'environnement de développement
### Prérequis Module ### Prérequis Module
Ces prérequis peuvent être trouvés dans requirements.txt qui se trouvent à la base du projet. 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/) 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 : Les modules suivant sont nécessaire :
>selenium==3.141.0 >selenium==3.141.0
>python-dotenv==0.17.1 >python-dotenv==0.17.1
>HtmlTestRunner==0.8.0 >HtmlTestRunner==0.8.0
Vous pouvez les installer manuellement avec pip avec la commande suivante : Vous pouvez les installer manuellement avec pip avec la commande suivante :
>pip install selenium >pip install selenium
ou alternativement avec ou alternativement avec
>pip install -r requirements.txt >pip install -r requirements.txt
### Environnement de test ### 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 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 #### .env
>BASE_URL = "https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" SCHEMA="http"
BASE_URL = "scodoc_server:5000"
Ici sera le lien vers la page d'accueil de votre Scodoc NOM_DPT = "TEST01"
SCODOC_ADMIN_ID = "admin_id"
>NOM_DPT = "test01" SCODOC_ADMIN_PASS = "admin_password"
SCODOC_ENS_ID = "enseignant_id"
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_ENS_PASS = "enseignant_password@10"
SCODOC_CHEF_ID = "chef_id"
>SCODOC_ADMIN_ID = "admin_id" SCODOC_CHEF_PASS = "p@ssword42@"
LINK_SCODOC_SERVER = "scodoc_server"
Le nom d'utilisateur d'un Admin Scodoc. BASE_SSH_URL = "scodoc_server:5000/"
NAVIGATEUR = "firefox"
>SCODOC_ADMIN_PASS = "admin_password"
Ici sera le lien vers la page d'accueil de votre Scodoc
Le mot de passe d'un Admin Scodoc.
>NOM_DPT = "test01"
>SCODOC_ENS_ID = "enseignant_id"
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.
Le nom d'utilisateur d'un enseignant lambda qui servira pour rentrer des notes, soit qui existe, soit qui sera créé.
>SCODOC_ADMIN_ID = "admin_id"
>SCODOC_ENS_PASS = "enseignant_password@10"
Le nom d'utilisateur d'un Admin Scodoc.
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_ADMIN_PASS = "admin_password"
>SCODOC_CHEF_ID = "chef_id"
Le mot de passe d'un Admin Scodoc.
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_ENS_ID = "enseignant_id"
>SCODOC_CHEF_PASS = "p@ssword42@"
Le nom d'utilisateur d'un enseignant lambda qui servira pour rentrer des notes, soit qui existe, soit qui sera créé.
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
>SCODOC_ENS_PASS = "enseignant_password@10"
>LINK_SCODOC_SERVER = "root@ssh_server_scodoc"
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.
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.
>SCODOC_CHEF_ID = "chef_id"
>BASE_NOT_SECURED_URL = "scodoc-dev-iutinfo.univ-lille.fr/"
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éé.
Le lien vers la page de choix de département, avec le format précisé.
>SCODOC_CHEF_PASS = "p@ssword42@"
>NAVIGATEUR = "firefox"
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
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.
>LINK_SCODOC_SERVER = "root@ssh_server_scodoc"
#### Explications du fonctionnement des tests
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.
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.
>BASE_SSH_URL = "scodoc-dev-iutinfo.univ-lille.fr/"
##Lancement des tests
Le lien vers la page de choix de département, avec le format précisé.
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
>NAVIGATEUR = "firefox"
>python3 01_creation_departement_test.py
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.
Alternativement vous pouvez lancer l'ensemble des tests avec la commande
#### Explications du fonctionnement des tests
>./lancement_de_tout_les_tests.sh
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.
L'option --c ou --cleanup est disponible si vous souhaitez effacer tout les rapports précédents
##Lancement des tests
###Resultats 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
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
>python3 01_creation_departement_test.py
>./scriptGenerateReportPage.sh
Alternativement vous pouvez lancer l'ensemble des tests avec la commande
Celui ci est lancé automatiquement à la fin du script
>./lancement_de_tout_les_tests.sh
>./lancement_de_tout_les_tests.sh
L'option --c ou --cleanup est disponible si vous souhaitez effacer tout les rapports précédents
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
###Resultats des tests
##Correctifs
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
* Modifier le PATH pour que geckodriver soit executable `export PATH=".:$PATH"`
>./scriptGenerateReportPage.sh
* pip install HtmlTestRunner-Python3
Celui ci est lancé automatiquement à la fin du script
* Créer un utilisateur Nom:BACH Prenom:Test User:Bach
>./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

View File

@ -6,6 +6,7 @@ then
exit 2 exit 2
fi fi
ssh $1 /bin/bash<< EOF ssh $1 /bin/bash<< EOF
cd /opt/scodoc/Products/ScoDoc/config cd /opt/scodoc
./create_dept.sh -n ${2} . venv/bin/activate
EOF flask create-dept $2
EOF

12
scriptCreationUtilisateurs.sh Executable file
View 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

View File

@ -6,7 +6,8 @@ then
exit 2 exit 2
fi fi
ssh $1 /bin/bash<< EOF ssh $1 /bin/bash<< EOF
cd /opt/scodoc/Products/ScoDoc/config cd /opt/scodoc
./delete_dept.sh -n ${2} . venv/bin/activate
EOF flask delete-dept ${2}
ssh $1 'systemctl restart scodoc' y
EOF

View File

@ -6,7 +6,7 @@ then
exit 2 exit 2
fi fi
ssh $1 /bin/bash<< EOF ssh $1 /bin/bash<< EOF
cd /opt/scodoc/Products/ScoDoc/ cd /opt/scodoc/
scotests/scointeractive.sh -r ${2} scotests/${3} scotests/scointeractive.sh -r ${2} scotests/${3}
EOF EOF
ssh $1 'systemctl restart scodoc' # ssh $1 'systemctl restart scodoc'

12
scriptImportFormation.sh Executable file
View 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

View File

@ -1,18 +1,20 @@
import os import os
from os.path import join, dirname from os.path import join, dirname
from dotenv import load_dotenv from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), ".env") dotenv_path = join(dirname(__file__), ".env")
load_dotenv(dotenv_path) load_dotenv(dotenv_path)
BASE_URL = os.environ.get("BASE_URL") SCHEMA = os.environ.get("SCHEMA")
NOM_DPT = os.environ.get("NOM_DPT") SCODOC_SERVER = os.environ.get("SCODOC_SERVER")
SCODOC_ADMIN_ID = os.environ.get("SCODOC_ADMIN_ID") SCODOC_PORT = os.environ.get("SCODOC_PORT")
SCODOC_ADMIN_PASS = os.environ.get("SCODOC_ADMIN_PASS") NOM_DPT = os.environ.get("NOM_DPT")
SCODOC_ENS_ID = os.environ.get("SCODOC_ENS_ID") SCODOC_ADMIN_ID = os.environ.get("SCODOC_ADMIN_ID")
SCODOC_ENS_PASS = os.environ.get("SCODOC_ENS_PASS") SCODOC_ADMIN_PASS = os.environ.get("SCODOC_ADMIN_PASS")
SCODOC_CHEF_ID = os.environ.get("SCODOC_CHEF_ID") SCODOC_ENS_ID = os.environ.get("SCODOC_ENS_ID")
SCODOC_CHEF_PASS = os.environ.get("SCODOC_CHEF_PASS") SCODOC_ENS_PASS = os.environ.get("SCODOC_ENS_PASS")
LINK_SCODOC_SERVER = os.environ.get("LINK_SCODOC_SERVER") SCODOC_CHEF_ID = os.environ.get("SCODOC_CHEF_ID")
BASE_NOT_SECURED_URL = os.environ.get("BASE_NOT_SECURED_URL") SCODOC_CHEF_PASS = os.environ.get("SCODOC_CHEF_PASS")
NAVIGATEUR = os.environ.get("NAVIGATEUR") LINK_SCODOC_SERVER = os.environ.get("LINK_SCODOC_SERVER")
BASE_SSH_URL = os.environ.get("BASE_SSH_URL")
NAVIGATEUR = os.environ.get("NAVIGATEUR")

View File

@ -1,50 +1,38 @@
# coding: utf8 # coding: utf8
import unittest from setting import (
import time SCODOC_ADMIN_ID,
import subprocess SCODOC_ADMIN_PASS,
import HtmlTestRunner SCHEMA,
from setting import ( SCODOC_SERVER,
SCODOC_ADMIN_ID, SCODOC_PORT,
SCODOC_ADMIN_PASS, NOM_DPT,
BASE_URL, LINK_SCODOC_SERVER,
NOM_DPT, BASE_SSH_URL,
LINK_SCODOC_SERVER, NAVIGATEUR,
BASE_NOT_SECURED_URL, )
NAVIGATEUR, from selenium import webdriver
)
from selenium import webdriver URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait ACRONYME_FORMATION = "FormationTEST"
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select def main():
from selenium.webdriver.support.select import Select if NAVIGATEUR == "firefox":
driver = webdriver.Firefox()
URL = BASE_URL + NOM_DPT + "/Scolarite" else:
driver = webdriver.Chrome()
ACRONYME_FORMATION = "FormationTEST" 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)
def main(): driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
if NAVIGATEUR == "firefox": driver.find_element_by_id("submit").click()
driver = webdriver.Firefox() # driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "scodoc_admin")
else: # time.sleep(2)
driver = webdriver.Chrome() # try:
driver.get( # select = Select(driver.find_element_by_id("delete-dept"))
"https://" # select.select_by_visible_text(NOM_DPT)
+ SCODOC_ADMIN_ID # driver.find_element_by_id("delete-dept").submit()
+ ":" # driver.close()
+ SCODOC_ADMIN_PASS # except NoSuchElementException:
+ "@" driver.close()
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
driver.get(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()