def test_authorize_should_call_apiLogin_if_httplogin_succeded(self):
        login = YouTubeLogin()
        login._apiLogin = Mock(return_value=("",200))
        login._httpLogin = Mock(return_value=("",200))

        login.authorize()

        login._httpLogin.assert_any_call({ "new": "true"})
        login._apiLogin.assert_any_call()
示例#2
0
    def test_authorize_should_call_apiLogin_if_httplogin_succeded(self):
        login = YouTubeLogin()
        login._apiLogin = Mock(return_value=("",200))
        login._httpLogin = Mock(return_value=("",200))

        login.authorize()

        login._httpLogin.assert_any_call({ "new": "true"})
        login._apiLogin.assert_any_call()
示例#3
0
    def test_authorize_should_reset_oauth2_data_when_refreshing(self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        login = YouTubeLogin()
        login._httpLogin = Mock(return_value=("",303))

        login.authorize()

        sys.modules["__main__"].settings.setSetting.assert_any_call("oauth2_access_token","")
        sys.modules["__main__"].settings.setSetting.assert_any_call("oauth2_refresh_token","")
        sys.modules["__main__"].settings.setSetting.assert_any_call("oauth2_expires_at","")
    def test_authorize_should_reset_oauth2_data_when_refreshing(self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        login = YouTubeLogin()
        login._httpLogin = Mock(return_value=("",303))

        login.authorize()

        sys.modules["__main__"].settings.setSetting.assert_any_call("oauth2_access_token","")
        sys.modules["__main__"].settings.setSetting.assert_any_call("oauth2_refresh_token","")
        sys.modules["__main__"].settings.setSetting.assert_any_call("oauth2_expires_at","")
    def test_authorize_should_show_refreshing_folder_message_on_success(self):
        sys.modules["__main__"].language.side_effect = ["string1", "string2"]

        login = YouTubeLogin()
        login._apiLogin = Mock(return_value=("",200))
        login._httpLogin = Mock(return_value=("",200))

        login.authorize()

        sys.modules["__main__"].utils.showErrorMessage.assert_called_with("string1","",303)
        sys.modules["__main__"].language.assert_called_with(30031)
    def test_authorize_should_show_error_message_on_api_login_failure(self):
        sys.modules["__main__"].language.side_effect = ["string1", "string2"]

        login = YouTubeLogin()
        login._apiLogin = Mock(return_value=("",500))
        login._httpLogin = Mock(return_value=("",200))

        login.authorize()

        sys.modules["__main__"].utils.showErrorMessage.assert_called_with("string1","",500)
        sys.modules["__main__"].language.assert_called_with(30609)
示例#7
0
    def test_authorize_should_show_refreshing_folder_message_on_success(self):
        sys.modules["__main__"].language.side_effect = ["string1", "string2"]

        login = YouTubeLogin()
        login._apiLogin = Mock(return_value=("",200))
        login._httpLogin = Mock(return_value=("",200))

        login.authorize()

        sys.modules["__main__"].utils.showErrorMessage.assert_called_with("string1","",303)
        sys.modules["__main__"].language.assert_called_with(30031)
示例#8
0
    def test_authorize_should_show_error_message_on_api_login_failure(self):
        sys.modules["__main__"].language.side_effect = ["string1", "string2"]

        login = YouTubeLogin()
        login._apiLogin = Mock(return_value=("",500))
        login._httpLogin = Mock(return_value=("",200))

        login.authorize()

        sys.modules["__main__"].utils.showErrorMessage.assert_called_with("string1","",500)
        sys.modules["__main__"].language.assert_called_with(30609)
    def test_login_should_check_debug_flag_to_ensure_we_get_proper_debug_incase_of_errors(self):
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()

        sys.modules["__main__"].pluginsettings.debugModeIsEnabled.assert_called_with()
    def test_login_should_tell_xbmc_to_refresh_the_current_folder_listing_if_login_was_success_full(self):
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()
        
        sys.modules["__main__"].xbmc.executebuiltin.assert_called_with("Container.Refresh")
示例#11
0
    def test_login_should_tell_xbmc_to_refresh_the_current_folder_listing_if_login_was_success_full(self):
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()
        
        sys.modules["__main__"].xbmc.executebuiltin.assert_called_with("Container.Refresh")
示例#12
0
    def test_login_should_check_debug_flag_to_ensure_we_get_proper_debug_incase_of_errors(self):
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()

        sys.modules["__main__"].pluginsettings.debugModeIsEnabled.assert_called_with()
示例#13
0
    def test_login_should_call_xbmc_open_settings_to_allow_user_to_revise_credentials(self):
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()

        sys.modules["__main__"].settings.openSettings.assert_called_with()
    def test_login_should_call_xbmc_open_settings_to_allow_user_to_revise_credentials(self):
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()

        sys.modules["__main__"].settings.openSettings.assert_called_with()
示例#15
0
    def test_login_should_call_authorize_if_refresh_token_didnt_work(self):
        sys.modules["__main__"].core._oRefreshToken.return_value = False
        login = YouTubeLogin()
        login.authorize = Mock(return_value=("",303))

        login.login()
        
        sys.modules["__main__"].core._oRefreshToken.assert_called_with()
        login.authorize.assert_called_with()
示例#16
0
    def test_login_should_exit_cleanly_if_user_hasnt_entered_a_username(self):
        sys.modules["__main__"].pluginsettings.userName.return_value = ""
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        (result, status) = login.login()

        assert (result == "")
        assert (status == 200)
    def test_login_should_get_both_old_and_new_user_name_to_check_for_user_changes(self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()

        sys.modules["__main__"].pluginsettings.userName.call_count = 2
        sys.modules["__main__"].pluginsettings.userPassword.call_count = 2
    def test_login_should_call_authorize_if_refresh_token_didnt_work(self):
        sys.modules["__main__"].core._oRefreshToken.return_value = False
        login = YouTubeLogin()
        login.authorize = Mock(return_value=("",303))

        login.login()
        
        sys.modules["__main__"].core._oRefreshToken.assert_called_with()
        login.authorize.assert_called_with()
示例#19
0
    def test_login_should_get_both_old_and_new_user_name_to_check_for_user_changes(self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login()

        sys.modules["__main__"].pluginsettings.userName.call_count = 2
        sys.modules["__main__"].pluginsettings.userPassword.call_count = 2
    def test_login_should_exit_cleanly_if_user_hasnt_entered_a_username(self):
        sys.modules["__main__"].pluginsettings.userName.return_value = ""
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        (result, status) = login.login()

        assert (result == "")
        assert (status == 200)
    def test_login_should_not_ask_core_to_refresh_security_token_if_user_password_has_changed(self):
        sys.modules["__main__"].pluginsettings.userName.return_value = "some_user"
        sys.modules["__main__"].pluginsettings.userPassword.side_effect = ["some_pass","some_other_pass"]
        sys.modules["__main__"].pluginsettings.authenticationRefreshRoken.return_value = "some_token"
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login({"new":"false"})

        assert(sys.modules["__main__"].core._oRefreshToken.call_count == 0)
    def test_login_should_ask_core_to_refresh_security_token_if_we_have_an_existing_token_and_credentials_are_unchanged(self):
        sys.modules["__main__"].pluginsettings.userName.return_value = "some_user"
        sys.modules["__main__"].pluginsettings.userPassword.return_value = "some_pass"
        sys.modules["__main__"].pluginsettings.authenticationRefreshRoken.return_value = "some_token"
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login({"new":"false"})

        sys.modules["__main__"].core._oRefreshToken.assert_any_call()
示例#23
0
    def test_login_should_ask_core_to_refresh_security_token_if_we_have_an_existing_token_and_credentials_are_unchanged(self):
        sys.modules["__main__"].pluginsettings.userName.return_value = "some_user"
        sys.modules["__main__"].pluginsettings.userPassword.return_value = "some_pass"
        sys.modules["__main__"].pluginsettings.authenticationRefreshRoken.return_value = "some_token"
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login({"new":"false"})

        sys.modules["__main__"].core._oRefreshToken.assert_any_call()
示例#24
0
    def test_login_should_not_ask_core_to_refresh_security_token_if_user_password_has_changed(self):
        sys.modules["__main__"].pluginsettings.userName.return_value = "some_user"
        sys.modules["__main__"].pluginsettings.userPassword.side_effect = ["some_pass","some_other_pass"]
        sys.modules["__main__"].pluginsettings.authenticationRefreshRoken.return_value = "some_token"
        login = YouTubeLogin()
        login.authorize = Mock(return_value=([],200))

        login.login({"new":"false"})

        assert(sys.modules["__main__"].core._oRefreshToken.call_count == 0)