示例#1
0
    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'})
示例#2
0
    def get_token(cls, **creds):
        """Get token using given credential"""

        access_info = sdk.authenticate(**creds)
        return access_info['token']
示例#3
0
    def get_user_id(cls, **creds):
        """Get ID of the user with given credential"""

        access_info = sdk.authenticate(**creds)
        return access_info['user_id']