ScodocTestClient/05_saisie_note_test.py

110 lines
4.0 KiB
Python
Raw Normal View History

2021-04-23 13:57:24 +02:00
import unittest
import time
import subprocess
2021-04-23 13:57:24 +02:00
import urllib.parse as urlparse
2021-05-28 20:41:04 +02:00
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
BASE_URL,
NOM_DPT,
SCODOC_ENS_ID,
SCODOC_ENS_PASS,
SCODOC_CHEF_ID,
SCODOC_CHEF_PASS,
NAVIGATEUR,
LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL,
)
2021-04-23 13:57:24 +02:00
from urllib.parse import parse_qs
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
2021-04-23 13:57:24 +02:00
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support.select import Select
URL_MATIERE = ""
2021-06-02 16:22:09 +02:00
URL_SEMESTRE = ""
URL = BASE_URL + NOM_DPT + "/Scolarite"
2021-06-03 15:34:04 +02:00
PRENOM_ENS = "Ens"
2021-06-03 16:13:17 +02:00
isAdmin = True
isChef = False
isEns = False
2021-05-28 20:41:04 +02:00
# Prérequis
2021-04-23 13:57:24 +02:00
class PythonOrgSearch(unittest.TestCase):
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self):
if NAVIGATEUR == "firefox":
self.driver = webdriver.Firefox()
else:
self.driver = webdriver.Chrome()
2021-04-23 13:57:24 +02:00
self.wait = WebDriverWait(self.driver, 10)
2021-06-03 16:13:17 +02:00
if isAdmin:
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
else:
self.driver.get(BASE_URL + NOM_DPT + "/Scolarite")
if isChef:
2021-06-03 16:42:24 +02:00
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
)
self.driver.find_element_by_name("submit").click()
2021-06-03 16:13:17 +02:00
elif isEns:
2021-06-03 16:42:24 +02:00
self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_ENS_ID)
self.driver.find_element_by_name("__ac_password").send_keys(
SCODOC_ENS_PASS
)
self.driver.find_element_by_name("submit").click()
2021-06-03 15:34:04 +02:00
# self.driver.get(self.url)
# self.driver.find_element_by_id("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()
2021-04-23 13:57:24 +02:00
2021-05-06 08:32:30 +02:00
# 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):
2021-04-23 13:57:24 +02:00
driver = self.driver
2021-06-02 16:22:09 +02:00
global URL
driver.get(URL)
2021-06-03 15:34:04 +02:00
# time.sleep(1)
self.assertTrue(
"Sessions en cours" in driver.find_element_by_class_name("listesems").text
)
2021-04-23 13:57:24 +02:00
2021-05-06 08:32:30 +02:00
# Test : Vérifie si une matière existe
# @expected : Le nom de la matière est présent dans le semestre préalablement testé
def test_020_matiere_existante(self):
driver = self.driver
2021-06-02 16:22:09 +02:00
global URL
driver.get(URL)
driver.find_element_by_link_text("semestre 4").click()
self.wait.until(EC.url_changes(URL))
try:
driver.find_element_by_class_name("formsemestre_status_ue")
2021-06-02 16:22:09 +02:00
global URL_SEMESTRE
URL_SEMESTRE = driver.current_url
self.assertTrue(True)
except NoSuchElementException:
self.assertFalse(False)
2021-05-06 08:32:30 +02:00
# Test : Ajout d'un enseignant comme résponsable d'un module
# @expected : Le nom de l'enseignant apparait désormais sur la page d'information du module
def test_030_ajout_enseignant_sur_module(self):
driver = self.driver
2021-06-03 15:34:04 +02:00
# driver.get(BASE_URL)
# driver.find_element_by_link_text("déconnecter").click()
# driver.get(BASE_URL)
# driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID)
# driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS)
# driver.find_element_by_id("submit").click()
# global URL_SEMESTRE
2021-06-02 16:22:09 +02:00
driver.get(URL_SEMESTRE)
2021-06-03 16:42:24 +02:00
driver.find_elemen