mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-08-25 23:11:14 +00:00
Add more optimization tests (#171)
* 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>
This commit is contained in:
committed by
GitHub
parent
de9fe2ddc9
commit
3652298134
30
tests/test_visualize.py
Normal file
30
tests/test_visualize.py
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
)
|
Reference in New Issue
Block a user