flowmarg / tests /test_excel_export.py
akash
Deploy to Hugging Face (source code only, no binary files)
2379054
Raw History Blame Contribute Delete
1.45 kB
"""
TEST SUITE - core/excel_export.py
Tests Excel export functionality
"""
import pytest
import pandas as pd
from pathlib import Path
from core.excel_export import (
fmt_cell,
add_professional_disclaimer,
add_version_footer,
write_workbook
)
class TestExcelExport:
"""Test Excel export functions"""
def test_fmt_cell_number_formatting(self):
# Test chainage formatting
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
cell = ws.cell(1, 1, 1000.5)
fmt_cell(cell, "Chainage")
assert cell.number_format == "0.###"
def test_fmt_cell_mm_formatting(self):
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
cell = ws.cell(1, 1, 25.0)
fmt_cell(cell, "Lift (mm)")
assert cell.number_format == "0"
def test_fmt_cell_level_formatting(self):
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
cell = ws.cell(1, 1, 12.345)
fmt_cell(cell, "Level (m)")
assert cell.number_format == "0.000"
def test_fmt_cell_nan(self):
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
cell = ws.cell(1, 1, float('nan'))
fmt_cell(cell, "Chainage")
assert cell.number_format == "0.###" # Should handle gracefully
if __name__ == "__main__":
pytest.main([__file__, "-v"])