Best Python code snippet using mailosaur-python_python
test_keyring.py
Source:test_keyring.py
1# Copyright 2014 Google Inc. All rights reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14"""Tests for oauth2client.keyring_storage tests.15Unit tests for oauth2client.keyring_storage.16"""17__author__ = 'jcgregorio@google.com (Joe Gregorio)'18import datetime19import keyring20import unittest21import mock22from oauth2client import GOOGLE_TOKEN_URI23from oauth2client.client import OAuth2Credentials24from oauth2client.keyring_storage import Storage25class OAuth2ClientKeyringTests(unittest.TestCase):26 def test_non_existent_credentials_storage(self):27 with mock.patch.object(keyring, 'get_password',28 return_value=None,29 autospec=True) as get_password:30 s = Storage('my_unit_test', 'me')31 credentials = s.get()32 self.assertEquals(None, credentials)33 get_password.assert_called_once_with('my_unit_test', 'me')34 def test_malformed_credentials_in_storage(self):35 with mock.patch.object(keyring, 'get_password',36 return_value='{',37 autospec=True) as get_password:38 s = Storage('my_unit_test', 'me')39 credentials = s.get()40 self.assertEquals(None, credentials)41 get_password.assert_called_once_with('my_unit_test', 'me')42 def test_json_credentials_storage(self):43 access_token = 'foo'44 client_id = 'some_client_id'45 client_secret = 'cOuDdkfjxxnv+'46 refresh_token = '1/0/a.df219fjls0'47 token_expiry = datetime.datetime.utcnow()48 user_agent = 'refresh_checker/1.0'49 credentials = OAuth2Credentials(50 access_token, client_id, client_secret,51 refresh_token, token_expiry, GOOGLE_TOKEN_URI,52 user_agent)53 # Setting autospec on a mock with an iterable side_effect is54 # currently broken (http://bugs.python.org/issue17826), so instead55 # we patch twice.56 with mock.patch.object(keyring, 'get_password',57 return_value=None,58 autospec=True) as get_password:59 with mock.patch.object(keyring, 'set_password',60 return_value=None,61 autospec=True) as set_password:62 s = Storage('my_unit_test', 'me')63 self.assertEquals(None, s.get())64 s.put(credentials)65 set_password.assert_called_once_with(66 'my_unit_test', 'me', credentials.to_json())67 get_password.assert_called_once_with('my_unit_test', 'me')68 with mock.patch.object(keyring, 'get_password',69 return_value=credentials.to_json(),70 autospec=True) as get_password:71 restored = s.get()72 self.assertEqual('foo', restored.access_token)73 self.assertEqual('some_client_id', restored.client_id)...
konnect_polen.py
Source:konnect_polen.py
1# -*- coding: utf-8 -*-2import keyring3enedis_pass1 = keyring.get_password("enedis","pass1")4enedis_key1 = keyring.get_password("enedis","key1")5polen_mail_user_production = keyring.get_password("polen","mail_user_production")6polen_mail_user_production = keyring.get_password("polen","mail_user_production")7polen_mail_pass_production = keyring.get_password("polen","mail_pass_production")8polen_mail_pass_production = keyring.get_password("polen","mail_pass_production")9polen_db_user_polen = keyring.get_password("configuration","db_user_polen")10polen_db_pass_polen = keyring.get_password("configuration","db_pass_polen")11configuration_db_user_localhost = keyring.get_password("configuration","db_user_localhost")12configuration_db_pass_localhost = keyring.get_password("configuration","db_pass_localhost")13polen_ftp_user_hydronext = keyring.get_password("polen","ftp_user_hydronext")14polen_ftp_pass_hydronext = keyring.get_password("polen","ftp_pass_hydronext")15polen_ftp_user_eex = keyring.get_password("polen","ftp_user_eex")16polen_ftp_pass_eex = keyring.get_password("polen","ftp_pass_eex")17polen_ftp_user_cnr = keyring.get_password("polen","ftp_user_cnr")18polen_ftp_pass_cnr = keyring.get_password("polen","ftp_pass_cnr")19polen_ftp_user_enercoop = keyring.get_password("polen","ftp_user_enercoop")...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!