Run ruff format changes and finalize indentation and lint fixes.
This commit is contained in:
@@ -8,10 +8,7 @@ from pathlib import Path
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
import pandas as pd
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
from src.export_manager import ExportManager
|
||||
from thechart.export import ExportManager
|
||||
|
||||
|
||||
class TestExportManager:
|
||||
@@ -212,8 +209,8 @@ class TestExportManager:
|
||||
"No data available to update graph for export"
|
||||
)
|
||||
|
||||
@patch('src.export_manager.ExportManager._save_graph_as_image')
|
||||
@patch('src.export_manager.SimpleDocTemplate')
|
||||
@patch('thechart.export.export_manager.ExportManager._save_graph_as_image')
|
||||
@patch('thechart.export.export_manager.SimpleDocTemplate')
|
||||
def test_export_to_pdf_success(self, mock_doc, mock_save_graph, export_manager):
|
||||
"""Test successful PDF export."""
|
||||
# Mock graph image saving
|
||||
@@ -241,8 +238,8 @@ class TestExportManager:
|
||||
if os.path.exists(temp_path):
|
||||
os.unlink(temp_path)
|
||||
|
||||
@patch('src.export_manager.ExportManager._save_graph_as_image')
|
||||
@patch('src.export_manager.SimpleDocTemplate')
|
||||
@patch('thechart.export.export_manager.ExportManager._save_graph_as_image')
|
||||
@patch('thechart.export.export_manager.SimpleDocTemplate')
|
||||
def test_export_to_pdf_no_graph(self, mock_doc, mock_save_graph, export_manager):
|
||||
"""Test PDF export without graph."""
|
||||
# Mock document building
|
||||
@@ -262,7 +259,7 @@ class TestExportManager:
|
||||
if os.path.exists(temp_path):
|
||||
os.unlink(temp_path)
|
||||
|
||||
@patch('src.export_manager.SimpleDocTemplate')
|
||||
@patch('thechart.export.export_manager.SimpleDocTemplate')
|
||||
def test_export_to_pdf_empty_data(self, mock_doc, export_manager):
|
||||
"""Test PDF export with empty data."""
|
||||
export_manager.data_manager.load_data.return_value = pd.DataFrame()
|
||||
@@ -283,7 +280,7 @@ class TestExportManager:
|
||||
if os.path.exists(temp_path):
|
||||
os.unlink(temp_path)
|
||||
|
||||
@patch('src.export_manager.SimpleDocTemplate')
|
||||
@patch('thechart.export.export_manager.SimpleDocTemplate')
|
||||
def test_export_to_pdf_exception(self, mock_doc, export_manager):
|
||||
"""Test PDF export with exception."""
|
||||
# Mock document building to raise exception
|
||||
@@ -330,9 +327,8 @@ class TestExportManagerIntegration:
|
||||
@pytest.fixture
|
||||
def real_data_manager(self, temp_csv_file, mock_logger):
|
||||
"""Create a data manager with real test data."""
|
||||
from src.medicine_manager import MedicineManager
|
||||
from src.pathology_manager import PathologyManager
|
||||
from src.data_manager import DataManager
|
||||
from thechart.managers import MedicineManager, PathologyManager
|
||||
from thechart.data import DataManager
|
||||
|
||||
# Create managers with real data
|
||||
medicine_manager = MedicineManager(logger=mock_logger)
|
||||
@@ -358,9 +354,8 @@ class TestExportManagerIntegration:
|
||||
"""Create a real graph manager for testing."""
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
from src.graph_manager import GraphManager
|
||||
from src.medicine_manager import MedicineManager
|
||||
from src.pathology_manager import PathologyManager
|
||||
from thechart.analytics import GraphManager
|
||||
from thechart.managers import MedicineManager, PathologyManager
|
||||
|
||||
# Create minimal tkinter setup
|
||||
root = tk.Tk()
|
||||
@@ -430,7 +425,7 @@ class TestExportManagerIntegration:
|
||||
|
||||
try:
|
||||
# Mock the SimpleDocTemplate to verify landscape format
|
||||
with patch('src.export_manager.SimpleDocTemplate') as mock_doc:
|
||||
with patch('thechart.export.export_manager.SimpleDocTemplate') as mock_doc:
|
||||
mock_doc_instance = Mock()
|
||||
mock_doc.return_value = mock_doc_instance
|
||||
|
||||
@@ -467,11 +462,11 @@ class TestExportManagerIntegration:
|
||||
|
||||
try:
|
||||
# Mock Table to verify column widths and styling
|
||||
with patch('src.export_manager.Table') as mock_table:
|
||||
with patch('thechart.export.export_manager.Table') as mock_table:
|
||||
mock_table_instance = Mock()
|
||||
mock_table.return_value = mock_table_instance
|
||||
|
||||
with patch('src.export_manager.SimpleDocTemplate') as mock_doc:
|
||||
with patch('thechart.export.export_manager.SimpleDocTemplate') as mock_doc:
|
||||
mock_doc_instance = Mock()
|
||||
mock_doc.return_value = mock_doc_instance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user