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,BASE_NOT_SECURED_URL
|
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-21 16:29:45 +02:00
|
|
|
cmdProcess = ['./scriptCreationDepartement.sh', LINK_SCODOC_SERVER, 'TESTCREATEDPT']
|
|
|
|
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):
|
|
|
|
self.driver = webdriver.Firefox()
|
|
|
|
self.driver.get(
|
|
|
|
"https://"
|
|
|
|
+ SCODOC_ADMIN_ID
|
|
|
|
+ ":"
|
|
|
|
+ SCODOC_ADMIN_PASS
|
2021-05-21 16:29:45 +02:00
|
|
|
+ "@"
|
|
|
|
+ BASE_NOT_SECURED_URL
|
|
|
|
+ "force_admin_authentication"
|
2021-04-21 13:28:58 +02:00
|
|
|
)
|
2021-05-12 14:49:00 +02:00
|
|
|
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
|
2021-05-12 14:49:00 +02:00
|
|
|
driver.get(BASE_URL + "/scodoc_admin")
|
2021-05-21 16:29:45 +02:00
|
|
|
select = Select(driver.find_element_by_id("CreateDept"))
|
|
|
|
select.select_by_visible_text("TESTCREATEDPT")
|
|
|
|
driver.find_element_by_name("DeptId").submit()
|
|
|
|
time.sleep(1)
|
|
|
|
driver.find_element_by_id("tf_submit").click()
|
2021-05-12 14:49:00 +02:00
|
|
|
driver.get(BASE_URL)
|
2021-05-21 16:29:45 +02:00
|
|
|
self.assertTrue("TESTCREATEDPT" in driver.page_source)
|
2021-04-21 13:28:58 +02:00
|
|
|
|
2021-05-21 16:29:45 +02:00
|
|
|
#Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données
|
|
|
|
# @expected : Le département n'apparait plus sur la page d'accueil
|
|
|
|
def test_delete_departement(self):
|
|
|
|
driver = self.driver
|
|
|
|
driver.get(BASE_URL + "/scodoc_admin")
|
|
|
|
select = Select(driver.find_element_by_id("DeleteDept"))
|
|
|
|
select.select_by_visible_text("TESTCREATEDPT")
|
|
|
|
driver.find_element_by_id("DeleteDept").submit()
|
|
|
|
driver.get(BASE_URL)
|
|
|
|
self.assertTrue("TESTCREATEDPT" not in driver.page_source)
|
|
|
|
cmdProcess = ['./scriptDeleteDepartement.sh', LINK_SCODOC_SERVER, 'TESTCREATEDPT']
|
|
|
|
process = subprocess.Popen(cmdProcess)
|
|
|
|
process.wait()
|
2021-04-21 13:28:58 +02:00
|
|
|
# ferme la fenetre à chaque fin de test
|
2021-05-21 16:29:45 +02:00
|
|
|
|
2021-04-21 13:28:58 +02:00
|
|
|
def tearDown(self):
|
|
|
|
self.driver.close()
|
|
|
|
|
|
|
|
|
2021-05-21 16:29:45 +02:00
|
|
|
|
2021-04-21 13:28:58 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|