from utils.db.dao import MeteorologyDao, StationDao
from utils.db.table import Station, Meteorology
from datetime import datetime
from dateutil.relativedelta import relativedelta


def test_MeteorologyDao():
    dao = MeteorologyDao()
    d = datetime.strptime("2019-07-15 12:57:00", "%Y-%m-%d %H:%M:%S")
    # l = [Meteorology(station_no=i + 1, datetime=d + relativedelta(hours=i * 6)) for i in range(10)]
    # dao.add_list(l)
    #
    # dao.delete(1, d)

    r = dao.query_by_datetime(d)
    print(r.rain)


def test_StationDao():
    dao = StationDao()
    # d = datetime.strptime("2020-12-16 12:00:00", "%Y-%m-%d %H:%M:%S")
    # l = [Station(station_no=i + 1, lon=2 * i, lat=i * 3, lon_index=i ** 2, lat_index=i ** 2 - 1) for i in range(10)]
    # dao.add_list(l)
    #
    # dao.delete(3)
    #
    # x = dao.query_by_station_no(4)
    # print(x)
    l = dao.query_stations()
    print(l)


if __name__ == '__main__':
    test_MeteorologyDao()
    # test_StationDao()
