def test_store_token(self, mock_keyring): mix = AADMixin() mix.cred_store = "store_name" mix.store_key = "client_id" mix._default_token_cache({'token_type':'1', 'access_token':'2'}) mock_keyring.set_password.assert_called_with( "store_name", "client_id", str({'token_type':'1', 'access_token':'2'}))
def test_store_token_boom(self, mock_keyring): mock_keyring.side_effect = Exception('Boom!') mix = AADMixin(None, None) mix.cred_store = "store_name" mix.store_key = "client_id" with self.assertLogs('msrestazure.azure_active_directory', level="WARNING"): mix._default_token_cache({'token_type': '1', 'access_token': '2'})
def test_store_token_boom(self, mock_keyring): def boom(*args, **kwargs): raise Exception("Boom!") mock_keyring.set_password = boom mix = AADMixin(None, None) mix.cred_store = "store_name" mix.store_key = "client_id" with self.assertLogs('msrestazure.azure_active_directory', level="WARNING"): mix._default_token_cache({'token_type':'1', 'access_token':'2'})