ajout d'ouput sous forme html pour les tests

This commit is contained in:
Aurélien Plancke 2021-06-23 14:27:05 +02:00
parent 4ead3eb9f3
commit 1c8bccbf41
11 changed files with 266 additions and 35 deletions

View File

@ -2,6 +2,7 @@
import unittest import unittest
import time import time
import subprocess import subprocess
import HtmlTestRunner
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
@ -82,4 +83,4 @@ if __name__ == "__main__":
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, "TESTCREATEDPT"] cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, "TESTCREATEDPT"]
process = subprocess.Popen(cmdProcess) process = subprocess.Popen(cmdProcess)
process.wait() process.wait()
unittest.main() unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

View File

@ -2,6 +2,7 @@
import unittest import unittest
import time import time
import subprocess import subprocess
import HtmlTestRunner
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
@ -118,17 +119,14 @@ class PythonOrgSearch(unittest.TestCase):
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
self.wait.until(EC.url_changes(URL)) self.wait.until(EC.url_changes(URL))
driver.find_element_by_xpath("//a[contains(@href,'ue_create?')]").click() driver.find_element_by_xpath("//a[contains(@href,'ue_create?')]").click()
driver.find_element_by_id('tf_titre').send_keys("UE TEST") driver.find_element_by_id("tf_titre").send_keys("UE TEST")
driver.find_element_by_id('tf_acronyme').send_keys("TEST") driver.find_element_by_id("tf_acronyme").send_keys("TEST")
driver.find_element_by_id('tf_submit').click() driver.find_element_by_id("tf_submit").click()
time.sleep(1) time.sleep(1)
driver.get(URL) driver.get(URL)
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
self.wait.until(EC.url_changes(URL)) self.wait.until(EC.url_changes(URL))
self.assertTrue( self.assertTrue("TEST UE TEST" in driver.page_source)
"TEST UE TEST"
in driver.page_source
)
driver.get(URL) driver.get(URL)
self.assertTrue((NOM_DPT.upper() + "-" + "DUT" + "--") in driver.page_source) self.assertTrue((NOM_DPT.upper() + "-" + "DUT" + "--") in driver.page_source)
@ -140,16 +138,19 @@ class PythonOrgSearch(unittest.TestCase):
global URL global URL
nomMat = "unematieretest" nomMat = "unematieretest"
driver.get(URL) driver.get(URL)
time.sleep(3)
idTitre = "titre_" + ACRONYME_FORMATION idTitre = "titre_" + ACRONYME_FORMATION
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
self.wait.until(EC.url_changes(URL)) self.wait.until(EC.url_changes(URL))
time.sleep(3)
driver.find_element_by_xpath("//a[contains(@href,'matiere_create?')]").click() driver.find_element_by_xpath("//a[contains(@href,'matiere_create?')]").click()
driver.find_element_by_id('tf_titre').send_keys(nomMat) driver.find_element_by_id("tf_titre").send_keys(nomMat)
driver.find_element_by_id('tf_numero').send_keys("1") driver.find_element_by_id("tf_numero").send_keys("1")
driver.find_element_by_id('tf_submit').click() driver.find_element_by_id("tf_submit").click()
time.sleep(1) time.sleep(3)
driver.get(URL) driver.get(URL)
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
time.sleep(3)
self.wait.until(EC.url_changes(URL)) self.wait.until(EC.url_changes(URL))
elements = driver.find_elements_by_xpath("//a[contains(@href,'matiere_edit?')]") elements = driver.find_elements_by_xpath("//a[contains(@href,'matiere_edit?')]")
matIsPresent = False matIsPresent = False
@ -180,6 +181,7 @@ class PythonOrgSearch(unittest.TestCase):
driver.get(URL) driver.get(URL)
self.assertTrue((NOM_DPT.upper() + "-" + "DUT" + "--") in driver.page_source) self.assertTrue((NOM_DPT.upper() + "-" + "DUT" + "--") in driver.page_source)
# Test : Dupplique une formation sous une nouvelle version # Test : Dupplique une formation sous une nouvelle version
# @expected : La formation est dupliquée et à la version "2" # @expected : La formation est dupliquée et à la version "2"
def test_017_creer_nouvelle_version_formation(self): def test_017_creer_nouvelle_version_formation(self):
@ -190,16 +192,19 @@ class PythonOrgSearch(unittest.TestCase):
driver.find_element_by_id(idTitre).click() driver.find_element_by_id(idTitre).click()
self.wait.until(EC.url_changes(URL)) self.wait.until(EC.url_changes(URL))
tmpurl = driver.current_url tmpurl = driver.current_url
driver.find_element_by_xpath("//a[contains(@href,'formation_create_new_version?')]").click() driver.find_element_by_xpath(
"//a[contains(@href,'formation_create_new_version?')]"
).click()
self.wait.until(EC.url_changes(tmpurl)) self.wait.until(EC.url_changes(tmpurl))
self.assertTrue("Nouvelle version !" in driver.page_source) self.assertTrue("Nouvelle version !" in driver.page_source)
driver.get(URL) driver.get(URL)
elements = driver.find_elements_by_class_name("version") elements = driver.find_elements_by_class_name("version")
versionIsPresent = False versionIsPresent = False
for element in elements: for element in elements:
if element.text == '2': if element.text == "2":
versionIsPresent = True versionIsPresent = True
self.assertTrue(versionIsPresent) self.assertTrue(versionIsPresent)
# Test : Supprime une formation après avoir supprimé les semestres qui y sont rattachés # Test : Supprime une formation après avoir supprimé les semestres qui y sont rattachés
# @expected : La formation n'apparait plus dans le tableau des formations # @expected : La formation n'apparait plus dans le tableau des formations
def test_020_delete_formation(self): def test_020_delete_formation(self):
@ -247,10 +252,10 @@ class PythonOrgSearch(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main()
cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT] cmdProcess = ["./scriptDeleteDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess) process = subprocess.Popen(cmdProcess)
process.wait() process.wait()
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
process = subprocess.Popen(cmdProcess)
process.wait()
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

View File

@ -1,5 +1,6 @@
import unittest import unittest
import time import time
import HtmlTestRunner
import subprocess import subprocess
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
@ -186,4 +187,4 @@ if __name__ == "__main__":
] ]
process = subprocess.Popen(cmdProcess) process = subprocess.Popen(cmdProcess)
process.wait() process.wait()
unittest.main() unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

