Download tests/test_excel_export.py from Surajnitp/flowmarg: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/Surajnitp/flowmarg/resolve/main/tests/test_excel_export.py
- Command line
-
hf download hf://spaces/Surajnitp/flowmarg/tests/test_excel_export.py
-
curl -L -o test_excel_export.py https://huggingface.co/spaces/Surajnitp/flowmarg/resolve/main/tests/test_excel_export.py
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"]) | |