Exemple #1
0
    def test_update(self):
        uid_1 = "uid_user_1"
        uid_2 = "uid_user_2"

        usecret_1 = "usecret_1"
        usecret_2 = "usecret_2"

        self.test_add_friend()

        resp, code = self.test_login(uid=uid_1, usecret=usecret_1, result=True)
        assert code == 200, resp

        resp_dict = json.loads(resp)

        headers = dict()
        headers['token'] = resp_dict['token']

        success, dialog_id = Dialog.did_from_users_list([uid_1, uid_2])
        assert success, dialog_id

        msg1 = Message(dialog_id=dialog_id, text="test text", from_id=uid_1, time_stamp=-1)
        msg2 = Message(dialog_id=dialog_id, text="text test", from_id=uid_2, time_stamp=-2)

        valid_params = msg1.to_dict()

        resp, code = api.on_new_msg(headers=headers, params=valid_params)
        assert code == 200, str(code) + resp
        resp, code = api.on_new_msg(headers=headers, params=valid_params)
        assert code == 200, str(code) + resp

        resp, code = api.on_update_request(headers=headers)
        assert code == 200, str(code) + resp

        print "test[test_update] finished"
Exemple #2
0
def route_update():
    if request.method == 'GET':
        # headers
        headers = request.headers

        return api.on_update_request(headers=headers)
    elif request.method == 'POST':
        # headers
        headers = request.headers
        # 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_new_msg(params=params, headers=headers)