def test_read_unknown_response(self): c = Cube('127.0.0.1', 62910) c._socket = StaticResponseSocket([ bytearray('X:', encoding='utf-8'), ]) c.read() self.assertEqual(len(c.received_messages), 0)
def test_read(self): c = Cube('127.0.0.1', 62910) c._socket = StaticResponseSocket([ bytearray('H:', encoding='utf-8') + HelloResponseBytes, bytearray('M:', encoding='utf-8') + MResponseBytes ]) c.read() self.assertEqual(len(c.received_messages), 2)
def test_read_after_connect(self): c = Cube('127.0.0.1', 62910) c.read = Mock() c._create_socket = Mock(return_value=Mock(socket.socket)) c.connect() self.assertTrue(c.read.called)