From 44812b926d34759c420e17bbe0de921cbb547b52 Mon Sep 17 00:00:00 2001 From: "Andrew Speciale (@liquidz00)" Date: Wed, 11 Sep 2024 17:53:17 -0400 Subject: [PATCH] Fix unit tests to anticipate Exception --- tests/test_excel_report.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_excel_report.py b/tests/test_excel_report.py index 01bc52b..f401e90 100644 --- a/tests/test_excel_report.py +++ b/tests/test_excel_report.py @@ -2,7 +2,9 @@ from unittest.mock import patch import pandas as pd +import pytest from src.patcher.models.reports.excel_report import ExcelReport +from src.patcher.utils.exceptions import ExportError def test_export_to_excel_success(sample_patch_reports, temp_output_dir): @@ -28,6 +30,9 @@ def test_export_to_excel_dataframe_creation_error(temp_output_dir): excel_report = ExcelReport() with patch.object(pd, "DataFrame", side_effect=ValueError("Test Error")): - excel_path = excel_report.export_to_excel([], temp_output_dir) + with pytest.raises(ExportError) as excinfo: + excel_report.export_to_excel([], temp_output_dir) - assert excel_path is None + assert "Error exporting data - file_path: Error creating DataFrame: Test Error" in str( + excinfo.value + )