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
|
2021-06-23 14:27:05 +02:00
|
|
|
import HtmlTestRunner
|
2021-06-24 15:04:22 +02:00
|
|
|
import createDepartement
|
|
|
|
import creationSiteDepartement
|
|
|
|
import deleteDepartement
|
|
|
|
import suppressionSiteDepartement
|
2021-05-28 20:41:04 +02:00
|
|
|
from setting import (
|
|
|
|
SCODOC_ADMIN_ID,
|
|
|
|
SCODOC_ADMIN_PASS,
|
2021-07-24 08:41:26 +02:00
|
|
|
SCHEMA,
|
2021-05-28 20:41:04 +02:00
|
|
|
BASE_URL,
|
|
|
|
NOM_DPT,
|
|
|
|
LINK_SCODOC_SERVER,
|
2021-07-24 08:41:26 +02:00
|
|
|
BASE_SSH_URL,
|
2021-06-01 16:50:45 +02:00
|
|
|
NAVIGATEUR,
|
2021-05-28 20:41:04 +02:00
|
|
|
)
|
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):
|
|
|
|
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
|
|
|
def setUp(self):
|
2021-07-29 08:17:23 +02:00
|
|
|
next_page = ""
|
2021-06-01 16:50:45 +02:00
|
|
|
if NAVIGATEUR == "firefox":
|
|
|
|
self.driver = webdriver.Firefox()
|
|
|
|
else:
|
|
|
|
self.driver = webdriver.Chrome()
|
2021-07-29 08:17:23 +02:00
|
|
|
auth_page = SCHEMA + "://" + BASE_SSH_URL + "auth/login?next=%2F" + next_page
|
|
|
|
driver.get(auth_page)
|
|
|
|
driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
|
|
|
|
driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
|
|
|
|
driver.find_element_by_id("submit").click()
|
2021-07-24 08:41:26 +02:00
|
|
|
self.driver.get(SCHEMA + "://" + 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
|
2021-06-25 02:12:04 +02:00
|
|
|
def test_01_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
|
2021-06-25 02:12:04 +02:00
|
|
|
def test_02_create_departement(self):
|
2021-05-06 08:32:30 +02:00
|
|
|
driver = self.driver
|
2021-07-24 08:41:26 +02:00
|
|
|
driver.get(SCHEMA + "://" + BASE_URL + "/scodoc_admin")
|
2021-06-21 15:19:30 +02:00
|
|
|
time.sleep(2)
|
2021-06-25 00:45:50 +02:00
|
|
|
select = Select(driver.find_element_by_id("create-dept"))
|
2021-06-21 15:19:30 +02:00
|
|
|
select.select_by_visible_text(NOM_DPT)
|
2021-06-25 02:12:04 +02:00
|
|
|
driver.find_element_by_id("create-dept").submit()
|
2021-05-21 16:29:45 +02:00
|
|
|
time.sleep(1)
|
|
|
|
driver.find_element_by_id("tf_submit").click()
|
2021-07-24 08:41:26 +02:00
|
|
|
driver.get(SCHEMA + "://" + BASE_URL)
|
2021-06-21 15:19:30 +02:00
|
|
|
self.assertTrue(NOM_DPT in driver.page_source)
|
2021-04-21 13:28:58 +02:00
|
|
|
|
2021-05-28 20:41:04 +02:00
|
|
|
# Test : Suppresion d'un département, puis lancement d'un script coté serveur pour supprimer sa base de données
|
2021-05-21 16:29:45 +02:00
|
|
|
# @expected : Le département n'apparait plus sur la page d'accueil
|
2021-06-25 02:12:04 +02:00
|
|
|
def test_03_delete_departement(self):
|
2021-05-21 16:29:45 +02:00
|
|
|
driver = self.driver
|
2021-07-24 08:41:26 +02:00
|
|
|
driver.get(SCHEMA + "://" + BASE_URL + "/scodoc_admin")
|
2021-06-25 00:45:50 +02:00
|
|
|
select = Select(driver.find_element_by_id("delete-dept"))
|
2021-06-21 15:19:30 +02:00
|
|
|
select.select_by_visible_text(NOM_DPT)
|
2021-06-25 02:12:04 +02:00
|
|
|
driver.find_element_by_id("delete-dept").submit()
|
2021-07-24 08:41:26 +02:00
|
|
|
driver.get(SCHEMA + "://" + BASE_URL)
|
2021-06-21 15:19:30 +02:00
|
|
|
self.assertTrue(NOM_DPT not in driver.page_source)
|
2021-05-28 20:41:04 +02:00
|
|
|
|
2021-04-21 13:28:58 +02:00
|
|
|
# ferme la fenetre à chaque fin de test
|
|
|
|
def tearDown(self):
|
|
|
|
self.driver.close()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-06-24 15:04:22 +02:00
|
|
|
deleteDepartement.main()
|
|
|
|
createDepartement.main()
|
|
|
|
suppressionSiteDepartement.main()
|
|
|
|
unittest.main(
|
|
|
|
testRunner=HtmlTestRunner.HTMLTestRunner(
|
2021-06-24 17:17:15 +02:00
|
|
|
report_name="01_création_département",
|
2021-06-24 15:04:22 +02:00
|
|
|
output="./ResultatTest",
|
|
|
|
combine_reports=True,
|
|
|
|
)
|
|
|
|
)
|