Skip to content

Use SsdpServiceInfo for ssdp tests (part 3)#60334

Merged
bdraco merged 15 commits intohome-assistant:devfrom
epenet:ssdp-tests-part3
Nov 25, 2021
Merged

Use SsdpServiceInfo for ssdp tests (part 3)#60334
bdraco merged 15 commits intohome-assistant:devfrom
epenet:ssdp-tests-part3

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Nov 25, 2021

Proposed change

Use SsdpServiceInfo for SOURCE_SSDP tests (part 3) as preliminary work for #59931.

They are split out from part 1/2 because the get method needs to be implemented in SsdpServiceInfo (at least temporarily)

Requires part 2 to be merged: #60322

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 #
  • 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.
  • 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:

return getattr(self, name)
return self.upnp.get(name)

def get(self, name: str, default: Any = None) -> Any:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@MartinHjelmare / @bdraco / @frenck
Should I add this also to the other xxxServiceInfo?
When I migrated the others using a TypedDict in the first pass, and then using a dataclass in the second pass it didn't seem required.
Now with hindsight I think it might cause issues with custom components (ie. breaking change before 2022.6)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is the code that actually needs this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

grep "discovery_info.get(" homeassistant/components/**/**.py

As an example:

if (
discovery_info.get(ssdp.ATTR_UPNP_MANUFACTURER_URL)
!= DECONZ_MANUFACTURERURL
):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For zeroconf (and dhcp/usb/mqtt) they were fixed as I bumped into them.
I don't have example but I assume there will be some similar code in custom components.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As much as I hate to have more temporary code, I think we should implement it in all places since someone will be doing it that way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll open a separate PR for the other discovery components.
This probably also applies for the __iter__ implementation in #60339

@epenet epenet marked this pull request as draft November 25, 2021 14:31
@epenet epenet marked this pull request as ready for review November 25, 2021 15:47
@epenet
Copy link
Copy Markdown
Contributor Author

epenet commented Nov 25, 2021

Rebased since part 2 was merged.

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.

This one took a while to go though. Hopefully the next one is a bit smaller.

@bdraco bdraco merged commit f292691 into home-assistant:dev Nov 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2021
@epenet epenet deleted the ssdp-tests-part3 branch November 29, 2021 07:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants