Пример #1
0
def login(email=None, pw=None):
    """ Attempt to login. Defaults to the special testing username and password specified
        in util/tests/context.py. """
    if email == None:
        email = Context.email
    if pw == None:
        pw = Context.passwd
    return do_post('/api/auth/login', {'email': email, 'password': pw})
Пример #2
0
def login(email=None, pw=None):
    """ Attempt to login. Defaults to the special testing username and password specified
        in util/tests/context.py. """
    if email == None:
        email = Context.email
    if pw == None:
        pw = Context.passwd
    return do_post('/api/auth/login', {'email':email, 'password':pw})
Пример #3
0
def test_post_results(token, result_id, **overrides):
    params = {'user_token': token}
    params.update(get_example_data(overrides))
    for key, val in params.items():
        if isinstance(val, list):
            params[key] = json.dumps(params[key])

    resp = do_post('/api/test_result/%s/edit' % str(result_id), params)
    check_status(resp, fields=[])

    print (SUCCESS("Post Test Results data"))
Пример #4
0
def test_new_set(token):
    params = {'user_token':token, 
            }

    resp = do_post('/api/test_set/create', params)
    check_status(resp, fields=['set_id'])

    set_id = resp.json()['set_id']

    print (SUCCESS("Create new Test Set",
        set_id=set_id,
        ))

    return set_id
Пример #5
0
def test_start_mobile(token, set_id):
    print token
    params = {'user_token':token, 
            'set_id':set_id,
            }

    resp = do_post('/api/start_test/mobile', params)
    check_status(resp, fields=['result_id', 'config'])

    js = resp.json()
    assert_valid_config(js['config'])

    print (SUCCESS("Start mobile test",
            conf=truncate_repr(js['config']),
            result_id=js['result_id']
        )) 
    return js['result_id'] #, js['config']
Пример #6
0
def test_get_results(token, result_id, **overrides):
    params = {'user_token':token,
            }
    extra_columns = [
            'download_throughputs_avg',
            'download_latencies_avg',
            'upload_throughputs_avg',
            'upload_latencies_avg',
            ]

    resp = do_post('/api/test_result/%s' % str(result_id), params)
    check_status(resp,
            fields=TestResult.get_public_columns().keys() + extra_columns)
    data = get_example_data(overrides)
    json_resp = resp.json()

    for col in data:
        validate_col(col, data[col], json_resp[col])

    print (SUCCESS("Retrieve Test Results data",
        data=truncate_repr(data, priority=overrides),
        ))

    return resp.json()
Пример #7
0
def testfunc(token):
    """ Make a call to the api testfunc. Require a valid authentication token."""
    return do_post('/api/testfunc', {"user_token": token})
Пример #8
0
def logout(token):
    """ Attempt to logout the user who is identified by the given token. """
    return do_post('/api/auth/logout', {"user_token": token})
Пример #9
0
def create_user(email=None, pw=None):
    """ Create a user with the given email and password.
        Defaults to the testing account. """
    email = email or Context.email
    pw = pw or Context.passwd
    return do_post('/api/auth/register', {'email': email, 'password': pw})
Пример #10
0
def testfunc(token):
    """ Make a call to the api testfunc. Require a valid authentication token."""
    return do_post('/api/testfunc', {"user_token":token})
Пример #11
0
def logout(token):
    """ Attempt to logout the user who is identified by the given token. """
    return do_post('/api/auth/logout', {"user_token":token})
Пример #12
0
def create_user(email=None, pw=None):
    """ Create a user with the given email and password.
        Defaults to the testing account. """
    email = email or Context.email
    pw = pw or Context.passwd
    return do_post('/api/auth/register', {'email':email, 'password':pw})