def test_number_of_scheduled_service_airports_per_country_false():
    airport_obj = airports()
    result =\
        airport_obj\
        .number_of_scheduled_or_nonscheduled_service_airports_per_country(
            False)
    assert result['PH'] == 229
def test_nearby_airports_within_one_degree_state_country_lat_long():
    airport_obj = airports()
    result = airport_obj.nearby_airports_within_one_degree("KSEA",
                                                           airport_lat_long=True,
                                                           state_country=True)
    assert type(result[0]) == list
    assert type(result[1]) == str
    assert type(result[2]) == str
def test_airports_with_home_links():
    airport_obj = airports()
    result = airport_obj.airports_with_home_links()
    assert type(result) == dict
    home_link_list = list(result.values())
    http_in_item = False
    for item in home_link_list:
        if 'http' in item:
            http_in_item = True
    assert http_in_item is True
def test_airports_with_wiki_pages():
    airport_obj = airports()
    result = airport_obj.airports_with_wiki_pages()
    assert type(result) == dict
    wiki_list = list(result.values())
    # account for some of the data being in the incorrect column
    wiki_in_list = False
    for item in wiki_list:
        if 'wiki' in item:
            wiki_in_list = True
    assert wiki_in_list is True
示例#5
0
def home_page():
    """ Open the home page of Seatac airport.

    Args:
        None

    Returns:
           Opens a web page in a separate window
    """
    airport_obj = airports()
    result = airport_obj.airports_with_home_links()
    url = result["Seattle Tacoma International Airport"]
    airport_obj.open_web_page(url)
示例#6
0
def wiki():
    """ Display the wiki page of Seatac airport
    runways.

    Args:
        None

    Returns:
           Displays Seatac airport's wiki page on stdout
    """
    airport_obj = airports()
    result = airport_obj.airports_with_wiki_pages()
    url = result["Seattle Tacoma International Airport"]
    airport_obj.open_web_page(url)
示例#7
0
def country_with_the_most_scheduled_nonscheduled_service_false():
    """ Find the country with the most nonscheduled service airports.

    Args:
        None

    Returns:
           Writes to stdout
    """
    airport_obj = airports()
    result =\
        airport_obj.country_with_the_most_scheduled_nonscheduled_service(False)
    print('*' * 80)
    print('country with most unscheduled service airports,(number)')
    print('{0:>30},({1})'.format(result[0], result[1]))
    print('*' * 80)
示例#8
0
def towns_with_airports_within_100_miles_of_Seattle():
    """ Find all of the airports within 100 miles of Seattle.

    Args:
        None

    Returns:
           Writes to stdout
    """
    airport_id = 'KSEA'
    airport_name = 'Seattle'
    airport_obj = airports()
    result = airport_obj.nearby_airports_within_one_degree(airport_id)
    print('*' * 80)
    print('number of towns with airports within 100 miles of ', airport_name)
    print('{0:>30}'.format(len(result)))
    print('*' * 80)
示例#9
0
def lat_long():
    """ Display the lat/long of Seatac airport.

    Args:
        None

    Returns:
           Displays lat/long of Seatac on stdout
    """
    airport_obj = airports()
    airport_id = "KSEA"
    result =\
        airport_obj.nearby_airports_within_one_degree(
            airport_id, airport_lat_long=True)
    print('*' * 80)
    print('Latitude/Longitude of ', airport_id)
    print('{0:>30}/{1}'.format(result[0], result[1]))
    print('*' * 80)
示例#10
0
def state_country():
    """ Display the country thatSeatac airport is in.

    Args:
        None

    Returns:
           Displays the state that Seatac is in on stdout
    """
    airport_obj = airports()
    country_obj = countries()
    airport_id = "KSEA"
    result =\
        airport_obj.nearby_airports_within_one_degree(
            airport_id, state_country=True)
    country = country_obj.country_code_to_country_conversion(result[0])
    print('*' * 80)
    print('State-Country of ', airport_id)
    print('{0:>30}'.format(country))
    print('*' * 80)
def test_get_column_names_in_csv_file():
    column_names_obj = airports()
    result = column_names_obj.get_column_names_in_csv_file()
    assert len(result) == 18
def test_nearby_airports_within_one_degree_state_country():
    airport_obj = airports()
    result = airport_obj.nearby_airports_within_one_degree(
        "KSEA", airport_lat_long=False, state_country=True)
    assert len(result) == 2
def test_country_with_the_most_scheduled_nonscheduled_service_least():
    airport_obj = airports()
    result = airport_obj.country_with_the_most_scheduled_nonscheduled_service(
        False)
    assert result == ('United States', 21919)
def test_nearby_airports_within_one_degree_lat_long():
    airport_obj = airports()
    result = airport_obj.nearby_airports_within_one_degree(
        "KSEA", airport_lat_long=True, state_country=False)
    lat_long = float(result[0]) + float(result[1])
    assert type(lat_long) == float
def test_get_list_of_records_from_a_csv_file_FileNotFoundError():
    with pytest.raises(FileNotFoundError):
        airport_obj = airports()
        remove_csv_files()
        airport_obj.get_list_of_records_from_a_csv_file('airports.csv')
def test_nearby_airports_within_one_degree():
    airport_obj = airports()
    result = airport_obj.nearby_airports_within_one_degree("KSEA")
    assert 'Olympia' in result
def test_download_airport_data_csv_files(remove_csv_files):
    """ Test that the object will download the correct file."""
    airports()
    with open("airports.csv", 'r') as fopen:
        line = fopen.readline()
        assert 'municipality' in line
def test_get_list_of_records_from_a_csv_file():
    airport_obj = airports()
    results = airport_obj.get_list_of_records_from_a_csv_file('airports.csv')
    assert results[3082][9] == 'US-GA'
def test_nearby_airports_within_one_degree_with_invalid_param():
    with pytest.raises(UnboundLocalError):
        airport_obj = airports()
        airport_obj.nearby_airports_within_one_degree("")