Exemplo n.º 1
0
def test_drivers_area_order(driver, driver2, admin_token):
    driver1_email = driver.get('email')
    driver1_password = 123456

    driver2_email = driver2.get('email')
    driver2_password = 123456

    driver1_login_json = login("Driver", driver1_email, driver1_password)
    assert driver1_login_json['status'] == "SUCCESS"
    if driver1_login_json['data']['status'] == 'Away-Off':
        print('Driver ==> {} <== status confirmed Away-Off after first login'.
              format(driver1_email))

    driver1_token = driver1_login_json['data']['api_token']
    print('driver1_token: ', driver1_token)
    '''take care that here we are calling change status api twice in order to be able to change status'''
    change_status_json = update_status(driver1_token, "Available")
    change_status_json = update_status(driver1_token, "Available")
    assert change_status_json['status'] == "SUCCESS"
    if change_status_json['status'] == "SUCCESS":
        print(
            'Driver ==> {} <== status has been successfully changed into Available'
            .format(driver1_email))

    driver2_login_json = login("Driver", driver2_email, driver2_password)
    assert driver2_login_json['status'] == "SUCCESS"
    if driver2_login_json['data']['status'] == 'Away-Off':
        print('Driver ==> {} <== status confirmed Away-Off after first login'.
              format(driver2_email))

    driver2_token = driver2_login_json['data']['api_token']
    print('driver2_token: ', driver2_token)
    '''take care that here we are calling change status api twice in order to be able to change status'''
    change_status_json = update_status(driver2_token, "Available")
    change_status_json = update_status(driver2_token, "Available")
    assert change_status_json['status'] == "SUCCESS"
    if change_status_json['status'] == "SUCCESS":
        print(
            'Driver ==> {} <== status has been successfully changed into Available'
            .format(driver2_email))

    point = {"lat": 30.06657871622343, "lng": 31.30840301513672}

    driver1_tracking_json = update_location(driver1_token, point['lat'],
                                            point['lng'])
    assert driver1_tracking_json['status'] == 'SUCCESS'
    if driver1_tracking_json['status'] == 'SUCCESS':
        print('Driver ==> {} <== location has been set successfully'.format(
            driver1_email))

    driver2_tracking_json = update_location(driver2_token, point['lat'],
                                            point['lng'])
    assert driver2_tracking_json['status'] == 'SUCCESS'
    if driver2_tracking_json['status'] == 'SUCCESS':
        print('Driver ==> {} <== location has been set successfully'.format(
            driver2_email))
Exemplo n.º 2
0
 def put(self, todo_id):
     item = get_item(todo_id)
     if not item:
         abort_if_todo_doesnt_exist(todo_id)
     args = parser.parse_args()
     status = args.get('completed')
     if status and update_status(todo_id, status):
         item = get_item(todo_id)
         return item
     return {'Fail': 'No status Parse. Please, use one of {}'}
Exemplo n.º 3
0
def update_status(id,status):   
   #Update item in the list
   res_data = helper.update_status(id, status)
   if res_data is None:
      response = Response("{'error': 'Error updating item - '" + str(id) + ", " + status   +  "}", status=400 , mimetype='application/json')
      return response
   
   #Return response
   response = Response(json.dumps(res_data), mimetype='application/json')
   
   return response
Exemplo n.º 4
0
def test_driver_status_change(driver):
    driver_email = driver.get('email')
    driver_password = constants.PASSWORD

    json_response = login("Driver", driver_email, driver_password)
    assert json_response.get('status') == "SUCCESS"
    assert json_response.get('data').get('status') == 'Away-Off'
    if json_response.get('data').get('status') == 'Away-Off':
        print('Driver ==> {} <== status confirmed Away-Off after first login'.
              format(driver_email))

    driver_token = json_response.get('data').get('api_token')
    ''' take care here you are calling change status twice because single hit causes error '''
    json_response = update_status(driver_token, 'Available')
    json_response = update_status(driver_token, 'Available')
    assert json_response.get('status') == "SUCCESS"
    if json_response.get('status') == "SUCCESS":
        print(
            'Driver ==> {} <== status has been successfully changed into Available'
            .format(driver_email))
