Skip to content

Commit

Permalink
Update amqtt (#226)
Browse files Browse the repository at this point in the history
* Run tests on main branch, as intended

* Update MQTT to dev version
  • Loading branch information
Orhideous authored Feb 13, 2024
1 parent e5a2cba commit 67af33d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
on:
push:
branches:
- master
- main

pull_request:

Expand Down
5 changes: 4 additions & 1 deletion roombapy/remote_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def _open_mqtt_connection(self):
self.mqtt_client.loop_start()

def _get_mqtt_client(self):
mqtt_client = mqtt.Client(client_id=self.blid)
mqtt_client = mqtt.Client(
client_id=self.blid,
callback_api_version=mqtt.CallbackAPIVersion.VERSION1,
)
mqtt_client.username_pw_set(username=self.blid, password=self.password)
mqtt_client.on_connect = self._internal_on_connect
mqtt_client.on_disconnect = self._internal_on_disconnect
Expand Down
25 changes: 13 additions & 12 deletions tests/test_roomba_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

import pytest
from hbmqtt.broker import Broker
from amqtt.broker import Broker

from tests import abstract_test_roomba

Expand Down Expand Up @@ -39,10 +39,10 @@ async def test_roomba_connect(self, broker, event_loop):
roomba = self.get_default_roomba()

# when
await self.start_broker(broker, event_loop)
await self.start_broker(broker)
is_connected = await self.roomba_connect(roomba, event_loop)
await self.roomba_disconnect(roomba, event_loop)
await self.stop_broker(broker, event_loop)
await self.stop_broker(broker)

# then
assert is_connected
Expand All @@ -53,29 +53,30 @@ async def test_roomba_connect_error(self, broker, event_loop):
roomba = self.get_default_roomba(blid="wrong")

# when
await self.start_broker(broker, event_loop)
await self.start_broker(broker)
is_connected = await self.roomba_connect(roomba, event_loop)
await self.stop_broker(broker, event_loop)

await self.stop_broker(broker)

# then
assert not is_connected

async def roomba_connect(self, roomba, loop):
await loop.run_in_executor(None, roomba.connect)
await asyncio.sleep(1, loop=loop)
await asyncio.sleep(1)
return roomba.roomba_connected

async def roomba_disconnect(self, roomba, loop):
await loop.run_in_executor(None, roomba.disconnect)

async def start_broker(self, broker, loop):
async def start_broker(self, broker):
await broker.start()
await asyncio.sleep(1, loop=loop)
await asyncio.sleep(1)

async def stop_broker(self, broker, loop):
async def stop_broker(self, broker):
await broker.shutdown()
await asyncio.sleep(1, loop=loop)
await asyncio.sleep(1)

@pytest.fixture
def broker(self, event_loop):
return Broker(BROKER_CONFIG, loop=event_loop)
def broker(self):
return Broker(BROKER_CONFIG)

0 comments on commit 67af33d

Please sign in to comment.