View File

@ -2,6 +2,7 @@ import unittest
import time import time
import urllib.parse as urlparse import urllib.parse as urlparse
import subprocess import subprocess
import HtmlTestRunner
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
@ -161,4 +162,4 @@ if __name__ == "__main__":
] ]
process = subprocess.Popen(cmdProcess) process = subprocess.Popen(cmdProcess)
process.wait() process.wait()
unittest.main() unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

View File

@ -2,6 +2,7 @@ import unittest
import time import time
import subprocess import subprocess
import urllib.parse as urlparse import urllib.parse as urlparse
import HtmlTestRunner
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
@ -388,4 +389,4 @@ if __name__ == "__main__":
driver.find_element_by_id("tf_submit").click() driver.find_element_by_id("tf_submit").click()
driver.find_element_by_id("utilisateurs_Vue").click() driver.find_element_by_id("utilisateurs_Vue").click()
driver.close() driver.close()
unittest.main(warnings="ignore") unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

View File

@ -2,6 +2,7 @@ import unittest
import time import time
import subprocess import subprocess
import urllib.parse as urlparse import urllib.parse as urlparse
import HtmlTestRunner
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
@ -442,4 +443,4 @@ if __name__ == "__main__":
] ]
process = subprocess.Popen(cmdProcess) process = subprocess.Popen(cmdProcess)
process.wait() process.wait()
unittest.main(warnings="ignore") unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

View File

