Skip to content

Fix cross-platform grouping tests for get_groupable_players#3

Merged
dan-s-github merged 4 commits intofeature/get-groupable-players-2342from
copilot/sub-pr-2
Jan 21, 2026
Merged

Fix cross-platform grouping tests for get_groupable_players#3
dan-s-github merged 4 commits intofeature/get-groupable-players-2342from
copilot/sub-pr-2

Conversation

Copy link

Copilot AI commented Jan 21, 2026

The test_get_groupable_players_multiplatform test patched MediaPlayerEntity.async_get_groupable_players to return cross-platform results, creating a false impression that the service supports cross-platform grouping by default.

Changes

  • Removed test_get_groupable_players_multiplatform from tests/components/media_player/test_init.py - this test patched the implementation and bypassed actual behavior
  • Added test_get_groupable_players_multiplatform_override to demonstrate how integrations can override the method for multi-platform grouping support

Context

The default implementation filters by platform:

# homeassistant/components/media_player/__init__.py:1224
registry_entry = entity_registry.async_get(entity.entity_id)
if not registry_entry or registry_entry.platform != current_platform:
    continue

The removed test bypassed this filtering by patching the method, misrepresenting the service's behavior. The new test properly demonstrates how integrations can override async_get_groupable_players to return entities from multiple platforms when they have integration-specific logic to support cross-platform grouping.

Test Coverage

Remaining tests now accurately cover:

  • test_get_groupable_players_service - Basic service functionality
  • test_get_groupable_players_entity_without_feature - Feature requirement enforcement
  • test_get_groupable_players_same_platform_only - Default same-platform filtering behavior
  • test_get_groupable_players_multiplatform_override - Integration override capability for multi-platform grouping

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: dan-s-github <20974454+dan-s-github@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix implementation of get groupable players feature Remove misleading cross-platform test that bypasses implementation Jan 21, 2026
Copilot AI requested a review from dan-s-github January 21, 2026 06:49
@dan-s-github
Copy link
Owner

@copilot we also need a test for multi-platform support as this is the main driver behind this service implementation

Copy link
Author

Copilot AI commented Jan 21, 2026

@copilot we also need a test for multi-platform support as this is the main driver behind this service implementation

I'm confused by this request. The current implementation (line 1224 in init.py) filters entities by platform: if not registry_entry or registry_entry.platform != current_platform: continue. This means it only returns same-platform entities.

The test I removed was patching this method to bypass the platform filtering, which doesn't test the actual implementation.

Could you clarify:

  1. Should the implementation be changed to support multi-platform grouping?
  2. Or should I add a test that sets up multiple platforms and verifies the current same-platform filtering behavior?
  3. What specific multi-platform scenario should the test cover?

@dan-s-github
Copy link
Owner

@copilot the default implementation will only return entities from the same platform, but other media_player entities can override this method and return entities from multiple platforms that could be grouped

Co-authored-by: dan-s-github <20974454+dan-s-github@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 21, 2026

@copilot the default implementation will only return entities from the same platform, but other media_player entities can override this method and return entities from multiple platforms that could be...

Added test in commit 4b8f5b8 that demonstrates how integrations can override async_get_groupable_players to support multi-platform grouping. The test creates a custom entity class that overrides the method to return entities from multiple platforms (spotify, sonos, chromecast) and verifies the service properly returns those results.

Copilot AI changed the title Remove misleading cross-platform test that bypasses implementation Fix cross-platform grouping tests for get_groupable_players Jan 21, 2026
@dan-s-github dan-s-github marked this pull request as ready for review January 21, 2026 08:18
@dan-s-github dan-s-github merged commit fe97877 into feature/get-groupable-players-2342 Jan 21, 2026
20 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants