Browse Source

amélioration des rapports & création de scripts pour l'indépendance des jeux de tests

master
Aurélien Plancke 4 months ago
parent
commit
2519454dae
  1. 29
      01_creation_departement_test.py
  2. 41
      02_creation_formation_test.py
  3. 21
      03_etudiant_test.py
  4. 20
      04_creation_absence_test.py
  5. 20
      05_saisie_note_test.py
  6. 28
      06_test_moyenne.py
  7. 20
      07_test_admission.py
  8. 84
      ResultatTest/01_création département_2021-06-24_15-02-41.html
  9. 8
      createDepartement.py
  10. 53
      creationSiteDepartement.py
  11. 8
      deleteDepartement.py
  12. 0
      index.html
  13. 13
      lancement_de_tout_les_tests.sh
  14. 4
      readme.md
  15. 50
      suppressionSiteDepartement.py

29
01_creation_departement_test.py

@ -3,6 +3,10 @@ import unittest
import time
import subprocess
import HtmlTestRunner
import createDepartement
import creationSiteDepartement
import deleteDepartement
import suppressionSiteDepartement
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
@ -66,25 +70,20 @@ class PythonOrgSearch(unittest.TestCase):
driver.find_element_by_id("DeleteDept").submit()
driver.get(BASE_URL)
self.assertTrue(NOM_DPT not in driver.page_source)
cmdProcess = [
"./scriptDeleteDepartement.sh",
LINK_SCODOC_SERVER,
NOM_DPT,
]
process = subprocess.Popen(cmdProcess)
process.wait()
# ferme la fenetre à chaque fin de test
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))
deleteDepartement.main()
createDepartement.main()
suppressionSiteDepartement.main()
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="01_création département",
output="./ResultatTest",
combine_reports=True,
)
)

41
02_creation_formation_test.py

@ -3,6 +3,9 @@ import unittest
import time
import subprocess
import HtmlTestRunner
import createDepartement
import creationSiteDepartement
import deleteDepartement
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
@ -251,32 +254,14 @@ class PythonOrgSearch(unittest.TestCase):
if __name__ == "__main__":
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
if NAVIGATEUR == "firefox":
driver = webdriver.Firefox()
else:
driver = webdriver.Chrome()
driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="02_creation_formation_test",
output="./ResultatTest",
combine_reports=True,
)
)
driver.get(BASE_URL + "scodoc_admin")
time.sleep(2)
select = Select(driver.find_element_by_id("CreateDept"))
select.select_by_visible_text(NOM_DPT)
driver.find_element_by_name("DeptId").submit()
time.sleep(1)
driver.find_element_by_id("tf_submit").click()
time.sleep(1)
driver.close()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

21
03_etudiant_test.py

@ -2,6 +2,9 @@ import unittest
import time
import HtmlTestRunner
import subprocess
import createDepartement
import creationSiteDepartement
import deleteDepartement
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
@ -137,7 +140,6 @@ class PythonOrgSearch(unittest.TestCase):
except:
boutonInscrireIsNotPresent = True
self.assertTrue(boutonInscrireIsNotPresent)
# Test Supprime un étudiant
# @expected : Lors d'une recherche sur le nom de l'étudiant, aucun résultat apparait
@ -182,12 +184,9 @@ class PythonOrgSearch(unittest.TestCase):
if __name__ == "__main__":
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
cmdProcess = [
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
@ -196,4 +195,10 @@ if __name__ == "__main__":
]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="03_Etudiant_test",
output="./ResultatTest",
combine_reports=True,
)
)

20
04_creation_absence_test.py

@ -3,6 +3,9 @@ import time
import urllib.parse as urlparse
import subprocess
import HtmlTestRunner
import createDepartement
import creationSiteDepartement
import deleteDepartement
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
@ -151,12 +154,9 @@ class PythonOrgSearch(unittest.TestCase):
if __name__ == "__main__":
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
cmdProcess = [
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
@ -165,4 +165,10 @@ if __name__ == "__main__":
]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="04_Absences tests",
output="./ResultatTest",
combine_reports=True,
)
)

