def test_search(): ''' assumption: [email protected] is the only registered email for now. 2.all the value errors have been modified into specfic words. 3.the channel called "channelname" hasn't been created ''' #successful test: #login reset_data() auth_register('*****@*****.**', 'q1w2e3r4', 'BEAR', 'XI') login1_dic = auth_login('*****@*****.**', 'q1w2e3r4') token = login1_dic['token'] #create a channel channelValue = channels_create(token, "channelname", True) channel_id = channelValue['channel_id'] #sending a message message_send(token, channel_id, "1q2w3e4r") #search messages_dic = search(token, "1q") assert messages_dic['messages'][0]['message'] == "1q2w3e4r" #logout auth_logout(token) reset_data()
def movies(): text = request.args.get('q', '') if text != '': result = search(text) return jsonify(result['hits']['hits']) else: return jsonify('none')
def test1(): restart() authRegisterDict1 = auth_register("*****@*****.**", "123456", "Tim", "Hu") token1 = authRegisterDict1["token"] UID1 = authRegisterDict1['u_id'] authRegisterDict2 = auth_register("*****@*****.**", "1we33456", "Hayden", "Smith") token2 = authRegisterDict2["token"] UID2 = authRegisterDict2['u_id'] authRegisterDict3 = auth_register("*****@*****.**", "1we33ee456", "Jeff", "Lu") token3 = authRegisterDict3["token"] UID3 = authRegisterDict3['u_id'] authRegisterDict4 = auth_register("*****@*****.**", "jijijij37236", 'daniel', 'quin') token4 = authRegisterDict4["token"] UID4 = authRegisterDict4['u_id'] channel_id = channels_create(token1, 'test1', True) channel_invite(token1, channel_id, UID2) channel_invite(token1, channel_id, UID3) message_send(token1, channel_id, 'hello') message_send(token2, channel_id, 'hi') message_send(token3, channel_id, 'numb') result = search(token1, 'hello') assert result['messages'][0]['message'] == 'hello' assert result['messages'][0]['message_id'] == 1
def messageSearch(): '''Given a query string, return a collection of messages in all of the channels that the user has joined that match the query''' token = request.args.get('token') query_str = request.args.get('query_str') try: return dumps(search(token, query_str)) except ValueError as e: raise e except AccessError as e: raise e
def searching(): token = request.args.get('token') query_str = request.args.get('query_str') result = search(token, query_str) return dumps(result)
def serch(): ''' Route to search all existing channels for messages based on keyword''' return search(request.args.get('token'), request.args.get('query_str'))
def app_search(): token = get_args('token') query_str = get_args('query_str') return dumps(search(token, query_str))