Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)