File tree Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,8 @@ async def select_bot(self, bot_id):
272272 if fetched_bot is None :
273273 raise errors .BotNotFoundError (f"Can't find bot with id: { bot_id } " )
274274 self .user_account .set_selected_bot_raw_data (fetched_bot )
275+ bot_name = self .user_account .get_bot_name_or_id (self .user_account .get_selected_bot_raw_data ())
276+ self .logger .debug (f"Selected bot '{ bot_name } '" )
275277 self .user_account .gql_bot_id = bot_id
276278 self ._save_gql_bot_id (self .user_account .gql_bot_id )
277279 await self .on_new_bot_select ()
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ class CommunityUserAccount:
2222 BOT_DEVICE = "device"
2323 NO_SELECTED_BOT_DESC = "No selected bot. Please select a bot to enable your community features."
2424
25-
2625 def __init__ (self ):
2726 self .gql_user_id = None
2827 self .gql_bot_id = None
@@ -62,6 +61,12 @@ def get_selected_bot_device_uuid(self):
6261 except AttributeError :
6362 raise errors .NoBotDeviceError ("No device associated to the select bot" )
6463
64+ def get_selected_bot_device_name (self ):
65+ try :
66+ return self .get_selected_bot_raw_data (raise_on_missing = True ).get (self .BOT_DEVICE , {}).get ("name" , None )
67+ except AttributeError :
68+ raise errors .NoBotDeviceError ("No device associated to the select bot" )
69+
6570 @staticmethod
6671 def get_bot_id (bot ):
6772 return bot ["_id" ]
Original file line number Diff line number Diff line change @@ -267,7 +267,8 @@ async def _connect(self):
267267 self ._update_client_config (self ._mqtt_client )
268268 self ._register_callbacks (self ._mqtt_client )
269269 self ._mqtt_client .set_auth_credentials (self ._device_uuid , None )
270- self .logger .debug (f"Connecting client" )
270+ self .logger .debug (f"Connecting client using device "
271+ f"'{ self .authenticator .user_account .get_selected_bot_device_name ()} '" )
271272 self ._connect_task = asyncio .create_task (
272273 self ._mqtt_client .connect (self .feed_url , self .mqtt_broker_port , version = self .MQTT_VERSION )
273274 )
Original file line number Diff line number Diff line change 3030
3131FEED_URL = "x.y.z"
3232TOKEN = "acb1"
33+ NAME = "name_a"
3334
3435
3536def _build_message (value , identifier ):
@@ -65,6 +66,8 @@ async def connected_community_feed(authenticator):
6566 feed .INIT_TIMEOUT = 1
6667 with mock .patch .object (authenticator .user_account , "get_selected_bot_device_uuid" , mock .Mock (return_value = TOKEN )) \
6768 as get_selected_bot_device_uuid_mock , \
69+ mock .patch .object (authenticator .user_account , "get_selected_bot_device_name" , mock .Mock (return_value = NAME )
70+ ) as _get_selected_bot_device_uuid_mock , \
6871 mock .patch .object (feed , "_subscribe" , mock .AsyncMock ()) as _subscribe_mock , \
6972 mock .patch .object (gmqtt .Client , "connect" , mock .AsyncMock ()) as _connect_mock :
7073 await feed .register_feed_callback (commons_enums .CommunityChannelTypes .SIGNAL , mock .AsyncMock ())
You can’t perform that action at this time.
0 commit comments