ScodocTestClient/01_creation_departement_test.py

55 lines
1.9 KiB
Python
Raw Normal View History

2021-04-21 13:28:58 +02:00
import unittest
import time
from setup import SCODOC_ADMIN_ID,SCODOC_ADMIN_PASS,BASE_URL,NOM_DPT
2021-04-21 13:28:58 +02:00
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
class PythonOrgSearch(unittest.TestCase):
2021-05-06 08:32:30 +02:00
nomDpt = "AurelienUS"
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):
self.driver = webdriver.Firefox()
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
)
self.driver.get(BASE_URL)
2021-04-21 13:28:58 +02:00
2021-05-06 08:32:30 +02:00
# Test : Verification de la connexion admin effective
# @expected : "Bonjour admin" est présent sur la page d'accueil
def test_connexion_admin(self):
2021-04-21 13:28:58 +02:00
driver = self.driver
2021-05-06 08:32:30 +02:00
self.assertTrue("admin" in driver.page_source)
# Test : Creer un département
# @expected : Le département est présent sur la page d'accueil
def test_create_departement(self):
driver = self.driver
driver.get(BASE_URL + "/scodoc_admin")
2021-04-21 13:28:58 +02:00
select = Select(driver.find_element_by_name("DeptId"))
select.select_by_visible_text("TESTDPT")
self.assertTrue(select.first_selected_option.text == "TESTDPT")
element = driver.find_element_by_name("DeptId")
element = driver.find_element_by_id("gtrcontent").find_element_by_tag_name("h6")
element.submit()
time.sleep(2)
driver.get(BASE_URL)
2021-04-21 13:28:58 +02:00
self.assertTrue("TESTDPT" in driver.page_source)
# 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()