File size: 1,446 Bytes
2379054 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | """
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"])
|