コード例 #1
0
ファイル: app.py プロジェクト: datakind/caseworker-scheduler
def get_endpoint():
    """
    Retreives start and end locations for a user
    """
    dbops = DBOps()
    user_id = request.args.get('userId')
    endpoint = request.args.get('endpoint')
    location = dbops.get_endpoint(user_id, endpoint)

    # Use the default location if a different location
    #   hasn't been saved for the user
    if not location:
        location = dbops.get_endpoint('default', endpoint)

    return jsonify(location)
コード例 #2
0
def test_endpoint_db():
    dbops = DBOps()
    test_start = {
        'userId': 'testid',
        'endpoint': 'start',
        'address': 'testaddress',
        'city': 'testcity',
        'state': 'teststate',
        'zipCode': 'testzip',
        'coordinates': [1, 2]
    }

    dbops.upsert_endpoint(test_start)
    start = dbops.get_endpoint('testid', 'start')
    for key in start:
        if key != 'insert_timestamp':
            assert start[key] == test_start[key]

    dbops.delete_endpoint('testid', 'start')
    activity = dbops.get_endpoint('testid', 'start')
    assert activity == None