refactor: clean up imports in MQTT modules and tests

This commit is contained in:
OMGeeky
2025-06-07 12:42:59 +02:00
parent 81cd6127ef
commit 1a241e4744
4 changed files with 9 additions and 34 deletions

View File

@@ -7,30 +7,11 @@ It supports both real hardware and simulation mode.
This module uses the MQTTClient class from mqtt_client.py for the core MQTT implementation.
"""
import time
import json
import time
from .mqtt_client import (
MQTTClient,
MQTTException,
CONNECT,
CONNACK,
PUBLISH,
PUBACK,
SUBSCRIBE,
SUBACK,
UNSUBSCRIBE,
UNSUBACK,
PINGREQ,
PINGRESP,
DISCONNECT,
CONN_ACCEPTED,
CONN_REFUSED_PROTOCOL,
CONN_REFUSED_IDENTIFIER,
CONN_REFUSED_SERVER,
CONN_REFUSED_USER_PASS,
CONN_REFUSED_AUTH,
MQTT_PROTOCOL_LEVEL,
MQTT_CLEAN_SESSION,
)

View File

@@ -7,10 +7,9 @@ and provides a simple interface for connecting to an MQTT broker, publishing
messages, and subscribing to topics.
"""
import time
import json
import socket
import struct
import time
# MQTT Protocol Constants
MQTT_PROTOCOL_LEVEL = 4 # MQTT 3.1.1

View File

@@ -2,10 +2,11 @@
Tests for the MQTT module.
"""
import pytest
import json
from unittest.mock import patch, MagicMock
from src.esp_sensors.mqtt_client import MQTTClient
import pytest
from src.esp_sensors.mqtt import setup_mqtt, publish_sensor_data

View File

@@ -4,25 +4,19 @@ Tests for the MQTT Client module.
This module contains tests for the MQTTClient class in the mqtt_client.py module.
"""
import struct
import time
from unittest.mock import patch, MagicMock
import pytest
import socket
import struct
from unittest.mock import patch, MagicMock, call
from src.esp_sensors.mqtt_client import (
MQTTClient,
MQTTException,
CONNECT,
CONNACK,
PUBLISH,
PUBACK,
SUBSCRIBE,
SUBACK,
PINGREQ,
PINGRESP,
DISCONNECT,
CONN_ACCEPTED,
)