ScodocTestClient/01_creation_departement_test.py
2021-05-06 08:32:30 +02:00

57 lines
2.0 KiB
Python

import unittest
import time
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
SCODOC_ADMIN_ID = "admin"
SCODOC_ADMIN_PASS = "root_pass_42"
class PythonOrgSearch(unittest.TestCase):
nomDpt = "AurelienUS"
# 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("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc")
# Test : Verification de la connexion admin effective
# @expected : "Bonjour admin" est présent sur la page d'accueil
def test_connexion_admin(self):
driver = self.driver
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("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/scodoc_admin")
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("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc")
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()