import tempfile import unittest from pathlib import Path from unittest.mock import patch from openpyxl import load_workbook from app import export_plain_workbook class ExportHeaderTests(unittest.TestCase): def test_export_uses_the_same_labels_shown_in_the_interface(self): payload = { "headers": ["Entrada EAV", "RH_VALOR", "LA_PT_PTF", "ENVIO_SEI"], "rows": [], } with tempfile.TemporaryDirectory() as directory: with patch("app.GENERATED_DIR", Path(directory)): output_path = export_plain_workbook(payload) workbook = load_workbook(output_path, read_only=True) try: headers = [cell.value for cell in next(workbook.active.iter_rows())] finally: workbook.close() self.assertEqual( headers, [ "Entrada Equipe", "Valor RH", "Trabalhos", "Envio SEI", "Comentários das Células", ], ) if __name__ == "__main__": unittest.main()