Beispiel #1
0
 def setUp(self):
     """Can't make an IRC connection in tests, so a mock will have to do."""
     self.client = Client(
         handlers=[],
         nick='anick',
         real_name='Real Name',
     )
     self.client.connection = mock.MagicMock(spec=Connection)
Beispiel #2
0
class TestOnConnect(TestCase):
    def setUp(self):
        """Can't make an IRC connection in tests, so a mock will have to do."""
        self.client = Client(
            handlers=[],
            nick='anick',
            real_name='Real Name',
        )
        self.client.connection = mock.MagicMock(spec=Connection)

    def test_user_command_sent(self):
        self.client.on_connect()
        expected = b'USER anick 0 * :Real Name\r\n'
        self.client.connection.send.assert_any_call(expected)

    def test_set_nick_called(self):
        self.client.on_connect()
        expected = b'NICK anick\r\n'
        self.client.connection.send.assert_called_with(expected)