<s> """<STR_LIT>""" <EOL> import unittest <EOL> import mock <EOL> from cauliflowervest . client import base_client <EOL> from cauliflowervest . client import settings <EOL> from cauliflowervest . client . mac import client <EOL> from cauliflowervest . client . mac import tkinter <EOL> class _NoGuiOauth ( tkinter . GuiOauth ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . server_url = '<STR_LIT>' <EOL> self . client_id = '<STR_LIT>' <EOL> self . client_secret = '<STR_LIT>' <EOL> def _ShowLoggingInMessage ( self ) : <EOL> pass <EOL> class GuiOauthTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( GuiOauthTest , self ) . setUp ( ) <EOL> settings . OAUTH_CLIENT_ID = '<STR_LIT>' <EOL> settings . OAUTH_CLIENT_SECRET = '<STR_LIT>' <EOL> def testAuthenticateFailBadMetadata ( self ) : <EOL> with mock . patch . object ( base_client , '<STR_LIT>' ) as _ : <EOL> mock_fvc = mock . MagicMock ( client . FileVaultClient ) <EOL> mock_fvc . GetAndValidateMetadata . side_effect = base_client . MetadataError ( <EOL> '<STR_LIT>' ) <EOL> with mock . patch . object ( client , '<STR_LIT>' ) as mock_fvc_cls : <EOL> mock_fvc_cls . return_value = mock_fvc <EOL> cb = mock . Mock ( ) <EOL> cb . return_value = None <EOL> _NoGuiOauth ( ) . _Authenticate ( cb ) <EOL> self . assertEqual ( <NUM_LIT:1> , cb . call_count ) <EOL> self . assertEqual ( '<STR_LIT>' , cb . call_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) <EOL> def testAuthenticateSuccess ( self ) : <EOL> with mock . patch . object ( base_client , '<STR_LIT>' ) as _ : <EOL> mock_fvc = mock . MagicMock ( client . FileVaultClient ) <EOL> mock_fvc . GetAndValidateMetadata . return_value = None <EOL> with mock . patch . object ( client , '<STR_LIT>' ) as mock_fvc_cls : <EOL> mock_fvc_cls . return_value = mock_fvc <EOL> result = _NoGuiOauth ( ) . _Authenticate ( self . fail ) <EOL> self . assertIsInstance ( result , base_client . CauliflowerVestClient ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
