def test_ping_server_raise_ex(self, mock_requests=MagicMock()):
        with patch.dict(
                os.environ,
            {
                "WEB_CLIENT_LOG_FILE": "web_client.log",
                "LOG_DIRECTORY": self.temp_dir.path,
                "LAN_SERVER_HTTPS": "True",
                "LAN_SERVER_IP": "0.0.0.0",
                "LAN_PORT": "0",
            },
        ):
            with LogCapture() as capture:
                l_client = WebClient()
                mock_requests.post.side_effect = Exception("Exception")

                payload = "{'key':'value'}"

                with self.assertRaises(Exception):
                    l_client.ping_lan_server(payload)

                mock_requests.post.assert_called_with("https://0.0.0.0:0",
                                                      data=payload)
                capture.check(
                    ("WEB_CLIENT_LOG_FILE", "INFO", "Pinging"),
                    ("WEB_CLIENT_LOG_FILE", "INFO", f"data: { payload }"),
                    ("WEB_CLIENT_LOG_FILE", "ERROR",
                     "error occurred: Exception"),
                )
        hum = sensePi.get_humidity()
        acc = sensePi.get_acceleration()
        orie = sensePi.get_orientation()
        all = sensePi.get_all()
        coords = gpsPi.get_geolocation()

        if coords is not None:
            data = [temp, pres, hum, acc, orie, coords, all]
        else:
            data = [temp, pres, hum, acc, orie, all]

        for i in data:
            payload = json.dumps(i)
            print(payload)
            try:
                client.ping_lan_server(payload)
            except Exception as err:
                print("error occurred: {}".format(str(err)))
                raise
            time.sleep(1)
else:
    print("Local Django Server")
    transceiver = Transceiver()
    url = os.environ.get("DJANGO_SERVER_API_ENDPOINT")
    if url:
        client = WebClient(server_url=url)
        while True:
            data = transceiver.listen()
            if data:
                print(data)
                client.ping_lan_server(json.loads(data))