@@ -49,7 +49,9 @@ async def _collect_agentic_chunks(producer, callback_data=None):
4949 stack .enter_context (patch .object (agentic , 'get_user_timezone' , lambda _uid : 'UTC' ))
5050 stack .enter_context (patch .object (agentic , '_get_agentic_qa_prompt' , lambda * _args , ** _kwargs : 'SYSTEM' ))
5151 stack .enter_context (patch .object (agentic , 'load_app_tools' , lambda _uid : []))
52- stack .enter_context (patch .object (agentic , 'get_current_datetime_block' , lambda _uid , tz = None : '' ))
52+ stack .enter_context (
53+ patch .object (agentic , 'get_current_datetime_block' , lambda _uid , tz = None , location = None : '' )
54+ )
5355 stack .enter_context (patch .object (agentic , '_convert_tools' , lambda _core , _app : ([], {})))
5456 stack .enter_context (patch .object (agentic , '_messages_to_anthropic' , lambda _messages : []))
5557 stack .enter_context (patch .object (agentic , '_inject_current_datetime' , lambda messages , _block : messages ))
@@ -84,6 +86,21 @@ def fake_is_file_question(question):
8486 assert ran_on ['thread' ] is not loop_thread , "retrieve_is_file_question must run off the event-loop thread"
8587
8688
89+ async def test_mobile_city_context_uses_only_mobile_platforms ():
90+ async def fake_run_blocking (_executor , _function , _uid ):
91+ return {'latitude' : 40.7128 , 'longitude' : - 74.006 }
92+
93+ async def fake_city (latitude , longitude ):
94+ assert (latitude , longitude ) == (40.7128 , - 74.006 )
95+ return 'New York, New York, United States'
96+
97+ with patch .object (agentic , 'run_blocking' , fake_run_blocking ), patch (
98+ 'utils.conversations.location.async_get_google_maps_city' , fake_city
99+ ):
100+ assert await agentic ._get_mobile_city ('uid1' , 'ios' ) == 'New York, New York, United States'
101+ assert await agentic ._get_mobile_city ('uid1' , 'macos' ) is None
102+
103+
87104def _file_chat_tool_for_stream_test ():
88105 """Create a FileChatTool without its production Firestore constructor for a hermetic stream test."""
89106 tool = object .__new__ (chat_file .FileChatTool )
@@ -226,7 +243,7 @@ async def fake_agent_stream(
226243 with patch .object (agentic , 'get_user_timezone' , rec ('tz' , 'UTC' )), patch .object (
227244 agentic , '_get_agentic_qa_prompt' , rec ('prompt' , 'SYSTEM' )
228245 ), patch .object (agentic , 'load_app_tools' , rec ('app_tools' , [])), patch .object (
229- agentic , 'get_current_datetime_block' , lambda uid , tz = None : ''
246+ agentic , 'get_current_datetime_block' , lambda uid , tz = None , location = None : ''
230247 ), patch .object (
231248 agentic , '_convert_tools' , lambda core , app : ([], {})
232249 ), patch .object (
0 commit comments