| import unittest | |
| from app import normalizar_texto, extrair_texto | |
| import os | |
| class TestUnit(unittest.TestCase): | |
| def test_normalizar_texto(self): | |
| self.assertEqual(normalizar_texto("Olá Mundo!"), "ola mundo") | |
| self.assertEqual(normalizar_texto("Ação e Reação"), "acao e reacao") | |
| self.assertEqual(normalizar_texto(""), "") | |
| self.assertEqual(normalizar_texto(None), "") | |
| def test_extrair_texto_txt(self): | |
| test_file = "test.txt" | |
| with open(test_file, "w", encoding="utf-8") as f: | |
| f.write("Conteúdo de teste") | |
| try: | |
| texto = extrair_texto(test_file) | |
| self.assertEqual(texto, "Conteúdo de teste") | |
| finally: | |
| if os.path.exists(test_file): | |
| os.remove(test_file) | |
| def test_extrair_texto_invalido(self): | |
| resultado = extrair_texto("arquivo_inexistente.pdf") | |
| self.assertTrue(resultado.startswith("Erro ao extrair texto")) | |
| if __name__ == "__main__": | |
| unittest.main() | |