def test_authenticate(self, mock_conn): x_conn = mock_conn.return_value x_conn.session.get_token.return_value = 'TOKEN' x_conn.session.get_user_id.return_value = 'test-user-id' x_conn.session.get_project_id.return_value = 'test-project-id' access_info = { 'token': 'TOKEN', 'user_id': 'test-user-id', 'project_id': 'test-project-id' } res = sdk.authenticate(foo='bar') self.assertEqual(access_info, res) mock_conn.assert_called_once_with({'foo': 'bar'})
def get_token(cls, **creds): """Get token using given credential""" access_info = sdk.authenticate(**creds) return access_info['token']
def get_user_id(cls, **creds): """Get ID of the user with given credential""" access_info = sdk.authenticate(**creds) return access_info['user_id']