-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6459dfd
commit e958f66
Showing
1 changed file
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
import gkeepapi | ||
import pytest | ||
|
||
from custom_components.google_keep_sync.api import GoogleKeepAPI | ||
from custom_components.google_keep_sync.api import GoogleKeepAPI, ListCase | ||
|
||
# Constants for testing | ||
TEST_USERNAME = "[email protected]" | ||
|
@@ -428,3 +428,54 @@ async def async_dump_state(): | |
mock_store.async_save.assert_called_once_with( | ||
{"token": TEST_TOKEN, "state": TEST_STATE, "username": TEST_USERNAME} | ||
) | ||
|
||
|
||
async def test_change_list_case(google_keep_api, mock_hass): | ||
"""Test changing the case of list items.""" | ||
# Create a list with items | ||
mock_list = MagicMock(spec=gkeepapi.node.List) | ||
mock_list.id = "todo_list_id" | ||
mock_list.title = "Todo List" | ||
mock_item1 = MagicMock(id="milk_item_id", text="Milk", checked=False) | ||
mock_item2 = MagicMock(id="apple_item_id", text="apple", checked=False) | ||
mock_list.items = [mock_item1, mock_item2] | ||
|
||
# Check upper case | ||
google_keep_api.change_list_case(mock_list.items, ListCase.UPPER) | ||
assert mock_item1.text == "MILK" | ||
assert mock_item2.text == "APPLE" | ||
|
||
# Check lower case | ||
google_keep_api.change_list_case(mock_list.items, ListCase.LOWER) | ||
assert mock_item1.text == "milk" | ||
assert mock_item2.text == "apple" | ||
|
||
# Check no change | ||
google_keep_api.change_list_case(mock_list.items, ListCase.NO_CHANGE) | ||
assert mock_item1.text == "milk" | ||
assert mock_item2.text == "apple" | ||
|
||
# Check title case | ||
google_keep_api.change_list_case(mock_list.items, ListCase.TITLE) | ||
assert mock_item1.text == "Milk" | ||
assert mock_item2.text == "Apple" | ||
|
||
# Check sentence case | ||
google_keep_api.change_list_case(mock_list.items, ListCase.SENTENCE) | ||
assert mock_item1.text == "Milk" | ||
assert mock_item2.text == "Apple" | ||
|
||
|
||
async def test_change_case(google_keep_api, mock_hass): | ||
"""Test changing the case of individual strings.""" | ||
assert google_keep_api.change_case("milk", ListCase.UPPER) == "MILK" | ||
assert google_keep_api.change_case("milk", ListCase.LOWER) == "milk" | ||
assert google_keep_api.change_case("milk", ListCase.NO_CHANGE) == "milk" | ||
assert ( | ||
google_keep_api.change_case("chocolate milk", ListCase.TITLE) | ||
== "Chocolate Milk" | ||
) | ||
assert ( | ||
google_keep_api.change_case("chocolate milk", ListCase.SENTENCE) | ||
== "Chocolate milk" | ||
) |