Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Changelog
=========

DEV
===
2.7.0 (2025-11-07)
==================

* Added enhydris_api_client.put_timeseries().
* enhydris_api_client.list_stations() now accepts a query string.
* Added textbisect module.
* Added type hints.
Expand Down
8 changes: 5 additions & 3 deletions docs/enhydris_api_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ Reference
.. method:: list_timeseries(self, station_id, timeseries_group_id)
get_timeseries(self, station_id, timeseries_group_id, timeseries_id)
post_timeseries(self, station_id, timeseries_group_id, data)
put_timeseries(self, station_id, timeseries_group_id, timeseries_id, data)
delete_timeseries(self, station_id, timeseries_group_id, timeseries_id)

Methods that create, retrieve or delete time series. Similar to
the ones for station. :meth:`~EnhydrisApiClient.list_timeseries`
returns a list of dictionaries.
Methods that create, retrieve, update or delete time series.
Similar to the ones for station.
:meth:`~EnhydrisApiClient.list_timeseries` returns a list of
dictionaries.

.. method:: read_tsdata(self, station_id, timeseries_group_id, timeseries_id, start_date=None, end_date=None, timezone=None)
.post_tsdata(self, station_id, timeseries_group_id, timeseries_id, ts)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ skip = ["_version.py"]
extra_standard_library = ["cpython", "libc"]

[tool.pyright]
ignore = ["osgeo.*", "django.contrib.gis.*"]
ignore = ["osgeo.*"]
17 changes: 17 additions & 0 deletions src/enhydris_api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,23 @@ def post_timeseries(
self.check_response()
return self.response.json()["id"]

def put_timeseries(
self,
station_id: int,
timeseries_group_id: int,
timeseries_id: int,
data: JSONDict,
) -> None:
self.response = self.session.put(
urljoin(
self.base_url,
f"api/stations/{station_id}/timeseriesgroups/{timeseries_group_id}/"
f"timeseries/{timeseries_id}/",
),
data=data,
)
self.check_response()

def delete_timeseries(
self, station_id: int, timeseries_group_id: int, timeseries_id: int
) -> None:
Expand Down
Empty file added src/evaporation/py.typed
Empty file.
Empty file added src/hspatial/py.typed
Empty file.
Empty file added src/htimeseries/py.typed
Empty file.
Empty file added src/rocc/py.typed
Empty file.
Empty file added src/textbisect/py.typed
Empty file.
11 changes: 11 additions & 0 deletions tests/enhydris_api_client/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ def test_returns_id(self) -> None:
self.assertEqual(self.data, 43)


@mock_session()
class PutTimeseriesTestCase(TestCase):
def test_makes_request(self, m: mock.MagicMock) -> None:
client = EnhydrisApiClient("https://mydomain.com")
client.put_timeseries(41, 42, 43, data={"location": "Syria"})
m.return_value.put.assert_called_once_with(
"https://mydomain.com/api/stations/41/timeseriesgroups/42/timeseries/43/",
data={"location": "Syria"},
)


class FailedPostTimeseriesTestCase(TestCase):
@mock_session(**{"post.return_value.status_code": 404})
def test_raises_exception_on_error(self, m: mock.MagicMock) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/hspatial/test_hspatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import numpy as np
import pandas as pd
from django.contrib.gis.gdal import GDALRaster # type: ignore
from django.contrib.gis.gdal import GDALRaster
from django.contrib.gis.geos import Point as GeoDjangoPoint
from osgeo import gdal, ogr, osr

Expand Down Expand Up @@ -154,7 +154,7 @@ def setUp(self) -> None:
)

# Our grid represents a 70x150m area, lower-left co-ordinates (0, 0).
self.dataset.geotransform = (0, 10, 0, 70, 0, -10)
self.dataset.geotransform = [0, 10, 0, 70, 0, -10]

self.target_band = self.dataset.bands[1]

Expand Down
Loading