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

@ -10,10 +10,12 @@ import suppressionSiteDepartement
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, LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL, BASE_SSH_URL,
NAVIGATEUR, NAVIGATEUR,
) )
from selenium import webdriver from selenium import webdriver
@ -21,24 +23,27 @@ 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_ROOT = SCHEMA + "://" + + + ":" + SCODOC_PORT
URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
URL_SCODOC8 = "/".join((URL_ROOT, "index"))
URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
class PythonOrgSearch(unittest.TestCase): class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self): def setUp(self):
next_page = ""
if NAVIGATEUR == "firefox": if NAVIGATEUR == "firefox":
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
else: else:
self.driver = webdriver.Chrome() self.driver = webdriver.Chrome()
self.driver.get( auth_page = URL_AUTH + "?next=%2F" + next_page
"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()
+ "@" self.driver.get(URL_SCODOC8)
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
self.driver.get(BASE_URL)
# Test : Verification de la connexion admin effective # Test : Verification de la connexion admin effective
# @expected : "Bonjour admin" est présent sur la page d'accueil # @expected : "Bonjour admin" est présent sur la page d'accueil
@ -50,25 +55,25 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : Le département est présent sur la page d'accueil # @expected : Le département est présent sur la page d'accueil
def test_02_create_departement(self): def test_02_create_departement(self):
driver = self.driver driver = self.driver
driver.get(BASE_URL + "/scodoc_admin") driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
time.sleep(2) time.sleep(2)
select = Select(driver.find_element_by_id("create-dept")) select = Select(driver.find_element_by_id("create-dept"))
select.select_by_visible_text(NOM_DPT) select.select_by_visible_text(NOM_DPT)
driver.find_element_by_id("create-dept").submit() driver.find_element_by_id("create-dept").submit()
time.sleep(1) time.sleep(1)
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
driver.get(BASE_URL) driver.get(URL_HOME)
self.assertTrue(NOM_DPT in driver.page_source) self.assertTrue(NOM_DPT in driver.page_source)
# Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données # Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données
# @expected : Le département n'apparait plus sur la page d'accueil # @expected : Le département n'apparait plus sur la page d'accueil
def test_03_delete_departement(self): def test_03_delete_departement(self):
driver = self.driver driver = self.driver
driver.get(BASE_URL + "/scodoc_admin") driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
select = Select(driver.find_element_by_id("delete-dept")) select = Select(driver.find_element_by_id("delete-dept"))
select.select_by_visible_text(NOM_DPT) select.select_by_visible_text(NOM_DPT)
driver.find_element_by_id("delete-dept").submit() driver.find_element_by_id("delete-dept").submit()
driver.get(BASE_URL) driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
self.assertTrue(NOM_DPT not in driver.page_source) self.assertTrue(NOM_DPT not in driver.page_source)
# ferme la fenetre à chaque fin de test # ferme la fenetre à chaque fin de test

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

@ -8,14 +8,14 @@ import deleteDepartement
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, LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL, BASE_SSH_URL,
NAVIGATEUR, NAVIGATEUR,
) )
import urllib.parse as urlparse
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
@ -23,7 +23,7 @@ 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"
@ -31,26 +31,31 @@ domicile = "50 rue de la marmite"
codepostaldomicile = "59000" codepostaldomicile = "59000"
paysdomicile = "Lille" paysdomicile = "Lille"
URL_ROOT = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT
URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
URL_SCODOC8 = "/".join((URL_ROOT, "index"))
URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
ACRONYME_FORMATION = "formationtest"
URL = URL_SCODOC8
class PythonOrgSearch(unittest.TestCase): class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self): def setUp(self):
next_page = ""
if NAVIGATEUR == "firefox": if NAVIGATEUR == "firefox":
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
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 + ("?next=" + next_page).replace("/", "%2F")
"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()
+ "@" self.driver.get(URL_HOME)
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
global URL
self.driver.get(URL)
# Test : creer un etudiant et verifie si sa fiche etudiante est creee # Test : creer un etudiant et verifie si sa fiche etudiante est creee
# @expected : A la soumission du formulaire on retrouve la fiche d'information avec le nip (unique) dans la page, on a également un resultat en recherchant l'étudiant # @expected : A la soumission du formulaire on retrouve la fiche d'information avec le nip (unique) dans la page, on a également un resultat en recherchant l'étudiant
@ -134,20 +139,21 @@ class PythonOrgSearch(unittest.TestCase):
semestres[0].click() semestres[0].click()
driver.find_element_by_xpath("//input[@value='Inscrire']").click() driver.find_element_by_xpath("//input[@value='Inscrire']").click()
time.sleep(2) time.sleep(2)
boutonInscrireIsNotPresent = False bouton_inscrire_is_not_present = False
try: try:
driver.find_element_by_partial_link_text("inscrire") driver.find_element_by_partial_link_text("inscrire")
except: except:
boutonInscrireIsNotPresent = True bouton_inscrire_is_not_present = True
self.assertTrue(boutonInscrireIsNotPresent) self.assertTrue(bouton_inscrire_is_not_present)
# Test Supprime un étudiant # Test Supprime un étudiant
# @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait # @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait
def test_05_suppresion_etudiant(self): def test_05_suppresion_etudiant(self):
driver = self.driver driver = self.driver
urlRecherche = ( urlRecherche = (
"https://" SCHEMA
+ BASE_NOT_SECURED_URL + "://"
+ SCODOC_SERVER + ":" + SCODOC_PORT
+ "ScoDoc/" + "ScoDoc/"
+ NOM_DPT + NOM_DPT
+ "/Scolarite/search_etud_in_dept" + "/Scolarite/search_etud_in_dept"
@ -159,8 +165,9 @@ class PythonOrgSearch(unittest.TestCase):
time.sleep(1) time.sleep(1)
etudid = driver.find_element_by_id("euid") etudid = driver.find_element_by_id("euid")
url = ( url = (
"https://" SCHEMA
+ BASE_NOT_SECURED_URL + "://"
+ SCODOC_SERVER + ":" + SCODOC_PORT
+ "ScoDoc/" + "ScoDoc/"
+ NOM_DPT + NOM_DPT
+ "/Scolarite/etudident_delete?etudid=" + "/Scolarite/etudident_delete?etudid="

View File

@ -9,10 +9,12 @@ import deleteDepartement
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, LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL, BASE_SSH_URL,
NAVIGATEUR, NAVIGATEUR,
) )
from urllib.parse import parse_qs from urllib.parse import parse_qs
@ -22,7 +24,7 @@ from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select from selenium.webdriver.support.select import Select
URL = BASE_URL + NOM_DPT + "/Scolarite" URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
NOM_ETU = "Semestre11" NOM_ETU = "Semestre11"
PRENOM_ETU = "EtudiantNumero1" PRENOM_ETU = "EtudiantNumero1"
dateDebutAbsenceNonJustifiee = "31/05/2021" dateDebutAbsenceNonJustifiee = "31/05/2021"
@ -32,27 +34,22 @@ dateDebutAbsenceJustifiee = "25/05/2021"
class PythonOrgSearch(unittest.TestCase): class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self): def setUp(self):
next_page = ""
if NAVIGATEUR == "firefox": if NAVIGATEUR == "firefox":
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
else: else:
self.driver = webdriver.Chrome() self.driver = webdriver.Chrome()
self.wait = WebDriverWait(self.driver, 10) auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
self.driver.get( self.driver.get(auth_page)
"https://" self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
+ SCODOC_ADMIN_ID self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
+ ":" self.driver.find_element_by_id("submit").click()
+ SCODOC_ADMIN_PASS self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
global URL
self.driver.get(URL)
def test_010_trouver_etudiant(self): def test_010_trouver_etudiant(self):
driver = self.driver driver = self.driver
global URL global URL
self.driver.get(BASE_URL + NOM_DPT + "/Scolarite") self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite")
element = self.driver.find_element_by_id("in-expnom") element = self.driver.find_element_by_id("in-expnom")
element.send_keys(NOM_ETU) element.send_keys(NOM_ETU)
element.submit() element.submit()

View File

@ -9,7 +9,9 @@ import deleteDepartement
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,
SCODOC_ENS_ID, SCODOC_ENS_ID,
SCODOC_ENS_PASS, SCODOC_ENS_PASS,
@ -17,7 +19,7 @@ from setting import (
SCODOC_CHEF_PASS, SCODOC_CHEF_PASS,
NAVIGATEUR, NAVIGATEUR,
LINK_SCODOC_SERVER, LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL, BASE_SSH_URL,
) )
from urllib.parse import parse_qs from urllib.parse import parse_qs
from selenium import webdriver from selenium import webdriver
@ -29,7 +31,7 @@ from selenium.webdriver.support.select import Select
URL_MATIERE = "" URL_MATIERE = ""
URL_SEMESTRE = "" URL_SEMESTRE = ""
URL = BASE_URL + NOM_DPT + "/Scolarite" URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
PRENOM_ENS = "Ens" PRENOM_ENS = "Ens"
PRENOM_CHEF = "Chef" PRENOM_CHEF = "Chef"
isAdmin = True isAdmin = True
@ -39,36 +41,25 @@ isEns = False
class PythonOrgSearch(unittest.TestCase): class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self): def setUp(self):
next_page = ""
if NAVIGATEUR == "firefox": if NAVIGATEUR == "firefox":
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
else: else:
self.driver = webdriver.Chrome() self.driver = webdriver.Chrome()
self.wait = WebDriverWait(self.driver, 10) self.wait = WebDriverWait(self.driver, 10)
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
self.driver.get(auth_page)
if isAdmin: if isAdmin:
self.driver.get( self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
"https://" self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
+ SCODOC_ADMIN_ID elif isChef:
+ ":" self.driver.find_element_by_id("user_name").send_keys(SCODOC_CHEF_ID)
+ SCODOC_ADMIN_PASS self.driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
else:
self.driver.get(BASE_URL + NOM_DPT + "/Scolarite")
if isChef:
self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_CHEF_ID)
self.driver.find_element_by_name("__ac_password").send_keys(
SCODOC_CHEF_PASS
)
time.sleep(3)
self.driver.find_element_by_name("submit").click()
elif isEns: elif isEns:
self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_ENS_ID) self.driver.find_element_by_id("user_name").send_keys(SCODOC_ENS_ID)
self.driver.find_element_by_name("__ac_password").send_keys( self.driver.find_element_by_id("password").send_keys(SCODOC_ENS_PASS)
SCODOC_ENS_PASS self.driver.find_element_by_id("submit").click()
) self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
self.driver.find_element_by_name("submit").click()
# Test : Vérifie s'il y a un semestre en cours # Test : Vérifie s'il y a un semestre en cours
# @expected : La class listesems n'est pas vide et contient "Session en cours" # @expected : La class listesems n'est pas vide et contient "Session en cours"
@ -167,17 +158,18 @@ class PythonOrgSearch(unittest.TestCase):
driver = self.driver driver = self.driver
global URL_MATIERE global URL_MATIERE
driver.get( driver.get(
"https://" SCHEMA
+ "://"
+ SCODOC_ADMIN_ID + SCODOC_ADMIN_ID
+ ":" + ":"
+ SCODOC_ADMIN_PASS + SCODOC_ADMIN_PASS
+ "@" + "@"
+ BASE_NOT_SECURED_URL + BASE_SSH_URL
+ "force_admin_authentication" + "force_admin_authentication"
) )
# driver.get(BASE_URL) # driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
# driver.find_element_by_link_text("déconnecter").click() # driver.find_element_by_link_text("déconnecter").click()
# driver.get(BASE_URL) # driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
# driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID) # driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID)
# driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS) # driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
# driver.find_element_by_id("submit").click() # driver.find_element_by_id("submit").click()
@ -356,15 +348,16 @@ if __name__ == "__main__":
process.wait() process.wait()
time.sleep(5) time.sleep(5)
driver.get( driver.get(
"https://" SCHEMA
+ "://"
+ SCODOC_ADMIN_ID + SCODOC_ADMIN_ID
+ ":" + ":"
+ SCODOC_ADMIN_PASS + SCODOC_ADMIN_PASS
+ "@" + "@"
+ BASE_NOT_SECURED_URL + BASE_SSH_URL
+ "force_admin_authentication" + "force_admin_authentication"
) )
driver.get(BASE_URL + NOM_DPT + "/Scolarite") driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite")
driver.find_element_by_id("link-view-users").click() driver.find_element_by_id("link-view-users").click()
time.sleep(5) time.sleep(5)
noms = driver.find_elements_by_class_name("nom_fmt") noms = driver.find_elements_by_class_name("nom_fmt")

