Skip to content

Commit

Permalink
Fix unit tests to anticipate Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz00 committed Sep 11, 2024
1 parent b924cd7 commit 44812b9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/test_excel_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
)

0 comments on commit 44812b9

Please sign in to comment.