hello! I need to pass autopep8 and pylint and flake8
the problem is Local variable 'mock_conn' value is not used

import json
import queue
import threading
import unittest
from unittest.mock import patch, MagicMock, mock_open
import requests
from server import Worker, WorkerConfig, MasterServer, ServerConfig
from client import Client, URLSender


class TestWorker(unittest.TestCase):
    def setUp(self):
        self.task_queue = queue.Queue()
        self.result_queue = queue.Queue()
        self.top_k = 6
        self.total_counter = [0]
        self.lock = threading.Lock()

        self.worker_config = WorkerConfig(
            task_queue=self.task_queue,
            result_queue=self.result_queue,
            top_k=self.top_k,
            total_counter=self.total_counter,
            lock=self.lock
        )

        self.worker = Worker(self.worker_config)
        self.worker.daemon = True
        self.worker.start()

    @patch("requests.get")
    def test_fetch_and_parse_normal(self, mock_get):
        mock_response = MagicMock()
        mock_response.text = "Data analysis is great. Data drives decisions."
        mock_response.raise_for_status = MagicMock()
        mock_get.return_value = mock_response

        client_socket = MagicMock()
        self.task_queue.put((client_socket, "http://analyticshub.com"))
        self.task_queue.join()

        mock_get.assert_called_with("http://analyticshub.com")
        expected = {
            "data": 2,
            "analysis": 1,
            "is": 1,
            "great": 1,
            "drives": 1,
            "decisions": 1,
        }
        client_socket.sendall.assert_called()
        sent_data = client_socket.sendall.call_args[0][0]
        response = json.loads(sent_data.decode("utf-8"))
        self.assertEqual(response, expected)
        self.assertEqual(self.total_counter[0], 1)

    @patch("requests.get")
    def test_fetch_and_parse_empty_response(self, mock_get):
        mock_response = MagicMock()
        mock_response.text = ""
        mock_response.raise_for_status = MagicMock()
        mock_get.return_value = mock_response

        client_socket = MagicMock()
        self.task_queue.put((client_socket, "http://emptycontent.com"))
        self.task_queue.join()

        mock_get.assert_called_with("http://emptycontent.com")
        sent_data = client_socket.sendall.call_args[0][0]
        response = json.loads(sent_data.decode("utf-8"))
        self.assertEqual(response, {})
        self.assertEqual(self.total_counter[0], 1)

    @patch(
        "requests.get",
        side_effect=requests.exceptions.HTTPError("503 Service Unavailable")
    )
    def test_fetch_and_parse_http_error(self, mock_get):
        client_socket = MagicMock()
        self.task_queue.put((client_socket, "http://downservice.com"))
        self.task_queue.join()

        mock_get.assert_called_with("http://downservice.com")
        sent_data = client_socket.sendall.call_args[0][0]
        response = json.loads(sent_data.decode("utf-8"))
        self.assertIn("error", response)
        self.assertEqual(response["error"], "503 Service Unavailable")
        self.assertEqual(self.total_counter[0], 1)

    @patch(
        "requests.get",
        side_effect=requests.exceptions.ConnectTimeout("Connection timed out")
    )
    def test_fetch_and_parse_timeout(self, mock_get):
        client_socket = MagicMock()
        self.task_queue.put((client_socket, "http://slowresponse.com"))
        self.task_queue.join()

        mock_get.assert_called_with("http://slowresponse.com")
        sent_data = client_socket.sendall.call_args[0][0]
        response = json.loads(sent_data.decode("utf-8"))
        self.assertIn("error", response)
        self.assertEqual(response["error"], "Connection timed out")
        self.assertEqual(self.total_counter[0], 1)

    @patch("requests.get")
    def test_fetch_and_parse_large_response(self, mock_get):
        large_text = "innovation " * 5000 + "technology"
        mock_response = MagicMock()
        mock_response.text = large_text
        mock_response.raise_for_status = MagicMock()
        mock_get.return_value = mock_response

        client_socket = MagicMock()
        self.task_queue.put((client_socket, "http://bigdata.com"))
        self.task_queue.join()

        mock_get.assert_called_with("http://bigdata.com")
        sent_data = client_socket.sendall.call_args[0][0]
        response = json.loads(sent_data.decode("utf-8"))
        expected = {"innovation": 5000, "technology": 1}
        self.assertEqual(response, expected)
        self.assertEqual(self.total_counter[0], 1)

    @patch("requests.get")
    def test_fetch_and_parse_non_text_content(self, mock_get):
        mock_response = MagicMock()
        mock_response.text = ""
        mock_response.raise_for_status = MagicMock()
        mock_get.return_value = mock_response

        client_socket = MagicMock()
        self.task_queue.put((client_socket, "http://binarydata.com"))
        self.task_queue.join()

        mock_get.assert_called_with("http://binarydata.com")
        sent_data = client_socket.sendall.call_args[0][0]
        response = json.loads(sent_data.decode("utf-8"))
        self.assertEqual(response, {})
        self.assertEqual(self.total_counter[0], 1)

    @patch("requests.get")
    def test_fetch_and_parse_special_chars(self, mock_get):
        mock_response = MagicMock()
        test_text = "Robust error-handling mechanisms ensure reliability."
        mock_response.text = test_text
        mock_response.raise_for_status = MagicMock()
        mock_get.return_value = mock_response

        client_socket = MagicMock()
        self.task_queue.put((client_socket, "http://robustsystems.com"))
        self.task_queue.join()

        mock_get.assert_called_with("http://robustsystems.com")
        sent_data = client_socket.sendall.call_args[0][0]
        response = json.loads(sent_data.decode("utf-8"))
        expected = {
            "robust": 1,
            "error": 1,
            "handling": 1,
            "mechanisms": 1,
            "ensure": 1,
            "reliability": 1,
        }
        self.assertEqual(response, expected)
        self.assertEqual(self.total_counter[0], 1)


