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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up tests of HomematicIP Cloud #31810

Merged
merged 2 commits into from Feb 14, 2020
Merged

Conversation

@SukramJ
Copy link
Contributor

SukramJ commented Feb 13, 2020

Proposed change

This PR speeds up the execution of the HomematicIP Cloud tests by filtering out not required devices or groups from origin test data json.

Besides some required renaming this PR adds a factory to create a HomematicIP Access Point.
This Factory expects a list of device/group names to just create these and not all available devices.

As a result the tests are executed in 11 seconds instead of 60 seconds before. (on my machine)

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

  • This PR fixes or closes issue: fixes #31794
  • This PR is related to issue:
  • Link to documentation pull request:

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

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum
@project-bot project-bot bot added this to Needs review in Dev Feb 13, 2020
@codecov

This comment was marked as off-topic.

Copy link

codecov bot commented Feb 13, 2020

Codecov Report

Merging #31810 into dev will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #31810      +/-   ##
==========================================
- Coverage   94.67%   94.65%   -0.02%     
==========================================
  Files         763      763              
  Lines       55110    55148      +38     
==========================================
+ Hits        52174    52202      +28     
- Misses       2936     2946      +10     
Impacted Files Coverage 螖
...meassistant/components/homematicip_cloud/switch.py 93.40% <0.00%> (-6.60%) 猬囷笍
...eassistant/components/homematicip_cloud/climate.py 98.29% <0.00%> (-1.71%) 猬囷笍
homeassistant/components/template/cover.py 96.34% <0.00%> (-1.37%) 猬囷笍
...omeassistant/components/homematicip_cloud/cover.py 97.36% <0.00%> (-1.32%) 猬囷笍
...tant/components/homematicip_cloud/binary_sensor.py 99.54% <0.00%> (-0.46%) 猬囷笍
homeassistant/helpers/config_validation.py 95.66% <0.00%> (-0.40%) 猬囷笍
homeassistant/components/ps4/media_player.py 89.76% <0.00%> (-0.16%) 猬囷笍
homeassistant/components/teksavvy/sensor.py 97.77% <0.00%> (-0.03%) 猬囷笍
homeassistant/components/startca/sensor.py 97.95% <0.00%> (-0.03%) 猬囷笍
homeassistant/components/plex/const.py 100.00% <0.00%> (酶) 猬嗭笍
... and 13 more

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 06f0642...d945bb9. Read the comment docs.

Copy link
Member

balloob left a comment

Amazing, thank you ! 馃帀

Dev automation moved this from Needs review to Reviewer approved Feb 14, 2020

def init_home(self, json_path=HOME_JSON):
"""Init template with json."""
self.init_json_state = json.loads(load_fixture(HOME_JSON))
self.init_json_state = self._cleanup_json(json.loads(load_fixture(HOME_JSON)))

This comment has been minimized.

Copy link
@balloob

balloob Feb 14, 2020

Member

So I don't think json_path is ever used in init_home and so it's always the same fixture. I think that it could help in loading the fixture once instead of every test. I would still do json.loads on each test in case the original data is mutated.

# Put on top of file.
FIXTURE_DATA = load_fixture(HOME_JSON)

This comment has been minimized.

Copy link
@SukramJ

SukramJ Feb 14, 2020

Author Contributor

Done

@balloob balloob merged commit 9eb0415 into home-assistant:dev Feb 14, 2020
10 checks passed
10 checks passed
CI Build #20200214.10 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch Coverage not affected when comparing 81c48c2...9ababa9
Details
codecov/project 94.65% (target 90%)
Details
Dev automation moved this from Reviewer approved to Done Feb 14, 2020
@SukramJ SukramJ deleted the SukramJ:HmIP-SpeedUP-Tests branch Feb 14, 2020
@lock lock bot locked and limited conversation to collaborators Feb 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can鈥檛 perform that action at this time.