|
2 | 2 | from unittest.mock import Mock, patch |
3 | 3 |
|
4 | 4 | import numpy as np |
| 5 | +import pytest |
5 | 6 | from bokeh.plotting import figure |
6 | 7 |
|
7 | 8 | from giskard.rag import QATestset, RAGReport |
@@ -98,34 +99,13 @@ def test_report_plots(): |
98 | 99 | assert len(histograms["Question"]["simple"]) == 4 |
99 | 100 |
|
100 | 101 |
|
101 | | -def test_report_to_html_with_embed(): |
102 | | - """Test that to_html works correctly with embed=True parameter.""" |
| 102 | +@pytest.mark.parametrize("embed", [False, True]) |
| 103 | +def test_report_to_html(embed): |
| 104 | + """Test that to_html works correctly with different embed parameter values.""" |
103 | 105 | testset, answers, metrics_results = _create_test_data() |
104 | | - knowledge_base = Mock() |
105 | | - |
106 | | - report = RAGReport(testset, answers, metrics_results, knowledge_base) |
107 | | - |
108 | | - # Test to_html with embed=False (default behavior) |
109 | | - html_output = report.to_html(embed=False) |
110 | | - assert html_output is not None |
111 | | - assert isinstance(html_output, str) |
112 | | - assert html_output.startswith("<!DOCTYPE html>") |
113 | 106 |
|
114 | | - # Test to_html with embed=True |
115 | | - embedded_output = report.to_html(embed=True) |
116 | | - assert embedded_output is not None |
117 | | - |
118 | | - # When embed=True, it should return an IPython HTML display object |
119 | | - from IPython.core.display import HTML |
120 | | - |
121 | | - assert isinstance(embedded_output, HTML) |
122 | | - |
123 | | - # The embedded output should contain an iframe with the escaped HTML content |
124 | | - iframe_html = embedded_output.data |
125 | | - assert "<iframe" in iframe_html |
126 | | - assert "srcdoc=" in iframe_html |
127 | | - assert "width=100%" in iframe_html |
128 | | - assert "height=800px" in iframe_html |
| 107 | + report = RAGReport(testset, answers, metrics_results) |
| 108 | + report.to_html(embed=embed) |
129 | 109 |
|
130 | 110 |
|
131 | 111 | def test_report_save_load(tmp_path): |
|
0 commit comments