3030 is_canfulfill_intent_name , is_intent_name , is_request_type , viewport ,
3131 get_slot , get_slot_value , get_account_linking_access_token ,
3232 get_api_access_token , get_device_id , get_dialog_state , get_intent_name ,
33- get_locale , get_request_type , is_new_session , get_supported_interfaces )
33+ get_locale , get_request_type , is_new_session , get_supported_interfaces ,
34+ get_user_id )
3435from ask_sdk_core .handler_input import HandlerInput
3536from ask_sdk_core .exceptions import AskSdkException
3637
@@ -414,6 +415,7 @@ def setUp(self):
414415 self .test_slot = Slot (
415416 name = self .test_slot_name , value = self .test_slot_value )
416417 self .test_api_access_token = "foo_api_access_token"
418+ self .test_user_id = "foo_user_id"
417419 self .test_access_token = "foo_account_linking_access_token"
418420 self .test_device_id = "foo_device_id"
419421 self .test_supported_interfaces = SupportedInterfaces (
@@ -436,7 +438,8 @@ def setUp(self):
436438 session = Session (new = self .test_new_session ),
437439 context = Context (
438440 system = SystemState (
439- user = User (access_token = self .test_access_token ),
441+ user = User (access_token = self .test_access_token ,
442+ user_id = self .test_user_id ),
440443 api_access_token = self .test_api_access_token ,
441444 device = Device (
442445 device_id = self .test_device_id ,
@@ -644,3 +647,19 @@ def test_is_new_session(self):
644647 self .test_new_session ,
645648 "is_new_session method returned incorrect session information "
646649 "from input request when a session exists" )
650+
651+ def test_get_user_id_with_no_user_info_returns_none (self ):
652+ test_input = self ._create_handler_input (
653+ request = self .test_launch_request )
654+ test_input .request_envelope .context .system .user = None
655+ self .assertIsNone (
656+ get_user_id (handler_input = test_input ),
657+ "get_user_id method returned incorrect user id from input request" )
658+
659+ def test_get_user_id (self ):
660+ test_input = self ._create_handler_input (
661+ request = self .test_launch_request )
662+
663+ self .assertEqual (
664+ get_user_id (handler_input = test_input ), self .test_user_id ,
665+ "get_user_id method returned incorrect user id from input request" )
0 commit comments