File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed
Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -45,3 +45,13 @@ async def get(self) -> CacheData:
4545
4646 async def set (self , value : CacheData ) -> None :
4747 self ._data = value
48+
49+
50+ class NoCache (Cache ):
51+ """No-op cache implementation."""
52+
53+ async def get (self ) -> CacheData :
54+ return CacheData ()
55+
56+ async def set (self , value : CacheData ) -> None :
57+ pass
Original file line number Diff line number Diff line change 1818from roborock .protocol import create_mqtt_params
1919from roborock .web_api import RoborockApiClient
2020
21- from .cache import Cache , InMemoryCache
21+ from .cache import Cache , NoCache
2222from .channel import Channel
2323from .mqtt_channel import create_mqtt_channel
2424from .traits .dyad import DyadApi
@@ -137,7 +137,7 @@ async def create_device_manager(
137137 include caching or other optimizations.
138138 """
139139 if cache is None :
140- cache = InMemoryCache ()
140+ cache = NoCache ()
141141
142142 mqtt_params = create_mqtt_params (user_data .rriot )
143143 mqtt_session = await create_mqtt_session (mqtt_params )
Original file line number Diff line number Diff line change 66import pytest
77
88from roborock .containers import HomeData , UserData
9+ from roborock .devices .cache import CacheData , InMemoryCache
910from roborock .devices .device_manager import create_device_manager , create_home_data_api
1011from roborock .exceptions import RoborockException
1112
@@ -109,9 +110,6 @@ async def mock_home_data_with_counter() -> HomeData:
109110 call_count += 1
110111 return HomeData .from_dict (mock_data .HOME_DATA_RAW )
111112
112- # Create a real cache implementation for testing
113- from roborock .devices .cache import CacheData
114-
115113 class TestCache :
116114 def __init__ (self ):
117115 self ._data = CacheData ()
@@ -122,9 +120,8 @@ async def get(self) -> CacheData:
122120 async def set (self , value : CacheData ) -> None :
123121 self ._data = value
124122
125- cache = TestCache ()
126123 # First call happens during create_device_manager initialization
127- device_manager = await create_device_manager (USER_DATA , mock_home_data_with_counter , cache )
124+ device_manager = await create_device_manager (USER_DATA , mock_home_data_with_counter , cache = InMemoryCache () )
128125 assert call_count == 1
129126
130127 # Second call should use cache, not increment call_count
You can’t perform that action at this time.
0 commit comments