20
05_saisie_note_test.py

@ -3,6 +3,9 @@ import time
import subprocess
import urllib.parse as urlparse
import HtmlTestRunner
import createDepartement
import creationSiteDepartement
import deleteDepartement
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
@ -334,12 +337,9 @@ if __name__ == "__main__":
driver = webdriver.Firefox()
else:
driver = webdriver.Chrome()
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
cmdProcess = [
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
@ -396,4 +396,10 @@ if __name__ == "__main__":
driver.find_element_by_id("tf_submit").click()
driver.find_element_by_id("utilisateurs_Vue").click()
driver.close()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="05_Saisie note tests",
output="./ResultatTest",
combine_reports=True,
)
)

28
06_test_moyenne.py

@ -3,6 +3,9 @@ import time
import subprocess
import urllib.parse as urlparse
import HtmlTestRunner
import createDepartement
import creationSiteDepartement
import deleteDepartement
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
@ -84,7 +87,7 @@ class PythonOrgSearch(unittest.TestCase):
self.wait.until(EC.url_changes(URL))
driver.get(URL_SEMESTRE)
noteBonne = True
#print(listeEtudiant)
# print(listeEtudiant)
for etudiant in listeEtudiant:
searchBar = driver.find_element_by_id("in-expnom")
searchBar.send_keys(etudiant)
@ -335,12 +338,12 @@ class PythonOrgSearch(unittest.TestCase):
float(MOY_UE1_EXC) * COEFF_UE1
+ ((float(MOY_UE2) + float(moyenneBonusEtudiant1)) * COEFF_UE2)
) / (COEFF_UE1 + COEFF_UE2)
#print(format(moyEtudiant1, "2.2f"))
#print(
# print(format(moyEtudiant1, "2.2f"))
# print(
# format(
# float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
# )
#)
# )
if format(moyEtudiant1, "2.2f") != format(
float(driver.find_element_by_class_name("rcp_moy").text), "2.2f"
):
@ -431,12 +434,9 @@ class PythonOrgSearch(unittest.TestCase):
if __name__ == "__main__":
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
cmdProcess = [
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
@ -445,4 +445,10 @@ if __name__ == "__main__":
]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="06_Moyenne tests",
output="./ResultatTest",
combine_reports=True,
)
)

20
07_test_admission.py

@ -3,6 +3,9 @@ import time
import subprocess
import urllib.parse as urlparse
import HtmlTestRunner
import createDepartement
import creationSiteDepartement
import deleteDepartement
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
@ -219,12 +222,9 @@ class PythonOrgSearch(unittest.TestCase):
if __name__ == "__main__":
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
deleteDepartement.main()
createDepartement.main()
creationSiteDepartement.main()
cmdProcess = [
"./scriptExecution.sh",
LINK_SCODOC_SERVER,
@ -233,4 +233,10 @@ if __name__ == "__main__":
]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(
report_name="07_Admission et passages tests",
output="./ResultatTest",
combine_reports=True,
)
)

84
ResultatTest/01_création département_2021-06-24_15-02-41.html

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html>
<head>
<title>Unittest Results</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h2 class="text-capitalize">Unittest Results</h2>
<p class='attribute'><strong>Start Time: </strong>2021-06-24 15:02:41</p>
<p class='attribute'><strong>Duration: </strong>39.96 s</p>
<p class='attribute'><strong>Summary: </strong>Total: 3, Pass: 3</p>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-10 col-md-10">
<table class='table table-hover table-responsive'>
<thead>
<tr>
<th>__main__.PythonOrgSearch</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<tr class='success'>
<td class="col-xs-10">test_connexion_admin</td>
<td class="col-xs-1">
<span class="label label-success" style="display:block;width:40px;">Pass</span>
</td>
<td class="col-xs-1">
</td>
</tr>
<tr class='success'>
<td class="col-xs-10">test_create_departement</td>
<td class="col-xs-1">
<span class="label label-success" style="display:block;width:40px;">Pass</span>
</td>
<td class="col-xs-1">
</td>
</tr>
<tr class='success'>
<td class="col-xs-10">test_delete_departement</td>
<td class="col-xs-1">
<span class="label label-success" style="display:block;width:40px;">Pass</span>
</td>
<td class="col-xs-1">
</td>
</tr>
<tr>
<td colspan="3">
Total: 3, Pass: 3 -- Duration: 39.96 s
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('td').on('click', '.btn', function(e){
e.preventDefault();
e.stopImmediatePropagation();
var $this = $(this);
var $nextRow = $this.closest('tr').next('tr');
$nextRow.slideToggle("fast");
$this.text(function(i, text){
if (text === 'View') {
return 'Hide';
} else {
return 'View';
};
});
});
});
</script>
</body>
</html