class TestClient(unittest.TestCase):
    @patch("builtins.print")
    def test_client_send_normal_urls(self, mock_print):
        test_urls = (
            "http://analyticshub.com\n"
            "http://datascience.ai\n"
            "invalid_url"
        )
        mock_socket = MagicMock()
        mock_responses = [
            json.dumps({"data": 2, "analysis": 1, "is": 1}).encode("utf-8"),
            json.dumps({"data": 3, "science": 2, "ai": 1}).encode("utf-8"),
            json.dumps({"error": "Invalid URL"}).encode("utf-8"),
            b""
        ]
        mock_socket.recv.side_effect = mock_responses

        with patch("builtins.open", mock_open(read_data=test_urls)), \
             patch("socket.create_connection") as mock_conn:
            mock_conn.return_value.__enter__.return_value = mock_socket
            client = Client("urls.txt", 2, "127.0.0.1", 8000)
            client.run()

            expected_outputs = [
                "http://analyticshub.com: {'data': 2, 'analysis': 1, 'is': 1}",
                "http://datascience.ai: {'data': 3, 'science': 2, 'ai': 1}",
                "invalid_url: {'error': 'Invalid URL'}"
            ]
            calls = [unittest.mock.call(output) for output in expected_outputs]
            mock_print.assert_has_calls(calls, any_order=True)
            self.assertEqual(mock_print.call_count, 3)

    def test_client_empty_url_file(self):
        with patch("builtins.open", mock_open(read_data="")), \
             patch("socket.create_connection") as mock_conn, \
             patch.object(URLSender, "send_url") as mock_send:
            client = Client("empty_urls.txt", 5, "127.0.0.1", 8000)
            client.run()
            mock_send.assert_not_called()

    def test_client_file_not_found(self):
        with patch("builtins.open", side_effect=FileNotFoundError):
            client = Client("nonexistent_urls.txt", 2, "127.0.0.1", 8000)
            with self.assertRaises(FileNotFoundError):
                client.run()


class TestIntegration(unittest.TestCase):
    def test_full_cycle(self):
        def create_mock_response(url):
            if "analyticshub.com" in url:
                text = "Data analysis drives insights. Data is crucial."
                mock_resp = MagicMock()
                mock_resp.text = text
                mock_resp.raise_for_status = MagicMock()
                return mock_resp
            elif "datascience.ai" in url:
                text = "Machine learning and AI are transforming industries."
                mock_resp = MagicMock()
                mock_resp.text = text
                mock_resp.raise_for_status = MagicMock()
                return mock_resp
            else:
                mock_resp = MagicMock()
                mock_resp.raise_for_status.side_effect = (
                    requests.exceptions.HTTPError("404 Not Found")
                )
                return mock_resp

        def run_server(start_event):
            config = ServerConfig(
                host="127.0.0.1",
                port=9000,
                num_workers=2,
                top_k=5
            )
            server = MasterServer(config)
            start_event.set()  # Signal that server has started
            server.start_server()

        test_urls = (
            "http://analyticshub.com\n"
            "http://datascience.ai\n"
            "http://unknown.ai"
        )

        start_event = threading.Event()

        with patch("requests.get") as mock_get, \
             patch("builtins.print") as mock_print, \
             patch("builtins.open", mock_open(read_data=test_urls)):

            mock_get.side_effect = create_mock_response
            server_thread = threading.Thread(
                target=run_server,
                args=(start_event,),
                daemon=True
            )
            server_thread.start()

            if not start_event.wait(timeout=5):
                self.fail("Server did not start in time.")

            client = Client("urls.txt", 3, "127.0.0.1", 9000)
            client.run()

            expected_outputs = [
                "http://analyticshub.com: {'data': 2, 'analysis': 1, "
                "'drives': 1, 'insights': 1, 'is': 1}",
                "http://datascience.ai: {'machine': 1, 'learning': 1, "
                "'and': 1, 'ai': 1, 'are': 1}",
                "http://unknown.ai: {'error': '404 Not Found'}"
            ]
            calls = [unittest.mock.call(output) for output in expected_outputs]
            mock_print.assert_has_calls(calls, any_order=True)
            self.assertEqual(mock_print.call_count, 3)


if __name__ == "__main__":
    unittest.main()