def test_update_replies(self, mock_communicator, mock_client):
        mock_communicator.read_bytes = MagicMock()
        mock_communicator.extract_message = MagicMock()
        mock_communicator.extract_message.side_effect = [
            bytearray([1, 2, 3]), None
        ]

        module = IqModule(mock_communicator)
        module.update_replies()

        assert mock_communicator.read_bytes.call_count == 1
        assert mock_communicator.extract_message.called
    def test_get_reply(self, mock_communicator, mock_client, test_input,
                       expected):
        client_entry_name = test_input[0]
        valid_message = test_input[1]

        mock_communicator.read_bytes = MagicMock()
        mock_communicator.extract_message = MagicMock()
        mock_communicator.extract_message.side_effect = [
            bytearray(valid_message), None
        ]

        module = IqModule(mock_communicator)
        module.update_replies()

        assert module.get_reply("client_test", client_entry_name) == expected
    def test_is_fresh(self, mock_communicator, mock_client, test_input):
        client_entry_name = test_input[0][0]
        valid_message = test_input[0][1]

        mock_communicator.read_bytes = MagicMock()
        mock_communicator.extract_message = MagicMock()
        mock_communicator.extract_message.side_effect = [
            bytearray(valid_message), None
        ]

        module = IqModule(mock_communicator)
        assert not module.is_fresh(self._CLIENT_NAME, client_entry_name)

        module.update_replies()

        assert module.is_fresh(self._CLIENT_NAME, client_entry_name)