View File

@ -9,8 +9,10 @@ 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,
SCODOC_PORT,
BASE_SSH_URL,
LINK_SCODOC_SERVER, LINK_SCODOC_SERVER,
NOM_DPT, NOM_DPT,
SCODOC_ENS_ID, SCODOC_ENS_ID,
@ -43,15 +45,16 @@ class PythonOrgSearch(unittest.TestCase):
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
elif NAVIGATEUR == "chrome": elif NAVIGATEUR == "chrome":
self.driver = webdriver.Chrome() self.driver = webdriver.Chrome()
self.url = BASE_URL + NOM_DPT + "/Scolarite" self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
self.wait = WebDriverWait(self.driver, 10) self.wait = WebDriverWait(self.driver, 10)
self.driver.get( self.driver.get(
"https://" SCHEMA
+ "://"
+ SCODOC_ADMIN_ID + SCODOC_ADMIN_ID
+ ":" + ":"
+ SCODOC_ADMIN_PASS + SCODOC_ADMIN_PASS
+ "@" + "@"
+ BASE_NOT_SECURED_URL + BASE_SSH_URL
+ "force_admin_authentication" + "force_admin_authentication"
) )

View File

@ -9,8 +9,10 @@ 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,
SCODOC_PORT,
BASE_SSH_URL,
LINK_SCODOC_SERVER, LINK_SCODOC_SERVER,
NOM_DPT, NOM_DPT,
SCODOC_ENS_ID, SCODOC_ENS_ID,
@ -39,15 +41,16 @@ class PythonOrgSearch(unittest.TestCase):
self.driver = webdriver.Firefox() self.driver = webdriver.Firefox()
elif NAVIGATEUR == "chrome": elif NAVIGATEUR == "chrome":
self.driver = webdriver.Chrome() self.driver = webdriver.Chrome()
self.url = BASE_URL + NOM_DPT + "/Scolarite" self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
self.wait = WebDriverWait(self.driver, 10) self.wait = WebDriverWait(self.driver, 10)
self.driver.get( self.driver.get(
"https://" SCHEMA
+ "://"
+ SCODOC_ADMIN_ID + SCODOC_ADMIN_ID
+ ":" + ":"
+ SCODOC_ADMIN_PASS + SCODOC_ADMIN_PASS
+ "@" + "@"
+ BASE_NOT_SECURED_URL + BASE_SSH_URL
+ "force_admin_authentication" + "force_admin_authentication"
) )

