diff --git a/ddlpy/ddlpy.py b/ddlpy/ddlpy.py index e884dcc..ddd5552 100644 --- a/ddlpy/ddlpy.py +++ b/ddlpy/ddlpy.py @@ -272,7 +272,6 @@ def _combine_waarnemingenlijst(result, location): "Naam", "X", "Y", - "Parameter_Wat_Omschrijving", ]: df[name] = location[name] diff --git a/tests/test_ddlpy.py b/tests/test_ddlpy.py index 86061e6..370b459 100755 --- a/tests/test_ddlpy.py +++ b/tests/test_ddlpy.py @@ -10,14 +10,14 @@ import numpy as np -@pytest.fixture +@pytest.fixture(scope="session") def locations(): """return all locations""" locations = ddlpy.locations() return locations -@pytest.fixture +@pytest.fixture(scope="session") def location(locations): """return sample location""" bool_grootheid = locations['Grootheid.Code'] == 'WATHTE' @@ -26,7 +26,7 @@ def location(locations): return location -@pytest.fixture +@pytest.fixture(scope="session") def measurements(location): """measurements for a location """ start_date = dt.datetime(1953, 1, 1) @@ -40,6 +40,13 @@ def test_locations(locations): assert locations.shape[1] == 18 # the number of rows is the number of stations, so will change over time assert locations.shape[0] > 1 + + # check presence of columns + assert "Coordinatenstelsel" in locations.columns + assert "Naam" in locations.columns + assert "X" in locations.columns + assert "Y" in locations.columns + assert "Parameter_Wat_Omschrijving" in locations.columns def test_locations_extended(): @@ -55,6 +62,14 @@ def test_locations_extended(): def test_measurements(measurements): assert measurements.shape[0] > 1 + + # check presence of columns + assert "Coordinatenstelsel" in measurements.columns + assert "Naam" in measurements.columns + assert "X" in measurements.columns + assert "Y" in measurements.columns + assert "Parameter_Wat_Omschrijving" in measurements.columns + assert "Code" in measurements.columns def test_measurements_freq_yearly(location, measurements): @@ -67,8 +82,8 @@ def test_measurements_freq_yearly(location, measurements): def test_measurements_freq_none(location, measurements): start_date = dt.datetime(1953, 1, 1) end_date = dt.datetime(1953, 4, 1) - measurements_yearly = ddlpy.measurements(location, start_date=start_date, end_date=end_date, freq=None) - assert measurements.shape == measurements_yearly.shape + measurements_monthly = ddlpy.measurements(location, start_date=start_date, end_date=end_date, freq=None) + assert measurements.shape == measurements_monthly.shape def test_measurements_available(location): diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index d46389a..84a04de 100755 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -4,18 +4,17 @@ """Tests for `ddlpy` package.""" import pytest - import requests - -from ddlpy import ddlpy +import ddlpy -@pytest.fixture +@pytest.fixture(scope="session") def endpoints(): """ Get the endpoints from the api """ - return ddlpy.ENDPOINTS + return ddlpy.ddlpy.ENDPOINTS + @pytest.fixture def collect_catalogue_resp(endpoints): @@ -56,6 +55,7 @@ def check_observations_available_resp(endpoints): def test_check_observations_available(check_observations_available_resp): assert check_observations_available_resp.status_code == 200 + @pytest.fixture def collect_number_of_observations_resp(endpoints): endpoint = endpoints['collect_number_of_observations'] @@ -65,6 +65,7 @@ def collect_number_of_observations_resp(endpoints): def test_collect_number_of_observations(collect_number_of_observations_resp): assert collect_number_of_observations_resp.status_code == 200 + @pytest.fixture def request_bulk_observations_resp(endpoints): endpoint = endpoints['request_bulk_observations'] diff --git a/tests/test_utils.py b/tests/test_utils.py index f06796a..d7dbf2b 100755 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,17 +3,17 @@ """Tests for `utils` package.""" -from ddlpy import utils +from ddlpy.utils import date_series import datetime -def test_content(): +def test_date_series(): """Sample pytest test function with the pytest fixture as an argument.""" # from bs4 import BeautifulSoup # assert 'GitHub' in BeautifulSoup(response.content).title.string start = datetime.datetime(2018, 1, 1) end = datetime.datetime(2018, 3, 1) - result = utils.date_series(start, end) + result = date_series(start, end) expected = [ (datetime.datetime(2018, 1, 1, 0, 0), datetime.datetime(2018, 2, 1, 0, 0)), (datetime.datetime(2018, 2, 1, 0, 0), datetime.datetime(2018, 3, 1, 0, 0)) @@ -22,7 +22,7 @@ def test_content(): start = datetime.datetime(2017, 11, 15) end = datetime.datetime(2018, 3, 5) - result = utils.date_series(start, end) + result = date_series(start, end) expected = [ (datetime.datetime(2017, 11, 15, 0, 0), datetime.datetime(2017, 12, 15, 0, 0)), (datetime.datetime(2017, 12, 15, 0, 0), datetime.datetime(2018, 1, 15, 0, 0)),