Exemple #1
0
    def test_max_length(self):
        """Is the correct max_length calculated?"""
        msg = 'A test message'
        with mock.patch('framewirc.message.chunk_message') as chunk_message:
            make_privmsgs('meshy', msg)

        expected_max = 495  # 512 - len(r'PRIVMSG meshy :' + '\r\n')
        chunk_message.assert_called_with(msg, max_length=expected_max)
Exemple #2
0
    def test_long_line(self):
        too_long = (
            "We're no strangers to love, You know the rules and so do I. " +
            "A full commitment's what I'm thinking of, You wouldnt get " +
            "this from any other guy. I just wanna tell you how I'm " +
            "feeling, Gotta make you understand… Never gonna give you up, " +
            "Never gonna let you down, Never gonna run around and desert " +
            "you. Never gonna make you cry, Never gonna say goodbye, Never " +
            "gonna tell a lie and hurt you. We've known each other for so " +
            "long your heart's been aching but you're too shy to say it. " +
            "Inside we both know what's been going on, We know the game " +
            "and we're gonna play it."
        )
        expected = [
            (
                b"PRIVMSG meshy :We're no strangers to love, You know the " +
                b"rules and so do I. A full commitment's what I'm thinking " +
                b"of, You wouldnt get this from any other guy. I just wanna " +
                b"tell you how I'm feeling, Gotta make you " +
                b"understand\xe2\x80\xa6 Never gonna give you up, Never " +
                b"gonna let you down, Never gonna run around and desert " +
                b"you. Never gonna make you cry, Never gonna say goodbye, " +
                b"Never gonna tell a lie and hurt you. We've known each " +
                b"other for so long your heart's been aching but you're too " +
                b"shy to say it. Inside we both\r\n"
            ),
            (
                b"PRIVMSG meshy :know what's been going on, We know the " +
                b"game and we're gonna play it.\r\n"
            ),
        ]

        messages = make_privmsgs('meshy', too_long)
        self.assertEqual(messages, expected)
Exemple #3
0
 def test_linebreaks(self):
     expected = [
         b'PRIVMSG meshy :A message\r\n',
         b'PRIVMSG meshy :split onto lines\r\n',
         b'PRIVMSG meshy :with varying linebreaks\r\n',
     ]
     messages = make_privmsgs(
         'meshy',
         'A message\rsplit onto lines\nwith varying linebreaks',
     )
     self.assertEqual(messages, expected)
Exemple #4
0
 def test_simple(self):
     expected = [
         b'PRIVMSG meshy :Just a simple message\r\n',
     ]
     messages = make_privmsgs('meshy', 'Just a simple message')
     self.assertEqual(messages, expected)