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

Test for none type in command function #892

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
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
Loading