"""Tests à blanc du pont (aucun appel RCON ni IA) : python3 -m unittest test_mind_chat""" import json, unittest import mind_chat as mc UUID = "0f8fad5b-d9cb-469f-a165-70867728950e" class TestPont(unittest.TestCase): def test_ligne_du_mod(self): ligne = f"[22:14:49] [Server thread/INFO] [co.ga.GastinelMind/]: [GastinelMind] DEMANDE totoche10 {UUID} :: comment faire du pain ?\n" self.assertEqual(mc.analyser(ligne), ("totoche10", UUID, "comment faire du pain ?")) def test_texte_avec_separateur(self): ligne = f"[GastinelMind] DEMANDE Bob_1 {UUID} :: a :: b" self.assertEqual(mc.analyser(ligne)[2], "a :: b") def test_chat_public_ignore(self): self.assertIsNone(mc.analyser("[22:00:00] [Server thread/INFO] [minecraft/MinecraftServer]: salut Mind")) self.assertIsNone(mc.analyser("[22:00:00] [Server thread/INFO] [minecraft/MinecraftServer]: [GastinelMind] DEMANDE")) def test_tellraw_json_valide(self): cmd = mc.commande_chuchotement("totoche10", 'Il faut 3 "blés"\net du {pain} \\ ok') self.assertTrue(cmd.startswith("tellraw totoche10 ")) comp = json.loads(cmd[len("tellraw totoche10 "):]) self.assertEqual(comp["color"], "gray") self.assertTrue(comp["italic"]) self.assertEqual(comp["text"], 'Mind vous chuchote : Il faut 3 "blés" et du {pain} \\ ok') if __name__ == "__main__": unittest.main()