<s> from __future__ import absolute_import , print_function <EOL> import pytest <EOL> from sentry . auth . exceptions import IdentityNotValid <EOL> from sentry . auth . providers . oauth2 import OAuth2Provider <EOL> from sentry . models import AuthIdentity , AuthProvider <EOL> from sentry . testutils import TestCase <EOL> class OAuth2ProviderTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . org = self . create_organization ( owner = self . user ) <EOL> self . user = self . create_user ( '<STR_LIT>' ) <EOL> self . auth_provider = AuthProvider . objects . create ( <EOL> provider = '<STR_LIT>' , <EOL> organization = self . org , <EOL> ) <EOL> self . provider = self . get_provider ( ) <EOL> super ( OAuth2ProviderTest , self ) . setUp ( ) <EOL> def get_provider ( self ) : <EOL> self . provider = OAuth2Provider ( <EOL> key = self . auth_provider . provider <EOL> ) <EOL> def test_refresh_identity_without_refresh_token ( self ) : <EOL> auth_identity = AuthIdentity . objects . create ( <EOL> auth_provider = self . auth_provider , <EOL> user = self . user , <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> provider = OAuth2Provider ( key = self . auth_provider . provider ) <EOL> with pytest . raises ( IdentityNotValid ) : <EOL> provider . refresh_identity ( auth_identity ) </s>
