2024-11-10 23:22:30 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from matplotlib.testing.compare import compare_images
|
|
|
|
|
2024-12-29 18:42:49 +01:00
|
|
|
from akkudoktoreos.utils.visualize import generate_example_report
|
2024-12-24 13:10:31 +01:00
|
|
|
|
|
|
|
filename = "example_report.pdf"
|
|
|
|
|
2024-11-10 23:22:30 +01:00
|
|
|
|
|
|
|
DIR_TESTDATA = Path(__file__).parent / "testdata"
|
2024-12-24 13:10:31 +01:00
|
|
|
reference_file = DIR_TESTDATA / "test_example_report.pdf"
|
|
|
|
|
|
|
|
|
2024-12-30 13:41:39 +01:00
|
|
|
def test_generate_pdf_example(config_eos):
|
2024-12-29 18:42:49 +01:00
|
|
|
"""Test generation of example visualization report."""
|
2025-01-12 05:19:37 +01:00
|
|
|
output_dir = config_eos.general.data_output_path
|
2024-12-30 13:41:39 +01:00
|
|
|
assert output_dir is not None
|
|
|
|
output_file = output_dir / filename
|
|
|
|
assert not output_file.exists()
|
2024-12-24 13:10:31 +01:00
|
|
|
|
2024-12-30 13:41:39 +01:00
|
|
|
# Generate PDF
|
|
|
|
generate_example_report()
|
2024-12-24 13:10:31 +01:00
|
|
|
|
|
|
|
# Check if the file exists
|
2024-12-30 13:41:39 +01:00
|
|
|
assert output_file.exists()
|
2024-12-24 13:10:31 +01:00
|
|
|
|
|
|
|
# Compare the generated file with the reference file
|
|
|
|
comparison = compare_images(str(reference_file), str(output_file), tol=0)
|
|
|
|
|
|
|
|
# Assert that there are no differences
|
|
|
|
assert comparison is None, f"Images differ: {comparison}"
|