Skip to content

Commit 466c873

Browse files
committed
final touch up
1 parent 9f5ed93 commit 466c873

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tests/system/small/test_run_and_publish_benchmark.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,39 @@
1515
from pathlib import Path
1616
import sys
1717

18-
from scripts import run_and_publish_benchmark
19-
18+
# Add the project root to the Python path to allow for application-specific imports.
2019
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
2120

21+
from scripts import run_and_publish_benchmark # noqa: E402
22+
23+
24+
def test_collect_benchmark_result(tmp_path: Path):
25+
"""Tests the collect_benchmark_result function.
26+
27+
This test verifies that the function correctly reads benchmark result
28+
files from a specified directory, processes them, and returns a
29+
pandas DataFrame with the expected data and types.
2230
23-
def test_collect_benchmark_result(tmp_path):
24-
# Create dummy log files
31+
Args:
32+
tmp_path (Path): The pytest fixture providing a temporary directory path.
33+
"""
34+
# Arrange: Create dummy log files with benchmark data.
2535
(tmp_path / "benchmark1.bytesprocessed").write_text("100")
2636
(tmp_path / "benchmark1.slotmillis").write_text("1000")
2737
(tmp_path / "benchmark1.bq_exec_time_seconds").write_text("1.0")
2838
(tmp_path / "benchmark1.local_exec_time_seconds").write_text("2.0")
2939
(tmp_path / "benchmark1.query_char_count").write_text("50")
3040
(tmp_path / "benchmark1.totalrows").write_text("10")
3141

32-
# Collect the benchmark results
42+
# Act: Collect the benchmark results from the temporary directory.
43+
# The second argument '1' is a placeholder for the number of runs.
3344
df, error_message = run_and_publish_benchmark.collect_benchmark_result(
3445
str(tmp_path), 1
3546
)
3647

37-
# Assert that the DataFrame is correct
38-
assert error_message is None
39-
assert len(df) == 1
48+
# Assert: Verify the contents and structure of the resulting DataFrame.
49+
assert error_message is None, "Expected no error messages."
50+
assert len(df) == 1, "DataFrame should contain exactly one row."
4051
assert df["Benchmark_Name"][0] == "benchmark1"
4152
assert df["Bytes_Processed"][0] == 100
4253
assert df["Slot_Millis"][0] == 1000

0 commit comments

Comments
 (0)