Binary file not shown.

Binary file not shown.

View File

@ -6,10 +6,12 @@ import HtmlTestRunner
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, LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL, BASE_SSH_URL,
NAVIGATEUR, NAVIGATEUR,
) )
from selenium import webdriver from selenium import webdriver
@ -20,26 +22,26 @@ 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"
def main(): def main():
next_page = URL_HOME
if NAVIGATEUR == "firefox": if NAVIGATEUR == "firefox":
driver = webdriver.Firefox() driver = webdriver.Firefox()
else: else:
driver = webdriver.Chrome() driver = webdriver.Chrome()
driver.get( auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
"https://" driver.get(auth_page)
+ SCODOC_ADMIN_ID driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
+ ":" driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
+ SCODOC_ADMIN_PASS driver.find_element_by_id("submit").click()
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
driver.get(BASE_URL + "scodoc_admin")
time.sleep(2) time.sleep(2)
try: try:
select = Select(driver.find_element_by_id("create-dept")) select = Select(driver.find_element_by_id("create-dept"))

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()

View File

@ -20,7 +20,18 @@ ou alternativement avec
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"
NOM_DPT = "TEST01"
SCODOC_ADMIN_ID = "admin_id"
SCODOC_ADMIN_PASS = "admin_password"
SCODOC_ENS_ID = "enseignant_id"
SCODOC_ENS_PASS = "enseignant_password@10"
SCODOC_CHEF_ID = "chef_id"
SCODOC_CHEF_PASS = "p@ssword42@"
LINK_SCODOC_SERVER = "scodoc_server"
BASE_SSH_URL = "scodoc_server:5000/"
NAVIGATEUR = "firefox"
Ici sera le lien vers la page d'accueil de votre Scodoc Ici sera le lien vers la page d'accueil de votre Scodoc
@ -56,7 +67,7 @@ Le mot de passe de l'utilisateur précédent, si l'utilisateur précédent n'exi
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. Le lien vers votre serveur Scodoc, ce dernier servira à lancer des scripts de mise en place sur le serveur. Veillez donc à avoir une connexion avec les droits root sur votre serveur, de préférences avec échange de clef ssh.
>BASE_NOT_SECURED_URL = "scodoc-dev-iutinfo.univ-lille.fr/" >BASE_SSH_URL = "scodoc-dev-iutinfo.univ-lille.fr/"
Le lien vers la page de choix de département, avec le format précisé. Le lien vers la page de choix de département, avec le format précisé.
@ -98,5 +109,4 @@ Vous y retrouverez les liens menant au détails de chaque rapport ainsi qu'un r
* pip install HtmlTestRunner-Python3 * pip install HtmlTestRunner-Python3
* Créer un utilisateur Nom:BACH Prenom:Test User:Bach * 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
flask create-dept $2
EOF 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
flask delete-dept ${2}
y
EOF EOF
ssh $1 'systemctl restart scodoc'

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

@ -5,7 +5,9 @@ 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")
SCODOC_SERVER = os.environ.get("SCODOC_SERVER")
SCODOC_PORT = os.environ.get("SCODOC_PORT")
NOM_DPT = os.environ.get("NOM_DPT") NOM_DPT = os.environ.get("NOM_DPT")
SCODOC_ADMIN_ID = os.environ.get("SCODOC_ADMIN_ID") SCODOC_ADMIN_ID = os.environ.get("SCODOC_ADMIN_ID")
SCODOC_ADMIN_PASS = os.environ.get("SCODOC_ADMIN_PASS") SCODOC_ADMIN_PASS = os.environ.get("SCODOC_ADMIN_PASS")
@ -14,5 +16,5 @@ SCODOC_ENS_PASS = os.environ.get("SCODOC_ENS_PASS")
SCODOC_CHEF_ID = os.environ.get("SCODOC_CHEF_ID") SCODOC_CHEF_ID = os.environ.get("SCODOC_CHEF_ID")
SCODOC_CHEF_PASS = os.environ.get("SCODOC_CHEF_PASS") SCODOC_CHEF_PASS = os.environ.get("SCODOC_CHEF_PASS")
LINK_SCODOC_SERVER = os.environ.get("LINK_SCODOC_SERVER") LINK_SCODOC_SERVER = os.environ.get("LINK_SCODOC_SERVER")
BASE_NOT_SECURED_URL = os.environ.get("BASE_NOT_SECURED_URL") BASE_SSH_URL = os.environ.get("BASE_SSH_URL")
NAVIGATEUR = os.environ.get("NAVIGATEUR") NAVIGATEUR = os.environ.get("NAVIGATEUR")

View File

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