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

Refactor homekit_controller config flow tests #32141

Merged
merged 4 commits into from
Feb 25, 2020

Conversation

Jc2k
Copy link
Member

@Jc2k Jc2k commented Feb 24, 2020

Proposed change

This refactors the homekit_controller config flow tests as per suggestion from @MartinHjelmare to use the hass.config_entries.flow methods to drive the tests, rather than calling the config flow directly.

This has deleted and cleaned up a lot of duplicated mocks and stubs so makes the tests much more compact and easy to understand but retains the coverage.

Had to bump aiohomekit to pick up a fix from the testing helpers there, but its a no-op for the integration itself (test helper only release).

There are 3 tests I didn't migrate:

  • test_parse_new_homekit_json
  • test_parse_old_homekit_json
  • test_parse_overlapping_homekit_json

These are all to do with both pre-config-flow pairing json files (.homekit/pairings.json and .homekit/hk-00:00:00:00:00:00). My preference would be to drop support for those files entirely. We haven't written to .homekit/pairings.json since May 2019 and haven't written to the older format since December 2018. Every release since then will have created a config flow entry and then started to ignore the old files.

If i have to keep them then i'll migrate them to the new style seperately - i need to do more refactoring on them that doesn't belong with this set of changes.

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)
  • 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
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@codecov
Copy link

codecov bot commented Feb 24, 2020

Codecov Report

Merging #32141 into dev will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #32141      +/-   ##
==========================================
- Coverage   94.73%   94.72%   -0.01%     
==========================================
  Files         767      767              
  Lines       55509    55500       -9     
==========================================
- Hits        52584    52575       -9     
  Misses       2925     2925
Impacted Files Coverage Δ
...stant/components/homekit_controller/config_flow.py 100% <100%> (ø) ⬆️
homeassistant/components/buienradar/camera.py 96.34% <0%> (-0.05%) ⬇️
homeassistant/components/demo/media_player.py 95.67% <0%> (-0.03%) ⬇️
homeassistant/components/device_tracker/legacy.py 99.14% <0%> (-0.01%) ⬇️
homeassistant/components/deconz/gateway.py 100% <0%> (ø) ⬆️
homeassistant/components/emulated_hue/hue_api.py 90.54% <0%> (ø) ⬆️
homeassistant/components/device_tracker/setup.py 93.25% <0%> (ø) ⬆️
homeassistant/components/deconz/const.py 100% <0%> (ø) ⬆️
homeassistant/components/device_tracker/const.py 100% <0%> (ø) ⬆️
homeassistant/components/efergy/sensor.py 96.55% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15b4975...8b617d7. Read the comment docs.

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Feb 24, 2020

We can announce that the old json files are deprecated and then remove support after eg two releases.

@Jc2k
Copy link
Member Author

Jc2k commented Feb 24, 2020

Thanks for the great feedback @MartinHjelmare! I think i've addressed all your points now.

How do I go about announcing a deprecation?

@MartinHjelmare
Copy link
Member

Make a PR and add a warning log message. Mark that PR breaking change and describe the deprecation in the breaking change paragraph.

@Jc2k
Copy link
Member Author

Jc2k commented Feb 25, 2020

Will leave the remaining tests that are affected by #32158 alone until the deprecation period is over, then remove them. So I think thats everything in here?

Dev automation moved this from Needs review to Reviewer approved Feb 25, 2020
@MartinHjelmare MartinHjelmare merged commit c9d78aa into home-assistant:dev Feb 25, 2020
Dev automation moved this from Reviewer approved to Done Feb 25, 2020
@Jc2k Jc2k deleted the homekit_controller_test_cf branch February 25, 2020 13:20
@lock lock bot locked and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants