Beispiel #1
0
    def test_add_user(self, uid="*****@*****.**", usecret="1234", result=False):
        uname = "user-" + uid

        params_invalid_0 = None

        params_invalid_1 = dict()
        params_invalid_1['uid'] = uid
        params_invalid_1['secret'] = usecret

        params_valid = dict(params_invalid_1)
        params_valid['name'] = uname

        invalid_response_0, inv_resp_code_0 = api.on_add_user(params=params_invalid_0)
        invalid_response_1, inv_resp_code_1 = api.on_add_user(params=params_invalid_1)
        valid_response, v_resp_code = api.on_add_user(params=params_valid)

        if result:
            if v_resp_code == 201:
                return
            elif v_resp_code == 400 and "already exists" in valid_response:
                return
        else:
            assert inv_resp_code_0 == 400, str(inv_resp_code_0) + invalid_response_0
            assert inv_resp_code_1 == 400, str(inv_resp_code_1) + invalid_response_1
            if not v_resp_code == 201 or v_resp_code == 400 and "already exists" in valid_response:
                pass
            else:
                assert v_resp_code == 201, str(v_resp_code) + valid_response

            print "test[test_add_user] finished"
Beispiel #2
0
def route_user_add():
    # params
    params = params_from_request(request)

    if params is None:
        response = json.dumps({'error': "unsupported content-type -> " + str(request.content_type)})
        return response, 400
    else:
        return api.on_add_user(params=params)