#NEWLINE# @ mock . patch ( 'oauth2client.contrib.dictionary_storage.OAuth2Credentials' ) #NEWLINE# def test_specified_scopes( self , OAuth2Credentials ) : #NEWLINE# #INDENT# request = self . factory . get ( '/test' ) #NEWLINE# request . session = mock . MagicMock ( ) #NEWLINE# credentials_mock = mock . Mock ( scopes = set ( django . conf . settings . GOOGLE_OAUTH2_SCOPES ) ) #NEWLINE# credentials_mock . has_scopes = False #NEWLINE# OAuth2Credentials . from_json . return_value = credentials_mock #NEWLINE# @ decorators . oauth_required ( scopes = [ 'additional-scope' ] ) #NEWLINE# def test_view( request ) : #NEWLINE# #INDENT# return http . HttpResponse ( 'hello world' ) #NEWLINE# #UNINDENT# response = test_view ( request ) #NEWLINE# self . assertEquals ( response . status_code , 302 )