forked from aurelien.plancke/ScodocTestClient
213 lines
7.8 KiB
Python
213 lines
7.8 KiB
Python
import unittest
|
|
import time
|
|
import subprocess
|
|
import urllib.parse as urlparse
|
|
from setting import (
|
|
SCODOC_ADMIN_ID,
|
|
SCODOC_ADMIN_PASS,
|
|
BASE_URL,
|
|
BASE_NOT_SECURED_URL,
|
|
LINK_SCODOC_SERVER,
|
|
NOM_DPT,
|
|
SCODOC_ENS_ID,
|
|
SCODOC_ENS_PASS,
|
|
SCODOC_CHEF_ID,
|
|
SCODOC_CHEF_PASS,
|
|
NAVIGATEUR,
|
|
)
|
|
from urllib.parse import parse_qs
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.keys import Keys
|
|
from selenium.common.exceptions import NoSuchElementException
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
from selenium.webdriver.support.ui import Select, WebDriverWait
|
|
from selenium.webdriver.support.select import Select
|
|
|
|
urlMatiere = ""
|
|
listeEtudiant = []
|
|
global MOY_UE1
|
|
global MOY_UE2
|
|
global URL_SEMESTRE
|
|
|
|
|
|
class PythonOrgSearch(unittest.TestCase):
|
|
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
|
def setUp(self):
|
|
if NAVIGATEUR == "firefox":
|
|
self.driver = webdriver.Firefox()
|
|
elif NAVIGATEUR == "chrome":
|
|
self.driver = webdriver.Chrome()
|
|
self.url = BASE_URL + NOM_DPT + "/Scolarite"
|
|
self.wait = WebDriverWait(self.driver, 10)
|
|
self.driver.get(
|
|
"https://"
|
|
+ SCODOC_ADMIN_ID
|
|
+ ":"
|
|
+ SCODOC_ADMIN_PASS
|
|
+ "@"
|
|
+ BASE_NOT_SECURED_URL
|
|
+ "force_admin_authentication"
|
|
)
|
|
|
|
def test_010_ajout_note_multiple_pour_une_ue(self):
|
|
global listeEtudiant
|
|
global MOY_UE1
|
|
global URL_SEMESTRE
|
|
driver = self.driver
|
|
url = self.url
|
|
driver.get(url)
|
|
linkAddNote = "formnotes_note_"
|
|
driver.find_element_by_link_text("semestre 1").click()
|
|
URL_SEMESTRE = driver.current_url
|
|
ue_name = driver.find_elements_by_class_name("status_ue_acro")[0].text
|
|
driver.find_element_by_link_text("M1101").click()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
URL = driver.current_url
|
|
for champs in driver.find_elements_by_xpath(
|
|
"//input[contains(@id,'" + linkAddNote + "')]"
|
|
):
|
|
champs.clear()
|
|
champs.send_keys(12)
|
|
idChamp = champs.get_attribute("id")
|
|
idEtud = idChamp[len(linkAddNote) : len(idChamp)]
|
|
if idEtud not in listeEtudiant:
|
|
listeEtudiant.append(idEtud)
|
|
driver.find_element_by_id("formnotes_submit").click()
|
|
self.wait.until(EC.url_changes(URL))
|
|
driver.get(URL_SEMESTRE)
|
|
noteBonne = True
|
|
print(listeEtudiant)
|
|
for etudiant in listeEtudiant:
|
|
searchBar = driver.find_element_by_id("in-expnom")
|
|
searchBar.send_keys(etudiant)
|
|
searchBar.submit()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
MOY_UE1 = driver.find_element_by_id("ue_" + ue_name).text
|
|
if "12" not in MOY_UE1:
|
|
noteBonne = False
|
|
self.assertTrue(noteBonne)
|
|
# matiereAvecEvaluation = driver.find_elements_by_xpath("//a[contains(text(),'1 prévues, 0 ok')]")
|
|
#
|
|
# for evaluation in matiereAvecEvaluation:
|
|
# URL = driver.current_url
|
|
# evaluation.click()
|
|
# self.wait.until(EC.url_changes(URL))
|
|
# URL_SEMESTRE = driver.current_url
|
|
# driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
|
# self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
# for champs in driver.find_elements_by_xpath(
|
|
# "//input[contains(@id,'" + linkAddNote + "')]"
|
|
# ):
|
|
# champs.send_keys(12)
|
|
# idChamp = champs.get_attribute("id")
|
|
# idEtud = idChamp[len(linkAddNote) : len(idChamp)]
|
|
# if idEtud not in listeEtudiant:
|
|
# listeEtudiant.append(idEtud)
|
|
# URL = driver.current_url
|
|
# driver.find_element_by_id("formnotes_submit").click()
|
|
# self.wait.until(EC.url_changes(URL))
|
|
# driver.get(URL_SEMESTRE)
|
|
# self.wait.until(EC.url_changes(URL))
|
|
# matiereAvecEvaluation = driver.find_elements_by_xpath(
|
|
# "//a[contains(text(),'1 prévues, 0 ok')]"
|
|
# )
|
|
|
|
def test_020_ajout_note_seconde_ue(self):
|
|
global listeEtudiant
|
|
global MOY_UE2
|
|
global URL_SEMESTRE
|
|
linkAddNote = "formnotes_note_"
|
|
driver = self.driver
|
|
url = self.url
|
|
driver.get(URL_SEMESTRE)
|
|
ue_name = driver.find_elements_by_class_name("status_ue_acro")[1].text
|
|
driver.find_element_by_link_text("M1201").click()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
URL = driver.current_url
|
|
for champs in driver.find_elements_by_xpath(
|
|
"//input[contains(@id,'" + linkAddNote + "')]"
|
|
):
|
|
champs.clear()
|
|
champs.send_keys(8)
|
|
driver.find_element_by_id("formnotes_submit").click()
|
|
self.wait.until(EC.url_changes(URL))
|
|
driver.get(URL_SEMESTRE)
|
|
noteBonne = True
|
|
for etudiant in listeEtudiant:
|
|
searchBar = driver.find_element_by_id("in-expnom")
|
|
searchBar.send_keys(etudiant)
|
|
searchBar.submit()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
MOY_UE2 = driver.find_element_by_id("ue_" + ue_name).text
|
|
if "8" not in MOY_UE2:
|
|
noteBonne = False
|
|
|
|
self.assertTrue(noteBonne)
|
|
|
|
def test_030_verification_moyenne_generale(self):
|
|
global listeEtudiant
|
|
global MOY_UE1
|
|
global MOY_UE2
|
|
driver = self.driver
|
|
url = self.url
|
|
driver.get(url)
|
|
moyenneBonne = True
|
|
for etudiant in listeEtudiant:
|
|
searchBar = driver.find_element_by_id("in-expnom")
|
|
searchBar.send_keys(etudiant)
|
|
searchBar.submit()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
if (MOY_UE1 * 2 + MOY_UE2 * 2) / 2 not in driver.find_element_by_id(
|
|
"ue_" + ue_name
|
|
).text:
|
|
moyenneBonne = False
|
|
self.assertTrue(moyenneBonne)
|
|
|
|
def test_040_modification_coefficiant_module(self):
|
|
global listeEtudiant
|
|
coeffUE1 = 3
|
|
coeffUE2 = 2
|
|
driver = self.driver
|
|
url = self.url
|
|
driver.get(url)
|
|
driver.find_element_by_id("ProgrammesLink").click()
|
|
driver.find_element_by_id("titre_DUT Info").click()
|
|
driver.find_element_by_xpath("//span[contains(text(),'M1101')]").click()
|
|
driver.find_element_by_id("tf_coefficient").clear()
|
|
driver.find_element_by_id("tf_coefficient").send_keys("3")
|
|
driver.find_element_by_id("tf_submit").click()
|
|
for etudiant in listeEtudiant:
|
|
searchBar = driver.find_element_by_id("in-expnom")
|
|
searchBar.send_keys(etudiant)
|
|
searchBar.submit()
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
if (
|
|
MOY_UE1 * moyUE1 + MOY_UE2 * coeffUE2
|
|
) / 2 not in driver.find_element_by_class(rcp_moy).text:
|
|
moyenneBonne = False
|
|
|
|
def tearDown(self):
|
|
self.driver.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if NAVIGATEUR == "firefox":
|
|
driver = webdriver.Firefox()
|
|
else:
|
|
driver = webdriver.Chrome()
|
|
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
|
|
process = subprocess.Popen(cmdProcess)
|
|
process.wait()
|
|
cmdProcess = [
|
|
"./scriptExecution.sh",
|
|
LINK_SCODOC_SERVER,
|
|
NOM_DPT,
|
|
"test_scenario3_formation.py",
|
|
]
|
|
process = subprocess.Popen(cmdProcess)
|
|
process.wait()
|
|
unittest.main(warnings="ignore") |