Ejemplo n.º 1
0
def api_ident():
    #  gets ident code or airport name from url
    if 'ident' in request.args:
        ident = request.args['ident']
        city_name = get_city_from_ident(ident)
    elif 'name' in request.args:
        name = request.args['name']
        city_name = get_city_from_name(name)
    else:
        #  executes if no fields are specified
        return "<h1>Error</h1><p>No fields provided. Please specify either an ident code or an airport name.</p>"

    # empty string is returned if there is no matching field in the csv file
    if city_name == "":
        return "<h1>Error</h1><p>City could not be found for given ident code or airport name</p>"

    weath = get_weather(city_name)

    if weath == -1:
        return "<h1>Error</h1><p>City could not be found</p>"
    else:
        return jsonify(weath)
Ejemplo n.º 2
0
def test_invalid_name():
    assert get_city_from_name("heyyy") == ""
Ejemplo n.º 3
0
def test_name3():
    assert get_city_from_name("Merrill Field") == "Anchorage"
Ejemplo n.º 4
0
def test_name2():
    assert get_city_from_name("Gulkana Airport") == "Gulkana"
Ejemplo n.º 5
0
def test_name1():
    assert get_city_from_name("Talkeetna Airport") == "Talkeetna"