Exemplo n.º 5
0
def update_status():
    req_data = request.get_json()
    item = req_data['item']
    status = req_data['status']

    res_data = helper.update_status(item, status)

    if res_data is None:
        response = Response("{'error'}: 'Error updating item - %s'}" % item, status=400, mimetype='application.json')
        return response

    response = Response(json.dumps(res_data), mimetype='application/json')
    return response
Exemplo n.º 6
0
def update_status():
   #Get item from the POST body
   req_data = request.get_json()
   item = req_data['item']
   status = req_data['status']
   
   #Update item in the list
   res_data = helper.update_status(item, status)
   if res_data is None:
      response = Response("{'error': 'Error updating item - '" + item + ", " + status   +  "}", status=400 , mimetype='application/json')
      return response
   
   #Return response
   response = Response(json.dumps(res_data), mimetype='application/json')
   
   return response
Exemplo n.º 7
0
def update_status():
    # get item from POST body
    req_data = request.get_json()
    item = req_data['item']
    status = req_data['status']

    # update item in list
    res_data = helper.update_status(item, status)

    if res_data is None:
        response = Response(
            f"{{'error': 'Error updating item - {item } {status} }}",
            status=400,
            mimetype='application/json')
        return response

    response = Response(json.dumps(res_data), mimetype='application/json')
    return response
Exemplo n.º 8
0
def update_status():
    req_data = request.get_json()
    title = req_data['title']
    status = req_data['status']

    # Update item in the list
    res_data = helper.update_status(title, status)

    # if helper function is unable to write to DB
    if res_data is None:
        response = Response("{'error': 'Error updating item - '" + title +
                            ", " + status + "}",
                            status=400,
                            mimetype='application/json')
        return response

    response = Response(json.dumps(res_data), mimetype='application/json')

    return response
Exemplo n.º 9
0
    def _update_status():
        """ Updates an item """
        # Get item from the POST body
        req_data = request.get_json()
        taskid = req_data['taskid']
        completed_at = req_data['completed_at']

        # Update item in the list
        res_data = helper.update_status(taskid, completed_at)

        # Return error if the status could not be updated
        if res_data is None:
            response = Response("{'error': 'Error updating item - '" + taskid +
                                "}", status=400, mimetype='application/json')
            return response

        # Return response
        response = Response(json.dumps(res_data), mimetype='application/json')

        return response
Exemplo n.º 10
0
def update_status():
    # Get item from the POST body
    req_data = request.get_json()
    itemid = req_data['itemid']
    status = req_data['status']

    # Update item in the list
    res_data = helper.update_status(itemid, status)

    # Return error if the status could not be updated
    if res_data is None:
        respuesta = {"error": "Se produjo un error al actualizar el status."}
        response = Response(json.dumps(respuesta),
                            status=400,
                            mimetype='application/json')
        return response

    # Return response
    response = Response(json.dumps(res_data), mimetype='application/json')

    return response
Exemplo n.º 11
0
def update_status():
    #get item from the post body
    req_data = request.get_json()
    item = req_data['item']
    status = req_data['status']

    #update item in the list
    res_data = helper.update_status(item, status)

    #return error if the status could not be updated
    if res_data is None:
        response = Response("{'error': 'Error updating item = '" + item +
                            ", " + status + "}",
                            status=400,
                            mimetype='application/json')
        return response

    #return response
    response = Response(json.dumps(res_data), mimetype='application/json')

    return response
Exemplo n.º 12
0
def update_status():
    # get the item from POST body
    req_data = request.get_json()
    item = req_data["item"]
    status = req_data["status"]

    # update item in list
    res_data = helper.update_status(item, status)

    # return error if unable to update status
    if res_data is None:
        response = Response(
            "{'error': 'Error updating item - '" + item + ", " + status + "}",
            status=400,
            mimetype="application/json",
        )
        return response

    response = Response(json.dumps(res_data), mimetype="application/json")

    return response