@ -2,6 +2,7 @@ import unittest
import time import time
import subprocess import subprocess
import urllib.parse as urlparse import urllib.parse as urlparse
import HtmlTestRunner
from setting import ( from setting import (
SCODOC_ADMIN_ID, SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS, SCODOC_ADMIN_PASS,
@ -229,4 +230,4 @@ if __name__ == "__main__":
] ]
process = subprocess.Popen(cmdProcess) process = subprocess.Popen(cmdProcess)
process.wait() process.wait()
unittest.main(warnings="ignore") unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="./output"))

View File

@ -589,28 +589,22 @@ test48:
page: *Notes page: *Notes
champsModifie: null champsModifie: null
champsInteractions: champsInteractions:
[ [id:tf_titre, id:tf_acronyme, id:tf_submit, link:ue_create]
id:tf_titre,
id:tf_acronyme,
id:tf_submit,
link:ue_create
]
role: *AdminDPT role: *AdminDPT
createur: Aurélien createur: Aurélien
test49: test49:
intitulé: Ajout d'une matière à l'UE créée intitulé: Ajout d'une matière à la formation créée
operation: Soumettre le formulaire d'ajout de matière operation: Soumettre le formulaire d'ajout de matière
resultat: La page sur laquelle on est dirigée contient la classe notes_matiere_list et un de ses enfants contient Systeme resultat: La page sur laquelle on est dirigée contient la classe notes_matiere_list et l'intitulé de la matière est présent
etat: *MatiereCreated etat: *MatiereCreated
page: *Notes page: *Notes
champsModifie: null champsModifie: null
champsInteractions: champsInteractions: [
[
id:tf_titre, id:tf_titre,
id:tf_acronyme, id:tf_acronyme,
id:tf_submit, id:tf_submit,
link:matiere_create link:matiere_create
link:matiere_edit link:matiere_edit,
] ]
role: *AdminDPT role: *AdminDPT
createur: Aurélien createur: Aurélien

View File

@ -0,0 +1,142 @@
<!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-23 13:51:43</p>
<p class='attribute'><strong>Duration: </strong>137.89 s</p>
<p class='attribute'><strong>Summary: </strong>Total: 8, Pass: 6, Fail: 2</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_011_create_formation</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_012_change_name_formation</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_013_same_name_formation</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='danger'>
<td class="col-xs-10">test_014_ajout_UE</td>
<td class="col-xs-1">
<span class="label label-danger" style="display:block;width:40px;">Fail</span>
</td>
<td class="col-xs-1">
<button class="btn btn-default btn-xs">View</button>
</td>
</tr>
<tr style="display:none;">
<td class="col-xs-9" colspan="3"><p style="color:maroon;">AssertionError: False is not true</p><p style="color:maroon;">Traceback (most recent call last):
File "/home/aurelien/Bureau/pythonSelenium/02_creation_formation_test.py", line 132, in test_014_ajout_UE
self.assertTrue((NOM_DPT.upper() + "-" + "DUT" + "--") in driver.page_source)
AssertionError: False is not true
</p>
</td>
</tr>
<tr class='success'>
<td class="col-xs-10">test_015_ajout_matiere</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_016_ajout_Semestre</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_017_creer_nouvelle_version_formation</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='danger'>
<td class="col-xs-10">test_020_delete_formation</td>
<td class="col-xs-1">
<span class="label label-danger" style="display:block;width:40px;">Fail</span>
</td>
<td class="col-xs-1">
<button class="btn btn-default btn-xs">View</button>
</td>
</tr>
<tr style="display:none;">
<td class="col-xs-9" colspan="3"><p style="color:maroon;">AssertionError: False is not true</p><p style="color:maroon;">Traceback (most recent call last):
File "/home/aurelien/Bureau/pythonSelenium/02_creation_formation_test.py", line 241, in test_020_delete_formation
self.assertTrue(False)
AssertionError: False is not true
</p>
</td>
</tr>
<tr>
<td colspan="3">
Total: 8, Pass: 6, Fail: 2 -- Duration: 137.89 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

View File

@ -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-23 14:11:52</p>
<p class='attribute'><strong>Duration: </strong>56.95 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: 56.95 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

View File