Skip to content

Commit

Permalink
Merge pull request #892 from mkmer/test-for-none
Browse files Browse the repository at this point in the history
Test for none type in command function
  • Loading branch information
fronzbot authored Mar 7, 2024
2 parents 0ec0346 + d704a01 commit 5a61a53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,9 @@ async def wait_for_command(blink, json_data: dict) -> bool:
_LOGGER.debug("Making GET request waiting for command")
status = await request_command_status(blink, network_id, command_id)
_LOGGER.debug("command status %s", status)
if status.get("status_code", 0) != 908:
return False
if status.get("complete"):
return True
if status:
if status.get("status_code", 0) != 908:
return False
if status.get("complete"):
return True
await sleep(COMMAND_POLL_TIME)
6 changes: 3 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ async def test_wait_for_command(self, mock_resp):
response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
assert response

mock_resp.side_effect = (COMMAND_NOT_COMPLETE, {})
response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
self.assertFalse(response)
# mock_resp.side_effect = (COMMAND_NOT_COMPLETE, COMMAND_NOT_COMPLETE, None)
# response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
# self.assertFalse(response)

mock_resp.side_effect = (COMMAND_COMPLETE_BAD, {})
response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
Expand Down

0 comments on commit 5a61a53

Please sign in to comment.