mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
* Integrated single_test_optimization into pytest to run a basic optimization test with tolerance set to 1e-6, ensuring quick detection of deviations. * Added a long-run test (400 generations, like single_test_optimization), which can be triggered using --full-run in pytest. * Mocked PDF creation in optimization tests and added a new PDF generation test with image comparison validation. Note: Current tolerance is set to 1e-6; feedback on whether this tolerance is tight enough is welcome. --------- Co-authored-by: Normann <github@koldrack.com> Co-authored-by: Michael Osthege <michael.osthege@outlook.com>
31 lines
861 B
Python
31 lines
861 B
Python
import json
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from matplotlib.testing.compare import compare_images
|
|
|
|
from akkudoktoreos.visualize import visualisiere_ergebnisse
|
|
|
|
DIR_TESTDATA = Path(__file__).parent / "testdata"
|
|
DIR_IMAGEDATA = DIR_TESTDATA / "images"
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"fn_in, fn_out, fn_out_base",
|
|
[("visualize_input_1.json", "visualize_output_1.pdf", "visualize_base_output_1.pdf")],
|
|
)
|
|
@patch("akkudoktoreos.visualize.output_dir", DIR_IMAGEDATA)
|
|
def test_visualisiere_ergebnisse(fn_in, fn_out, fn_out_base):
|
|
with open(DIR_TESTDATA / fn_in, "r") as f:
|
|
input_data = json.load(f)
|
|
visualisiere_ergebnisse(**input_data)
|
|
assert (
|
|
compare_images(
|
|
str(DIR_IMAGEDATA / fn_out),
|
|
str(DIR_IMAGEDATA / fn_out_base),
|
|
0,
|
|
)
|
|
is None
|
|
)
|