import sys
import unittest
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from normaliza import normalizar_html


class NormalizaTest(unittest.TestCase):
    def test_remove_csrf(self):
        self.assertEqual(
            normalizar_html('<input type="hidden" name="_csrf" value="abc">'),
            normalizar_html('<input type="hidden" name="_csrf" value="xyz">'),
        )

    def test_remove_meta_csrf(self):
        self.assertEqual(
            normalizar_html('<meta name="csrf-token" content="aaa">'),
            normalizar_html('<meta name="csrf-token" content="bbb">'),
        )

    def test_remove_datahora(self):
        self.assertEqual(
            normalizar_html("<p>22/10/2026 10:11:12</p>"),
            normalizar_html("<p>23/10/2026 09:00:00</p>"),
        )

    def test_remove_hash_assets(self):
        self.assertEqual(
            normalizar_html('<script src="/assets/a1b2c3d4/jquery.js?v=1700000000"></script>'),
            normalizar_html('<script src="/assets/ffee9988/jquery.js?v=1800000000"></script>'),
        )

    def test_mantem_conteudo(self):
        self.assertNotEqual(normalizar_html("<td>Valor 10</td>"), normalizar_html("<td>Valor 11</td>"))


if __name__ == "__main__":
    unittest.main()
