#NEWLINE# @ mock . patch ( 'oauth2client.contrib.django_util.UserOAuth2' , autospec = True ) #NEWLINE# def test_has_credentials_in_storage( self , UserOAuth2 ) : #NEWLINE# #INDENT# request = self . factory . get ( '/test' ) #NEWLINE# request . session = mock . MagicMock ( ) #NEWLINE# @ decorators . oauth_required #NEWLINE# def test_view( request ) : #NEWLINE# #INDENT# return http . HttpResponse ( 'test' ) #NEWLINE# #UNINDENT# my_user_oauth = mock . MagicMock ( ) #NEWLINE# UserOAuth2 . return_value = my_user_oauth #NEWLINE# my_user_oauth . has_credentials . return_value = True #NEWLINE# response = test_view ( request ) #NEWLINE# self . assertEquals ( response . status_code , http_client . OK ) #NEWLINE# self . assertEquals ( response . content , b'test' )