def test_bad_messages(self): result = list(Message.prepare_message("a\n" * (MAX_LENGHT // 2))) for r in result: self.check(r) self.assertEqual(len(result), 1) result = Message.prepare_message("a" * (MAX_LENGHT * 3)) for r in result: self.check(r) result = list(Message.prepare_message("a " * int(MAX_LENGHT * 2.9))) for r in result: self.check(r) self.assertEqual(len(result), 6) result = list(Message.prepare_message("a" * MAX_LENGHT + " a")) for r in result: self.check(r) self.assertEqual(len(result), 2) self.assertEqual(len(result[-1]), 1) result = list(Message.prepare_message("a" * MAX_LENGHT + " aaaa")) for r in result: self.check(r) self.assertEqual(len(result), 2) self.assertEqual(len(result[-1]), 4)
def test_long_messages(self): result = Message.prepare_message("a" * MAX_LENGHT) for r in result: self.check(r) result = Message.prepare_message(("a" * (MAX_LENGHT - 1) + "\n") * 2) for r in result: self.check(r) result = Message.prepare_message(("a" * MAX_LENGHT + "\n") * 2) for r in result: self.check(r)
def test_simple_message(self): result = Message.prepare_message("hi") size = 0 for r in result: self.check(r) size += 1 self.assertEqual(size, 1)