Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connected-mqtt-client fixture #117

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion everest-testing/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ install_requires =
pytest
pytest-asyncio
python-dateutil
paho-mqtt
paho-mqtt ==1.6.1
pyftpdlib
ocpp
websockets
Expand Down
14 changes: 14 additions & 0 deletions everest-testing/src/everest/testing/core_utils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from typing import Optional

import pytest
import os
import paho.mqtt.client as mqtt

from ._configuration.everest_configuration_strategies.everest_configuration_strategy import \
EverestConfigAdjustmentStrategy
Expand Down Expand Up @@ -116,3 +118,15 @@ def test_controller(request, tmp_path, everest_core) -> EverestTestController:

# FIXME (aw): proper life time management, shouldn't the fixure start and stop?
test_controller.stop()

@pytest.fixture
def connected_mqtt_client(everest_core: EverestCore) -> mqtt.Client:
mqtt_server_uri = os.environ.get("MQTT_SERVER_ADDRESS", "127.0.0.1")
mqtt_server_port = int(os.environ.get("MQTT_SERVER_PORT", "1883"))
client = mqtt.Client(everest_core.everest_uuid)
client.connect(mqtt_server_uri, mqtt_server_port)
client.loop_start()

yield client

client.loop_stop()
Loading