Skip to content

Commit d2354b2

Browse files
committed
adapt tests
1 parent 549cced commit d2354b2

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

tests/fast/test_profiler.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import json
2-
31
import pytest
42

53
import duckdb
6-
from duckdb.query_graph import translate_json_to_html
4+
from duckdb.query_graph import ProfilingInfo
75

86

97
@pytest.fixture(scope="session")
@@ -18,11 +16,12 @@ def profiling_connection():
1816
class TestProfiler:
1917
def test_profiler_matches_expected_format(self, profiling_connection, tmp_path_factory):
2018
# Test String returned
21-
profiling_info_json = profiling_connection.get_profiling_information(format="json")
19+
profiling_info = ProfilingInfo(profiling_connection)
20+
profiling_info_json = profiling_info.to_json()
2221
assert isinstance(profiling_info_json, str)
2322

2423
# Test expected metrics are there and profiling is json loadable
25-
profiling_dict = json.loads(profiling_info_json)
24+
profiling_dict = profiling_info.to_pydict()
2625
expected_keys = {
2726
"query_name",
2827
"total_bytes_written",
@@ -39,10 +38,10 @@ def test_profiler_matches_expected_format(self, profiling_connection, tmp_path_f
3938
"blocked_thread_time",
4039
"children",
4140
}
42-
assert profiling_dict.keys() == expected_keys
41+
assert expected_keys.issubset(profiling_dict.keys())
4342

4443
def test_profiler_html_output(self, profiling_connection, tmp_path_factory):
4544
tmp_dir = tmp_path_factory.mktemp("profiler", numbered=True)
46-
profiling_info_json = profiling_connection.get_profiling_information(format="json")
45+
profiling_info = ProfilingInfo(profiling_connection)
4746
# Test HTML execution works, nothing to assert!
48-
translate_json_to_html(input_text=profiling_info_json, output_file=f"{tmp_dir}/profiler_output.html")
47+
profiling_info.to_html(output_file=f"{tmp_dir}/profiler_output.html")

0 commit comments

Comments
 (0)