Esempio n. 1
0
def test_traffic_api_data_distance():
    db_file = "rt_bike"
    lat = db.read_column_from_db(db_file, 'lat', 'dublin_bike')
    lon = db.read_column_from_db(db_file, 'lng', 'dublin_bike')
    bid = db.read_column_from_db(db_file, 'number', 'dublin_bike')
    coord = (bid, lat, lon)
    latlonid = dp.clean_lat_lon_id(coord)

    lat = str(53.344352)
    lon = str(-6.258456)
    for x, i, j in zip(latlonid[0], latlonid[1], latlonid[2]):
        distance_data = dp.get_distance(lat, lon, i, j)
        assert type(distance_data) == int
Esempio n. 2
0
def test_pollution_api(db_file, table, rt_db_file):
    bike_db_file = "rt_bike"
    lat = db.read_column_from_db(bike_db_file, 'lat', 'dublin_bike')
    lon = db.read_column_from_db(bike_db_file, 'lng', 'dublin_bike')
    bid = db.read_column_from_db(bike_db_file, 'number', 'dublin_bike')
    coord = (bid, lat, lon)
    latlonid = dp.clean_lat_lon_id(coord)
    rows_before_fetch = db.get_all_data(db_file, table)
    assert len(rows_before_fetch) % 113 == 0
    df.fetch_pollution_api_data(db_file, table, latlonid[0], latlonid[1],
                                latlonid[2], rt_db_file)
    rows_after_fetch = db.get_all_data(db_file, table)
    assert len(rows_after_fetch) % 113 == 0
    assert len(rows_after_fetch) - len(rows_before_fetch) == 113
    rows_rt_fetch = db.get_all_data(rt_db_file, table)
    assert len(rows_rt_fetch) == 113
Esempio n. 3
0

bike_data = db.get_bike_data()
pollution_data = db.get_pollution_data()
event_data = db.get_event_data()
traffic_data = db.get_traffic_data()

database_file = "../citymgmt/mobility_db"

tables = ['bike_availability', 'pollution_level', 'traffic_info','event_info']
tables_data = {tables[0]:bike_data, tables[1]:pollution_data, tables[2]:traffic_data, tables[3]:event_data}

#create_tables(database_file, tables_data)

bike_db_file = '../citymgmt/rt_bike_db'
lat = db.read_column_from_db(bike_db_file,'lat','bike_availability')
lon = db.read_column_from_db(bike_db_file,'lng','bike_availability')
bid = db.read_column_from_db(bike_db_file, 'number', 'bike_availability')
coord = (bid, lat, lon)
latlonid = dp.clean_lat_lon_id(coord)

start_time = time.time()
max_date = datetime.datetime.utcfromtimestamp(start_time).date()
lat = str(53.344352)
lon = str(-6.258456)
key_itr = 0
while True:
	current_time = time.time()
	current_date = datetime.datetime.utcfromtimestamp(current_time).date()
	df.fetch_bike_api_data(database_file, tables[0])
	df.fetch_pollution_api_data(database_file, tables[1], latlonid[0], latlonid[1], latlonid[2], key_itr)