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

Fix flaky updater tests #26221

Merged
merged 1 commit into from Aug 27, 2019
Merged

Fix flaky updater tests #26221

merged 1 commit into from Aug 27, 2019

Conversation

andrewsayre
Copy link
Member

Description:

Fixes an issue where dt_util.utcnow was not properly being patch in the updater tests, which (I believe) resulted in periodic failures. Also updates the code in the file to use the async keywords and some linting. No functional changes to code.

Related issue (if applicable): fixes #26187

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]

@project-bot project-bot bot added this to Needs review in Dev Aug 27, 2019
@probot-home-assistant probot-home-assistant bot added core has-tests small-pr PRs with less than 30 lines. labels Aug 27, 2019
"""Fixture to mock utcnow."""
with patch("homeassistant.components.updater.dt_util.utcnow") as mock:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is where the root of the issue was. The tests weren't even using the fixture, probably because the patch wasn't working. I'm not sure why this didn't work (it does in other places in the tests, but none of those were in a fixture), but when debugging I could see it wasn't mocking. Changing it to the module then returning the method inside the yield fixed the issue.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

Dev automation moved this from Needs review to Reviewer approved Aug 27, 2019
@MartinHjelmare MartinHjelmare merged commit 9dc4019 into dev Aug 27, 2019
Dev automation moved this from Reviewer approved to Done Aug 27, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix_updater_tests branch August 27, 2019 08:30
@lock lock bot locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed core has-tests small-pr PRs with less than 30 lines.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

Flaky Updater Test
3 participants