Skip to content

Commit b612a79

Browse files
fix tests
1 parent db4ee41 commit b612a79

File tree

3 files changed

+76
-48
lines changed

3 files changed

+76
-48
lines changed

src/feelpp/benchmarking/json_report/tests/data/golden/plot_features.adoc

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@
99
1010
<div class='figure-container'>
1111
12-
<div class="subfigure-container active" data-subfigure="1">
13-
<div>
14-
<div>FIGURE</div>
15-
<script></script>
16-
</div>
12+
<div class="subfigure-container active" data-subfigure="1">
13+
<div id="graph-div-<FIGURE_ID>-1"> </div>
1714
<div class='export-container'>
18-
<button class="csv-btn">CSV</button>
19-
<button class="latex-btn">LaTeX</button>
15+
<a href='<ZIPPATH>' download>CSV</a>
2016
</div>
2117
</div>
2218
</div>
2319
20+
21+
<script>
22+
fetch('<JSONPATH>')
23+
.then(response => response.json())
24+
.then(figure_json => {
25+
Plotly.newPlot('graph-div-<FIGURE_ID>-1',figure_json);
26+
})
27+
.catch(err => console.error(err));
28+
</script>
29+
30+
2431
++++
2532
====
2633

@@ -37,32 +44,40 @@
3744
<button class='figure-tab' onclick='switchTab(this, 2)'>stacked_bar</button>
3845
</div>
3946
40-
<div class="subfigure-container active" data-subfigure="1">
41-
<div>
42-
<div>FIGURE</div>
43-
<script></script>
44-
</div>
47+
48+
<div class="subfigure-container active" data-subfigure="1">
49+
<div id="graph-div-<FIGURE_ID>-1"> </div>
4550
<div class='export-container'>
46-
<button>CSV</button>
47-
<button>LaTeX</button>
51+
<a href='<ZIPPATH>' download>CSV</a>
4852
</div>
49-
5053
</div>
5154
52-
<div class="subfigure-container inactive" data-subfigure="2">
53-
<div>
54-
<div>FIGURE</div>
55-
<script></script>
56-
</div>
55+
<div class="subfigure-container inactive" data-subfigure="2">
56+
<div id="graph-div-<FIGURE_ID>-2"> </div>
5757
<div class='export-container'>
58-
<button>CSV</button>
59-
<button>LaTeX</button>
58+
<a href='<ZIPPATH>' download>CSV</a>
6059
</div>
61-
6260
</div>
61+
6362
</div>
6463
6564
65+
<script>
66+
fetch('<JSONPATH>')
67+
.then(response => response.json())
68+
.then(figure_json => {
69+
Plotly.newPlot('graph-div-<FIGURE_ID>-1',figure_json);
70+
})
71+
.catch(err => console.error(err));
72+
fetch('<JSONPATH>')
73+
.then(response => response.json())
74+
.then(figure_json => {
75+
Plotly.newPlot('graph-div-<FIGURE_ID>-2',figure_json);
76+
})
77+
.catch(err => console.error(err));
78+
</script>
79+
80+
6681
++++
6782
====
6883

src/feelpp/benchmarking/json_report/tests/data/golden/report.adoc

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,24 @@ Placeholders in this report allow dynamic insertion of values from the datasets.
101101
102102
<div class='figure-container'>
103103
104-
<div class="subfigure-container active" data-subfigure="1">
105-
<div>
106-
<div>FIGURE</div>
107-
<script></script>
108-
</div>
104+
<div class="subfigure-container active" data-subfigure="1">
105+
<div id="graph-div-<FIGURE_ID>-1"> </div>
109106
<div class='export-container'>
110-
<button class="csv-btn">CSV</button>
111-
<button class="latex-btn">LaTeX</button>
107+
<a href='<ZIPPATH>' download>CSV</a>
112108
</div>
113109
</div>
114110
</div>
115111
112+
113+
<script>
114+
fetch('<JSONPATH>')
115+
.then(response => response.json())
116+
.then(figure_json => {
117+
Plotly.newPlot('graph-div-<FIGURE_ID>-1',figure_json);
118+
})
119+
.catch(err => console.error(err));
120+
</script>
121+
116122
++++
117123
====
118124

@@ -123,18 +129,24 @@ Placeholders in this report allow dynamic insertion of values from the datasets.
123129
124130
<div class='figure-container'>
125131
126-
<div class="subfigure-container active" data-subfigure="1">
127-
<div>
128-
<div>FIGURE</div>
129-
<script></script>
130-
</div>
132+
<div class="subfigure-container active" data-subfigure="1">
133+
<div id="graph-div-<FIGURE_ID>-1"> </div>
131134
<div class='export-container'>
132-
<button class="csv-btn">CSV</button>
133-
<button class="latex-btn">LaTeX</button>
135+
<a href='<ZIPPATH>' download>CSV</a>
134136
</div>
135137
</div>
136138
</div>
137139
140+
141+
<script>
142+
fetch('<JSONPATH>')
143+
.then(response => response.json())
144+
.then(figure_json => {
145+
Plotly.newPlot('graph-div-<FIGURE_ID>-1',figure_json);
146+
})
147+
.catch(err => console.error(err));
148+
</script>
149+
138150
++++
139151
====
140152

src/feelpp/benchmarking/json_report/tests/test_jsonReport.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ def normalizeReport(content: str) -> str:
88
content = re.sub( r"^:docdatetime: .*?$", ":docdatetime: <TIMESTAMP>", content, flags=re.MULTILINE )
99

1010
content = re.sub(
11-
r"<button[^>]*?>\s*(.*?)\s*</button>",
12-
lambda match : f"<button>{match.group(1).strip()}</button>",
11+
r"graph-div-.*?-",
12+
"<FIGURE_ID>",
1313
content, flags=re.DOTALL
1414
)
1515
content = re.sub(
16-
r"<div[^>]*>\s*<div[^>]*></div>\s*<script.*?</script>\s*</div>",
17-
"""
18-
<div>
19-
<div>FIGURE</div>
20-
<script></script>
21-
</div>""",
22-
content,
23-
flags=re.DOTALL
16+
r"<a href='.*?' download>CSV</a>",
17+
"<ZIPPATH>",
18+
content, flags=re.DOTALL
2419
)
20+
content = re.sub(
21+
r"fetch\('.*?'\)",
22+
"<JSONPATH>",
23+
content, flags=re.DOTALL
24+
)
25+
2526

2627
lines = [line.rstrip() for line in content.splitlines() if line.strip()]
2728
return "\n".join(lines)
@@ -54,6 +55,6 @@ def test_jsonReportCases(report_filename,output_format="adoc"):
5455
)
5556

5657
with tempfile.TemporaryDirectory() as tmpdir:
57-
output_file = controller.render(output_dirpath=os.path.join(data_dir,"outputs"))
58+
output_file = controller.render(output_dirpath=os.path.join(data_dir,tmpdir))
5859
golden_file = os.path.join(data_dir,"golden",report_filename.replace(".json",f".{output_format}"))
5960
assert_report_matches_golden(output_file,golden_file)

0 commit comments

Comments
 (0)