tests 02 (formation) ok

This commit is contained in:
Jean-Marie Place 2021-08-09 18:14:10 +02:00
parent 2a57748959
commit b66631cdcc
14 changed files with 2112 additions and 2065 deletions

View File

@ -11,7 +11,8 @@ from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_SSH_URL,
@ -22,7 +23,7 @@ from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
URL_ROOT = SCHEMA + "://" + BASE_URL
URL_ROOT = SCHEMA + "://" + + + ":" + SCODOC_PORT
URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
URL_SCODOC8 = "/".join((URL_ROOT, "index"))
URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
@ -54,7 +55,7 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : Le département est présent sur la page d'accueil
def test_02_create_departement(self):
driver = self.driver
driver.get(SCHEMA + "://" + BASE_URL + "/scodoc_admin")
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
time.sleep(2)
select = Select(driver.find_element_by_id("create-dept"))
select.select_by_visible_text(NOM_DPT)
@ -68,11 +69,11 @@ class PythonOrgSearch(unittest.TestCase):
# @expected : Le département n'apparait plus sur la page d'accueil
def test_03_delete_departement(self):
driver = self.driver
driver.get(SCHEMA + "://" + BASE_URL + "/scodoc_admin")
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "/scodoc_admin")
select = Select(driver.find_element_by_id("delete-dept"))
select.select_by_visible_text(NOM_DPT)
driver.find_element_by_id("delete-dept").submit()
driver.get(SCHEMA + "://" + BASE_URL)
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
self.assertTrue(NOM_DPT not in driver.page_source)
# ferme la fenetre à chaque fin de test

View File

