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

Handle "resp invalid json" error (Closes: #205) #449

Merged
merged 2 commits into from
Jan 10, 2019

Conversation

syssi
Copy link
Collaborator

@syssi syssi commented Jan 7, 2019

@syssi syssi requested a review from rytilahti January 7, 2019 07:29
@coveralls
Copy link

coveralls commented Jan 7, 2019

Coverage Status

Coverage decreased (-0.2%) to 72.455% when pulling 625b2f5 on syssi:feature/resp-invalid-json-fix into 05f55bc on rytilahti:master.

miio/exceptions.py Outdated Show resolved Hide resolved
raise DeviceError(m.data.value["error"])
error = m.data.value["error"]
if "code" in error and error["code"] == -30001:
raise RecoverableError(error)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to have this codepath tested too (at some point, maybe there are also other recoverable cases?) :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you've an idea how to test this part?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way to go would be mocking the Message.parse() to return with that error code, and then checking that it gets called retry_count times. #437 may simplify the tests (or we might split the code even a bit more to make it easier to test). I think this can wait for now, feel free to merge.

@syssi syssi merged commit f08b615 into rytilahti:master Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants