Skip to content

Fix missing mocking for SamsungTV tests#60181

Merged
chemelli74 merged 1 commit intohome-assistant:devfrom
chemelli74:chemelli74-samsungtv-tests
Nov 23, 2021
Merged

Fix missing mocking for SamsungTV tests#60181
chemelli74 merged 1 commit intohome-assistant:devfrom
chemelli74:chemelli74-samsungtv-tests

Conversation

@chemelli74
Copy link
Copy Markdown
Contributor

Proposed change

Add missing mocking to tests: from +200s to 15s

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 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.

The integration reached or maintains the following Integration Quality Scale:

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

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link
Copy Markdown

Hey there @escoand, mind taking a look at this pull request as it has been labeled with an integration (samsungtv) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

Copy link
Copy Markdown
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

LGTM if CI passes 👍

@epenet
Copy link
Copy Markdown
Contributor

epenet commented Nov 23, 2021

There are still some slow tests in test_init.py.

Could you please also make sure that all dhcp.DhcpServiceInfo entries have all three arguments provided? A few have missing hostname and this will cause issues when #60136 is merged in.
Edit: Actually don't worry about hostname I think if you make changes there it might actually cause merge conflicts with #60136

@chemelli74 chemelli74 merged commit e673d9d into home-assistant:dev Nov 23, 2021
@chemelli74 chemelli74 deleted the chemelli74-samsungtv-tests branch November 23, 2021 10:56
@epenet
Copy link
Copy Markdown
Contributor

epenet commented Nov 23, 2021

There are still three tests taking a long time:

20.04s call     tests/components/samsungtv/test_init.py::test_setup[pyloop]
20.04s call     tests/components/samsungtv/test_init.py::test_setup_duplicate_entries[pyloop]
20.03s call     tests/components/samsungtv/test_init.py::test_setup_from_yaml_without_port_device_offline[pyloop]

@chemelli74 chemelli74 mentioned this pull request Nov 23, 2021
22 tasks
with patch(
"homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.device_info",
return_value=MOCK_DEVICE_INFO,
), patch("getmac.get_mac_address", return_value="aa:bb:cc:dd:ee:ff"):
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Nov 24, 2021

Choose a reason for hiding this comment

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

We have this fixture already. We can use it and just change the return value in the test.

@pytest.fixture(name="no_mac_address")
def mac_address_fixture():
"""Patch getmac.get_mac_address."""
with patch("getmac.get_mac_address", return_value=None) as mac:
yield mac

@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2021
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.

SamsungTV tests take too long

5 participants