Skip to content

Clean up entity_service_call tests#169170

Merged
frenck merged 2 commits into
home-assistant:devfrom
arturpragacz:h/service/clean-up-entity-service-call-tests
Apr 29, 2026
Merged

Clean up entity_service_call tests#169170
frenck merged 2 commits into
home-assistant:devfrom
arturpragacz:h/service/clean-up-entity-service-call-tests

Conversation

@arturpragacz
Copy link
Copy Markdown
Member

Proposed change

Clean up entity_service_call tests.

  • Exercise the real dispatch path instead of mocking the private service._handle_single_entity_call helper.
  • Drop test_call_with_match_all, redundant with test_call_no_context_target_all.

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

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

Checklist

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors entity_service_call tests in Home Assistant core to exercise the real entity dispatch path instead of mocking the private _handle_single_entity_call helper, improving test fidelity.

Changes:

  • Replace mocking of homeassistant.helpers.service._handle_single_entity_call with a fixture that patches a method on the base Entity class and asserts calls through the real dispatch stack.
  • Update several entity_service_call tests to pass a method name ("test_method") to follow the string-based dispatch path.
  • Remove test_call_with_match_all as redundant with existing coverage.

Comment thread tests/helpers/test_service.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 25, 2026 23:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tests/helpers/test_service.py:1787

  • Set is_admin=False on the mocked user so this test actually exercises the non-admin permission filtering path instead of being treated as admin due to Mock.is_admin being truthy by default.
    with patch(
        "homeassistant.auth.AuthManager.async_get_user",
        return_value=Mock(
            permissions=PolicyPermissions(
                {"entities": {"entity_ids": {"light.kitchen": True}}}, None
            )
        ),

Copy link
Copy Markdown
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @arturpragacz 👍

../Frenck

                       

Blogging my personal ramblings at frenck.dev

@frenck frenck merged commit e4e4785 into home-assistant:dev Apr 29, 2026
52 checks passed
@arturpragacz arturpragacz deleted the h/service/clean-up-entity-service-call-tests branch April 29, 2026 09:37
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
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