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 ring chimes data update #109220

Merged
merged 4 commits into from
Jan 31, 2024
Merged

Conversation

sdb9696
Copy link
Contributor

@sdb9696 sdb9696 commented Jan 31, 2024

Proposed change

Fix coordinator bug with chimes introduced by #107088.

Reported in issue #109210.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@sdb9696 sdb9696 changed the title Fix bug with chimes data update Fix bug with ring integration chimes data update Jan 31, 2024
Copy link
Contributor

@ReneNulschDE ReneNulschDE left a comment

Choose a reason for hiding this comment

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

Thx. Tested it and can confirm that it works again.

tests/components/ring/test_sensor.py Outdated Show resolved Hide resolved
Comment on lines 76 to 77
error_logs = [record for record in caplog.records if record.levelname == "ERROR"]
assert len(error_logs) == 0
Copy link
Member

Choose a reason for hiding this comment

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

Isn't having the update trigger enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not completely sure what you mean but the bug would cause the error in the logs so the test is checking the logs do not have errors. Otherwise the test passes.

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't having

assert UnboundLocalError not in caplog.text

Be a better approach?

Copy link
Member

@joostlek joostlek Jan 31, 2024

Choose a reason for hiding this comment

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

Wouldn't having

assert "UnboundLocalError" not in caplog.text

Be a better approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a check for "UnboundLocalError" (and referenced the specific issue causing it). However as this test will be useful to pick up other errors in the future I've kept a check that there are no errors and also introduced a check that there's a success message. All three checks I tested with and without the fix and they call pickup the error.

Comment on lines +61 to +64
requests_mock.get(
"https://api.ring.com/clients_api/ring_devices",
text=load_fixture("chime_devices.json", "ring"),
)
Copy link
Member

Choose a reason for hiding this comment

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

We usually patch the library instead of mocking http requests done by the integration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of the tests in the integration use this approach for mocking the library so it could be a quite lift to change that for this fix . I can look at seeing how to change this for all the tests in a subsequent PR if that's ok.

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft January 31, 2024 15:06
@sdb9696
Copy link
Contributor Author

sdb9696 commented Jan 31, 2024

Comments addressed/replied to

@sdb9696 sdb9696 marked this pull request as ready for review January 31, 2024 17:08
@sdb9696
Copy link
Contributor Author

sdb9696 commented Jan 31, 2024

Failing CI due to codecov upload, @joostlek are you able to re-trigger that step please?

@joostlek joostlek changed the title Fix bug with ring integration chimes data update Fix ring chimes data update Jan 31, 2024
@joostlek joostlek merged commit 605b731 into home-assistant:dev Jan 31, 2024
18 of 19 checks passed
@sdb9696
Copy link
Contributor Author

sdb9696 commented Jan 31, 2024

Many thanks @joostlek !

@sdb9696 sdb9696 deleted the fix_coordinator_history branch January 31, 2024 18:58
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants