Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
watkins-matt committed Oct 3, 2024
1 parent 1cf7f09 commit 2e50f3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion custom_components/google_keep_sync/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
)
self.api = api
self.config_entry = entry
self._user_named_entities = set()
self._user_named_entities: set[str] = set()
_LOGGER.debug("GoogleKeepSyncCoordinator initialized")

async def _async_update_data(self) -> list[GKeepList]:
Expand Down
20 changes: 11 additions & 9 deletions tests/test_coordinator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Unit tests for the todo component."""

import logging
from typing import List
from unittest.mock import AsyncMock, MagicMock, call, patch

import pytest
Expand Down Expand Up @@ -262,7 +263,7 @@ async def test_notify_new_items(
async def test_no_deleted_lists(
mock_api: MagicMock, mock_hass: MagicMock, mock_config_entry: MockConfigEntry
):
"""Test that no entities are removed and config is unchanged when no lists are deleted."""
"""Test that entities and config remain the same when lists are not deleted."""
# Setup mock lists
mock_list1 = MagicMock(id="list1", title="List 1")
mock_list2 = MagicMock(id="list2", title="List 2")
Expand Down Expand Up @@ -307,7 +308,7 @@ async def test_no_deleted_lists(
async def test_some_deleted_lists(
mock_api: MagicMock, mock_hass: MagicMock, mock_config_entry: MockConfigEntry
):
"""Test that specified entities are removed and config is updated when some lists are deleted."""
"""Test that list deletion results in entity removal and config change."""
# Setup mock lists
mock_list1 = MagicMock(id="list1", title="List 1")
mock_list3 = MagicMock(id="list3", title="List 3")
Expand Down Expand Up @@ -369,7 +370,7 @@ async def test_some_deleted_lists(
async def test_all_deleted_lists(
mock_api: MagicMock, mock_hass: MagicMock, mock_config_entry: MockConfigEntry
):
"""Test that all entities are removed and config is cleared when all lists are deleted."""
"""Test that all entities and config are removed when all lists are deleted."""
# Initialize mock_config_entry.data
mock_config_entry.data = {
"list_prefix": "Test",
Expand All @@ -379,7 +380,7 @@ async def test_all_deleted_lists(
}

# Setup mock lists
mock_synced_lists = []
mock_synced_lists: List[MagicMock] = []
deleted_list_ids = ["list1", "list2", "list3"]

# Mock the API to return all lists as deleted
Expand Down Expand Up @@ -438,7 +439,7 @@ def get_entity_id(platform, domain, unique_id):
assert actual_calls == expected_calls

# Ensure configuration was updated to remove all lists
updated_lists = []
updated_lists: List[str] = []
mock_hass.config_entries.async_update_entry.assert_called_once_with(
mock_config_entry,
data={**mock_config_entry.data, "lists_to_sync": updated_lists},
Expand All @@ -448,7 +449,7 @@ def get_entity_id(platform, domain, unique_id):
async def test_deleted_lists_without_entities(
mock_api: MagicMock, mock_hass: MagicMock, mock_config_entry: MockConfigEntry
):
"""Test that coordinator handles deletions when some deleted lists lack corresponding entities."""
"""Test that coordinator deletes lists without corresponding entities."""
# Initialize mock_config_entry.data
mock_config_entry.data = {
"list_prefix": "Test",
Expand Down Expand Up @@ -533,7 +534,7 @@ async def test_exception_during_entity_removal(
"""Test coordinator's behavior when an exception occurs during entity removal."""
# Setup mock lists
mock_list1 = MagicMock(id="list1", title="List 1")
mock_synced_lists = []
mock_synced_lists: List[MagicMock] = []
deleted_list_ids = ["list1"]

# Mock the API to return some deleted lists
Expand Down Expand Up @@ -597,7 +598,8 @@ async def test_notify_new_items_deleted_lists(
mock_api: MagicMock, mock_hass: MagicMock, mock_config_entry: MockConfigEntry
):
"""Test that notifications are not sent when handling deleted lists."""
# This test ensures that when lists are deleted, no new item notifications are triggered.
# This test ensures that when lists are deleted,
# no new item notifications are triggered.

# Setup mock lists
mock_list1 = MagicMock(id="list1", title="List 1")
Expand Down Expand Up @@ -648,7 +650,7 @@ async def test_handle_deleted_lists_logging(
"""Test that appropriate logs are generated when handling deleted lists."""
# Setup mock lists
mock_list1 = MagicMock(id="list1", title="List 1")
mock_synced_lists = []
mock_synced_lists: List[MagicMock] = []
deleted_list_ids = ["list1"]

# Mock the API to return some deleted lists
Expand Down

0 comments on commit 2e50f3a

Please sign in to comment.