def test_stations(): api = SMHI() dataset = api.list()[0] stations = dataset.stations assert len(stations) > 0 for station in stations: assert isinstance(station, Station)
def test_get_dataset(): api = SMHI() datasets = api.list() ds_by_id = api.get(datasets[0].id) ds_by_label = api.get(datasets[0].label) assert (isinstance(ds_by_id, Dataset)) assert (isinstance(ds_by_label, Dataset))
def test_dimension(): api = SMHI() dataset = api.list()[0] dims = dataset.dimensions for dim in dims: assert (isinstance(dim, Dimension)) assert dim.id assert (isinstance(dim.list(), list)) assert (isinstance(dim.categories, list))
def test_dimension(): api = SMHI() dataset = api.list()[0] dims = dataset.dimensions for dim in dataset.dimensions: assert isinstance(dim.categories, list) assert isinstance(dim.list(), list) for category in dim.categories: assert category.id assert isinstance(category, Category)
def test_query_all_datasets(): """ Make a sample query on all datasets """ api = SMHI() for dataset in api.list(): stations = [x.id for x in dataset.stations if x.updated.year >= 2016][:3] data = dataset.query(station=stations, period=["latest-day", "latest-months"]).data if len(data) == 0: data = dataset.query(station=stations, period=["corrected-archive"]).data assert len(data) > 0
def test_list_datasets(): api = SMHI() datasets = api.list() assert isinstance(datasets, list) assert isinstance(datasets[0], Dataset) assert len(datasets) > 0
def test_that_datasets_have_id(): api = SMHI() datasets = api.list() for dataset in datasets: assert (dataset.id)
def test_basics(): api = SMHI() for dataset in api.list(): assert dataset.id