Skip to content

Commit

Permalink
Merge pull request #207 from builder555/dev
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
builder555 committed Jan 25, 2024
2 parents f0e0da3 + 9a33fd5 commit aafdab1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion backend/pinecil_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ async def monitor(self, stop_event):
await self.broadcast(msg)
except DeviceDisconnectedException:
logging.info("Pinecil disconnected")
self.broadcast(
await self.broadcast(
json.dumps({"status": "ERROR", "message": "Device disconnected"})
)
except Exception as e:
logging.warning("Error while getting live data - ignored")
9 changes: 5 additions & 4 deletions backend/test_pinecil_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def select_pinecil(index):

@pytest.fixture
def mock_broadcast():
return MagicMock()
return AsyncMock()


@pytest.mark.asyncio
Expand All @@ -97,11 +97,12 @@ async def test_monitor_no_pinecil_found(
@pytest.mark.asyncio
async def test_monitor_success(mock_pinecil_finder, mock_broadcast):
stop_event = asyncio.Event()
monitor = PinecilMonitor(mock_pinecil_finder, mock_broadcast)
mock_broadcast_sets_event = AsyncMock(side_effect=lambda msg: stop_event.set())

monitor = PinecilMonitor(mock_pinecil_finder, mock_broadcast_sets_event)
asyncio.create_task(monitor.monitor(stop_event))
await asyncio.sleep(0.2)
stop_event.set()
mock_broadcast.assert_called_with(
mock_broadcast_sets_event.assert_called_with(
'{"command": "LIVE_DATA", "payload": {"temp": 100, "voltage": 230}, "status": "OK"}'
)

Expand Down
2 changes: 1 addition & 1 deletion ci/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ "$(uname)" == "Darwin" ]; then
# this is needed because the mac will not execute binaries that are downloaded from the internet
# see https://developer.apple.com/library/archive/technotes/tn2459/_index.html
if xattr -p com.apple.quarantine ./Pinecil >/dev/null 2>&1; then
find ./ --name Pinecil | xargs xattr -rd com.apple.quarantine
find ./ -name Pinecil | xargs xattr -rd com.apple.quarantine
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.12
2.1.14

0 comments on commit aafdab1

Please sign in to comment.