Skip to content

Commit

Permalink
feat(sensor): tests for patch response json
Browse files Browse the repository at this point in the history
Signed-off-by: GustaafL <guus@seita.nl>
  • Loading branch information
GustaafL committed Aug 2, 2023
1 parent bbca0dc commit 37d8359
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
14 changes: 3 additions & 11 deletions documentation/api/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ API change log

.. note:: The FlexMeasures API follows its own versioning scheme. This is also reflected in the URL, allowing developers to upgrade at their own pace.

v3.0-8 | 2023-08-01
v3.0-11 | 2023-08-02
"""""""""""""""""""

- Added REST endpoint for patching a sensor: `/sensor<id>` (PATCH)

v3.0-12 | 2023-07-31
"""""""""""""""""""

- Added REST endpoint for adding a sensor: `/sensors` (POST)

v3.0-11 | 2023-07-20
""""""""""""""""""""

- Added REST endpoint for fetching one sensor: `/sensors/<id>` (GET)
- Added REST endpoint for adding a sensor: `/sensors` (POST)
- Added REST endpoint for patching a sensor: `/sensor<id>` (PATCH)

v3.0-10 | 2023-06-12
""""""""""""""""""""
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/api/v3_0/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def post(self, sensor_data: dict):
@permission_required_for_context("update", ctx_arg_name="db_sensor")
@as_json
def patch(self, sensor_data: dict, id: int, db_sensor: Sensor):
"""Update an sensor given its identifier.
"""Update a sensor given its identifier.
.. :quickref: Sensor; Update a sensor
Expand Down
7 changes: 5 additions & 2 deletions flexmeasures/api/v3_0/tests/test_sensors_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ def test_patch_sensor(client, setup_api_test_data):
assert Sensor.query.filter(Sensor.name == "some gas sensor").one_or_none() is None


def test_patch_sensor_for_excluded_attribute(client, setup_api_test_data):
@pytest.mark.parametrize(
"attribute", ["generic_asset_id", "timezone", "entity_address"]

This comment has been minimized.

Copy link
@nhoening

nhoening Aug 2, 2023

Contributor

I don't believe timezone is excluded?

)
def test_patch_sensor_for_excluded_attribute(client, setup_api_test_data, attribute):
"""Test to change the generic_asset_id that should not be allowed.
The generic_asset_id is excluded in the partial_sensor_schema"""
auth_token = get_auth_token(client, "test_admin_user@seita.nl", "testtest")
Expand All @@ -135,7 +138,7 @@ def test_patch_sensor_for_excluded_attribute(client, setup_api_test_data):
url_for("SensorAPI:patch", id=sensor.id),
headers={"content-type": "application/json", "Authorization": auth_token},
json={
"generic_asset_id": 8,
attribute: 8,
},
)

Expand Down

0 comments on commit 37d8359

Please sign in to comment.