@ -6,14 +6,14 @@ import HtmlTestRunner
import createDepartement
import creationSiteDepartement
import deleteDepartement
import creationUtilisateurs
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_SSH_URL,
NAVIGATEUR,
)
from selenium import webdriver
@ -24,7 +24,7 @@ from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
URL_ROOT = SCHEMA + "://" + BASE_URL
URL_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"))
@ -37,18 +37,16 @@ URL = URL_SCODOC8
class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self):
next_page = ""
if NAVIGATEUR == "firefox":
self.driver = webdriver.Firefox()
else:
self.driver = webdriver.Chrome()
self.wait = WebDriverWait(self.driver, 10)
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
auth_page = URL_AUTH + ("?next=" + URL_HOME).replace("/", "%2F")
self.driver.get(auth_page)
self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
self.driver.find_element_by_id("submit").click()
self.driver.get(URL_HOME)
# Test Creer une formation
# @expected : La formation se trouve dans le tableau de la liste des formations
@ -176,7 +174,7 @@ class PythonOrgSearch(unittest.TestCase):
wait.until(EC.url_changes(URL))
driver.find_element_by_name("date_debut").send_keys("01/01/2021")
driver.find_element_by_name("date_fin").send_keys("30/06/2021")
driver.find_element_by_name("responsable_id").send_keys("HAUSPIE Michael (bach)")
driver.find_element_by_name("responsable_id").send_keys("BACH Jean-Sebastien (Bach)")
Select(driver.find_element_by_id("tf_semestre_id")).select_by_value("4")
driver.find_element_by_id("tf_submit").click()
wait.until(EC.url_changes(URL))
@ -262,6 +260,7 @@ if __name__ == "__main__":
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
creationUtilisateurs.main()
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(

View File

@ -9,14 +9,13 @@ from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_SSH_URL,
NAVIGATEUR,
)
import urllib.parse as urlparse
from urllib.parse import parse_qs
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
@ -24,7 +23,7 @@ from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
nomEtu = "Semestre11"
prenomEtu = "Etudiant1"
nip = "11122234"
@ -32,6 +31,15 @@ domicile = "50 rue de la marmite"
codepostaldomicile = "59000"
paysdomicile = "Lille"
URL_ROOT = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT
URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
URL_SCODOC8 = "/".join((URL_ROOT, "index"))
URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
ACRONYME_FORMATION = "formationtest"
URL = URL_SCODOC8
class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
@ -41,12 +49,13 @@ class PythonOrgSearch(unittest.TestCase):
self.driver = webdriver.Firefox()
else:
self.driver = webdriver.Chrome()
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
self.wait = WebDriverWait(self.driver, 10)
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
self.driver.get(auth_page)
self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
self.driver.find_element_by_id("submit").click()
self.driver.get(SCHEMA + "://" + BASE_URL)
self.driver.get(URL_HOME)
# Test : creer un etudiant et verifie si sa fiche etudiante est creee
# @expected : A la soumission du formulaire on retrouve la fiche d'information avec le nip (unique) dans la page, on a également un resultat en recherchant l'étudiant
@ -130,12 +139,12 @@ class PythonOrgSearch(unittest.TestCase):
semestres[0].click()
driver.find_element_by_xpath("//input[@value='Inscrire']").click()
time.sleep(2)
boutonInscrireIsNotPresent = False
bouton_inscrire_is_not_present = False
try:
driver.find_element_by_partial_link_text("inscrire")
except:
boutonInscrireIsNotPresent = True
self.assertTrue(boutonInscrireIsNotPresent)
bouton_inscrire_is_not_present = True
self.assertTrue(bouton_inscrire_is_not_present)
# Test Supprime un étudiant
# @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait
@ -144,7 +153,7 @@ class PythonOrgSearch(unittest.TestCase):
urlRecherche = (
SCHEMA
+ "://"
+ BASE_URL
+ SCODOC_SERVER + ":" + SCODOC_PORT
+ "ScoDoc/"
+ NOM_DPT
+ "/Scolarite/search_etud_in_dept"
@ -158,7 +167,7 @@ class PythonOrgSearch(unittest.TestCase):
url = (
SCHEMA
+ "://"
+ BASE_URL
+ SCODOC_SERVER + ":" + SCODOC_PORT
+ "ScoDoc/"
+ NOM_DPT
+ "/Scolarite/etudident_delete?etudid="

View File

@ -10,7 +10,8 @@ from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_SSH_URL,
@ -23,7 +24,7 @@ from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
NOM_ETU = "Semestre11"
PRENOM_ETU = "EtudiantNumero1"
dateDebutAbsenceNonJustifiee = "31/05/2021"
@ -43,12 +44,12 @@ class PythonOrgSearch(unittest.TestCase):
self.driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
self.driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
self.driver.find_element_by_id("submit").click()
self.driver.get(SCHEMA + "://" + BASE_URL)
self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
def test_010_trouver_etudiant(self):
driver = self.driver
global URL
self.driver.get(SCHEMA + "://" + 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.send_keys(NOM_ETU)
element.submit()

View File

@ -10,7 +10,8 @@ from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT,
SCODOC_ENS_ID,
SCODOC_ENS_PASS,
@ -30,7 +31,7 @@ from selenium.webdriver.support.select import Select
URL_MATIERE = ""
URL_SEMESTRE = ""
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
PRENOM_ENS = "Ens"
PRENOM_CHEF = "Chef"
isAdmin = True
@ -58,7 +59,7 @@ class PythonOrgSearch(unittest.TestCase):
self.driver.find_element_by_id("user_name").send_keys(SCODOC_ENS_ID)
self.driver.find_element_by_id("password").send_keys(SCODOC_ENS_PASS)
self.driver.find_element_by_id("submit").click()
self.driver.get(SCHEMA + "://" + BASE_URL)
self.driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
# Test : Vérifie s'il y a un semestre en cours
# @expected : La class listesems n'est pas vide et contient "Session en cours"
@ -166,9 +167,9 @@ class PythonOrgSearch(unittest.TestCase):
+ BASE_SSH_URL
+ "force_admin_authentication"
)
# driver.get(SCHEMA + "://" + BASE_URL)
# driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT)
# driver.find_element_by_link_text("déconnecter").click()
# driver.get(SCHEMA + "://" + 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("password").send_keys(SCODOC_CHEF_PASS)
# driver.find_element_by_id("submit").click()
@ -356,7 +357,7 @@ if __name__ == "__main__":
+ BASE_SSH_URL
+ "force_admin_authentication"
)
driver.get(SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite")
driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite")
driver.find_element_by_id("link-view-users").click()
time.sleep(5)
noms = driver.find_elements_by_class_name("nom_fmt")

View File

@ -10,7 +10,8 @@ from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
BASE_SSH_URL,
LINK_SCODOC_SERVER,
NOM_DPT,
@ -44,7 +45,7 @@ class PythonOrgSearch(unittest.TestCase):
self.driver = webdriver.Firefox()
elif NAVIGATEUR == "chrome":
self.driver = webdriver.Chrome()
self.url = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
self.wait = WebDriverWait(self.driver, 10)
self.driver.get(
SCHEMA

View File

@ -10,7 +10,8 @@ from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
BASE_SSH_URL,
LINK_SCODOC_SERVER,
NOM_DPT,
@ -40,7 +41,7 @@ class PythonOrgSearch(unittest.TestCase):
self.driver = webdriver.Firefox()
elif NAVIGATEUR == "chrome":
self.driver = webdriver.Chrome()
self.url = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
self.url = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
self.wait = WebDriverWait(self.driver, 10)
self.driver.get(
SCHEMA

View File

@ -7,7 +7,8 @@ from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_SSH_URL,
@ -21,7 +22,7 @@ from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
URL_ROOT = SCHEMA + "://" + BASE_URL
URL_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"))

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,8 +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
#### .env
>SCHEMA = "https"
>BASE_URL = "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

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

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

@ -6,7 +6,8 @@ dotenv_path = join(dirname(__file__), ".env")
load_dotenv(dotenv_path)
SCHEMA = os.environ.get("SCHEMA")
BASE_URL = os.environ.get("BASE_URL")
SCODOC_SERVER = os.environ.get("SCODOC_SERVER")
SCODOC_PORT = os.environ.get("SCODOC_PORT")
NOM_DPT = os.environ.get("NOM_DPT")
SCODOC_ADMIN_ID = os.environ.get("SCODOC_ADMIN_ID")
SCODOC_ADMIN_PASS = os.environ.get("SCODOC_ADMIN_PASS")

View File

@ -1,43 +1,33 @@
# coding: utf8
import unittest
import time
import subprocess
import HtmlTestRunner
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
SCHEMA,
BASE_URL,
SCODOC_SERVER,
SCODOC_PORT,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_SSH_URL,
NAVIGATEUR,
)
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
URL = SCHEMA + "://" + BASE_URL + NOM_DPT + "/Scolarite"
URL = SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + NOM_DPT + "/Scolarite"
ACRONYME_FORMATION = "FormationTEST"
def main():
next_page = "test_vue"
if NAVIGATEUR == "firefox":
driver = webdriver.Firefox()
else:
driver = webdriver.Chrome()
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
auth_page = URL_AUTH + ("?next=" + URL_HOME).replace("/", "%2F")
driver.get(auth_page)
driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
driver.find_element_by_id("submit").click()
# driver.get(SCHEMA + "://" + BASE_URL + "scodoc_admin")
# driver.get(SCHEMA + "://" + SCODOC_SERVER + ":" + SCODOC_PORT + "scodoc_admin")
# time.sleep(2)
# try:
# select = Select(driver.find_element_by_id("delete-dept"))