ScodocTestClient/02_creation_formation_test.py

98 lines
3.9 KiB
Python
Raw Normal View History

2021-05-21 16:29:45 +02:00
# coding: utf8
2021-04-21 13:28:58 +02:00
import unittest
import time
2021-05-21 16:29:45 +02:00
import subprocess
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT, LINK_SCODOC_SERVER
2021-04-21 13:28:58 +02:00
from selenium import webdriver
2021-05-21 16:29:45 +02:00
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.common.exceptions import NoSuchElementException
2021-04-21 13:28:58 +02:00
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
2021-05-21 16:29:45 +02:00
URL = BASE_URL + NOM_DPT + "/Scolarite"
2021-04-21 13:28:58 +02:00
2021-05-21 16:29:45 +02:00
ACRONYME_FORMATION = "FormationTEST"
2021-04-21 13:28:58 +02:00
class PythonOrgSearch(unittest.TestCase):
2021-05-21 16:29:45 +02:00
cmdProcess = ['./scriptCreationDepartement.sh', LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
2021-04-21 13:28:58 +02:00
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
def setUp(self):
2021-05-21 16:29:45 +02:00
self.url = ''
2021-04-21 13:28:58 +02:00
self.driver = webdriver.Firefox()
2021-05-21 16:29:45 +02:00
self.wait = WebDriverWait(self.driver, 10)
2021-04-21 13:28:58 +02:00
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
2021-05-21 16:29:45 +02:00
self.driver.get(BASE_URL + "/ScoDoc")
2021-04-21 13:28:58 +02:00
2021-05-06 20:28:56 +02:00
# Test Creer une formation
2021-05-21 16:29:45 +02:00
# @expected : La formation se trouve dans le tableau de la liste des formations
def test_011_create_formation(self):
driver = self.driver
driver.get(URL)
driver.find_element_by_id("ProgrammesLink").click()
self.url = driver.current_url
driver.find_element_by_id("create_formation_link").click()
self.wait.until(EC.url_changes(URL))
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_officiel").send_keys("formation de test")
driver.find_element_by_id("tf_submit").click()
driver.get(self.url)
formations = driver.find_elements_by_class_name("acronyme")
textElementAcronyme = []
for formation in formations:
textElementAcronyme.append(formation.text)
self.assertTrue(ACRONYME_FORMATION in textElementAcronyme)
def test_012_create_formation_with_same_name(self):
2021-04-21 13:28:58 +02:00
driver = self.driver
2021-05-21 16:29:45 +02:00
url = self.url
2021-04-21 13:28:58 +02:00
driver.get(url)
2021-05-21 16:29:45 +02:00
idEditFormation = "edit_Formation_" + ACRONYME_FORMATION
driver.find_element_by_id(idEditFormation).click()
self.wait.until(EC.url_changes(URL))
driver.find_element_by_id("tf_acronyme").send_keys(ACRONYME_FORMATION + ACRONYME_FORMATION)
driver.find_element_by_id("tf_submit").click()
driver.get(self.url)
formations = driver.find_elements_by_class_name(" acronyme")
textElementAcronyme = []
for formation in formations:
textElementAcronyme.append(formation.text)
self.assertTrue(ACRONYME_FORMATION + ACRONYME_FORMATION in textElementAcronyme)
def test_020_delete_formation(self):
driver = self.driver
url = self.url
driver.get(self.url)
driver.find_element_by_id("ProgrammesLink").click()
url = driver.current_url
idButtonDelete = "delete_Formation_"+ACRONYME_FORMATION
driver.find_element_by_id(idButtonDelete).click()
self.wait.until(EC.url_changes(url))
driver.find_element_by_xpath("//input[@value='Supprimer cette formation']").click()
driver.get(self.url)
try:
driver.find_element_by_id(idButtonDelete)
self.assertTrue(False)
except NoSuchElementException:
self.assertTrue(True)
2021-04-21 13:28:58 +02:00
# def test_create_module(self):
# driver = self.driver
# element = driver.find_element_by_name("TESTDPT")
# ferme la fenetre à chaque fin de test
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()