def test_get_credential_with_datasource_id_and_secret(self): token = get_credential() self.assertDictEqual( token, { 'datasource_id': TEST_DATASOURCE_ID, 'datasource_secret': TEST_DATASOURCE_SECRET })
def test_get_credential_with_user_id_and_personal_access_token(self): token = get_credential() self.assertDictEqual( token, { 'user_id': TEST_USER_ID, 'personal_access_token': TEST_PERSONAL_ACCESS_TOKEN })
def __init__(self, credential=None, timeout: Optional[int] = None, max_retry_count: Optional[int] = None): self.timeout = timeout or os.environ.get( SDK_CONNECTION_TIMEOUT_ENV_KEY) or DEFAULT_CONNECTION_TIMEOUT self.max_retry_count = max_retry_count or os.environ.get( SDK_MAX_RETRY_COUNT_ENV_KEY) or DEFAULT_MAX_RETRY_COUNT if credential is None: self.credential = get_credential() or {} else: self.credential = credential if 'user_id' in self.credential and not self.credential[ 'user_id'].startswith("user-"): self.credential['user_id'] = 'user-{}'.format( self.credential['user_id']) if 'datasource_id' in self.credential and \ not self.credential['datasource_id'].startswith('datasource-'): self.credential['datasource_id'] = 'datasource-{}'.format( self.credential['datasource_id'])
def test_get_credential_without_anything(self): token = get_credential() self.assertIsNone(token)
def test_get_credential_with_token(self): token = get_credential() self.assertDictEqual(token, {'auth_token': TEST_TOKEN})