forked from dlubal-software/RSTAB_Python_Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_Reports.py
More file actions
71 lines (58 loc) · 2.73 KB
/
Copy pathtest_Reports.py
File metadata and controls
71 lines (58 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import sys
import os
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.pardir)
)
sys.path.append(PROJECT_ROOT)
from RSTAB.Reports.printoutReport import PrintoutReport
from RSTAB.Reports.html import ExportResultTablesToHtml
from RSTAB.initModel import Model, closeModel, openFile
from RSTAB.connectionGlobals import url
from tools import getPathToRunningRSTAB
from shutil import rmtree
import pytest
import time
if Model.clientModel is None:
Model()
@pytest.mark.skipif(url != 'http://127.0.0.1', reason="This test fails on remote PC due to incorrect file path. \
Althought it is easy to change, it would not be easy to update on every remote computer.\
It is not necessary to evaluate Client as functional. Localy this tests still gets executed.")
def test_html_report():
Model.clientModel.service.delete_all()
Model.clientModel.service.run_script(os.path.join(getPathToRunningRSTAB(), 'scripts\\internal\\Demos\\Demo-002 Cantilever Beams.js'))
Model.clientModel.service.calculate_all(False)
dirname = os.path.join(os.getcwd(), os.path.dirname(__file__))
folderPath = os.path.join(dirname, 'testResults')
# Remove any previous results if they exist
if os.path.isdir(folderPath):
rmtree(folderPath)
ExportResultTablesToHtml(folderPath, False)
assert os.path.exists(folderPath)
@pytest.mark.skipif(url != 'http://127.0.0.1', reason="This test fails on remote PC due to incorrect file path. \
Althought it is easy to change, it would not be easy to update on every remote computer.\
It is not necessary to evaluate Client as functional. Localy this tests still gets executed.")
def test_printout_report():
# Remove any previous results if they exist
dirname = os.path.join(os.getcwd(), os.path.dirname(__file__))
folderPath = os.path.join(dirname, 'testResults')
if not os.path.isdir(folderPath):
os.mkdir(folderPath)
htmlPath = os.path.join(folderPath, 'printout.html')
pdfPath = os.path.join(folderPath, 'printout.pdf')
if os.path.exists(htmlPath):
os.remove(htmlPath)
if os.path.exists(pdfPath):
os.remove(pdfPath)
if os.path.isdir(os.path.join(folderPath, 'printout_data')):
rmtree(os.path.join(folderPath, 'printout_data'))
openFile(os.path.join(dirname, 'src', 'printout.rs9'))
PrintoutReport.delete(3)
assert len(PrintoutReport.getList()) == 2
PrintoutReport.exportToHTML(1, htmlPath)
PrintoutReport.exportToPDF(2, pdfPath)
time.sleep(2)
assert os.path.exists(htmlPath)
#assert os.path.exists(pdfPath) # this check creates timeouts often
closeModel('printout.rs9')
time.sleep(1)