8
createDepartement.py

@ -0,0 +1,8 @@
import subprocess
from setting import LINK_SCODOC_SERVER, NOM_DPT
def main():
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()

53
creationSiteDepartement.py

@ -0,0 +1,53 @@
# coding: utf8
import unittest
import time
import subprocess
import HtmlTestRunner
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
BASE_URL,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL,
NAVIGATEUR,
)
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
URL = BASE_URL + NOM_DPT + "/Scolarite"
ACRONYME_FORMATION = "FormationTEST"
def main():
if NAVIGATEUR == "firefox":
driver = webdriver.Firefox()
else:
driver = webdriver.Chrome()
driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
driver.get(BASE_URL + "scodoc_admin")
time.sleep(2)
try:
select = Select(driver.find_element_by_id("CreateDept"))
select.select_by_visible_text(NOM_DPT)
driver.find_element_by_name("DeptId").submit()
time.sleep(1)
driver.find_element_by_id("tf_submit").click()
time.sleep(1)
driver.close()
except NoSuchElementException:
driver.close()

8
deleteDepartement.py

@ -0,0 +1,8 @@
import subprocess
from setting import LINK_SCODOC_SERVER, NOM_DPT
def main():
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()

0
index.html

13
lancement_de_tout_les_tests.sh

@ -1,9 +1,20 @@
#!/bin/bash
#Ce script lance en séquence les différents jeux de tests.
if [ "$#" -ne 2 ]
then
if [ "$1" = "--cleanup" ] || [ "$1" = "--c" ]
then
rm -rf ./ResultatTest/*
else
echo "Mauvaise utilisation de la commande, utilisez --cleanup ou -c pour supprimer les anciens rapport de tests"
fi
fi
python3 01_creation_departement_test.py;
python3 02_creation_formation_test.py;
python3 03_etudiant_test.py;
python3 04_creation_absence_test.py;
python3 05_saisie_note_test.py;
python3 06_test_moyenne.py;
python3 07_test_admission.py
python3 07_test_admission.py;
python3 deleteDepartement.py;
tree -H './ResultatTest' -L 1 --noreport --charset utf-8 > index.html

4
readme.md

@ -74,6 +74,10 @@ Pour lancer les tests, assurez vous d'avoir une connexion possible avec votre se
>python3 01_creation_departement_test.py
Alternativement vous pouvez lancer l'ensemble des tests avec la commande
>./lancement_de_tout_les_tests.sh
###Resultats des tests
###TODO

50
suppressionSiteDepartement.py

@ -0,0 +1,50 @@
# coding: utf8
import unittest
import time
import subprocess
import HtmlTestRunner
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
BASE_URL,
NOM_DPT,
LINK_SCODOC_SERVER,
BASE_NOT_SECURED_URL,
NAVIGATEUR,
)
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
URL = BASE_URL + NOM_DPT + "/Scolarite"
ACRONYME_FORMATION = "FormationTEST"
def main():
if NAVIGATEUR == "firefox":
driver = webdriver.Firefox()
else:
driver = webdriver.Chrome()
driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
driver.get(BASE_URL + "scodoc_admin")
time.sleep(2)
try:
select = Select(driver.find_element_by_id("DeleteDept"))
select.select_by_visible_text(NOM_DPT)
driver.find_element_by_id("DeleteDept").submit()
driver.close()
except NoSuchElementException:
driver.close()
Loading…
Cancel
Save