Skip to content

Commit

Permalink
refactor: review suggestions, changed test asserts
Browse files Browse the repository at this point in the history
Signed-off-by: GustaafL <guus@seita.nl>
  • Loading branch information
GustaafL committed Jul 19, 2023
1 parent fa465c8 commit cf83385
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
1 change: 0 additions & 1 deletion flexmeasures/api/v3_0/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,5 +529,4 @@ def fetch_one(self, id, sensor):
:status 403: INVALID_SENDER
:status 422: UNPROCESSABLE_ENTITY
"""
sensor = Sensor.query.filter(Sensor.id == 1).one_or_none()
return sensor_schema.dump(sensor), 200
14 changes: 4 additions & 10 deletions flexmeasures/api/v3_0/tests/test_sensors_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,17 @@ def test_fetch_one_sensor(
setup_api_test_data: dict[str, Sensor],
):
sensor_id = 1
assert_response = {
"name": "some gas sensor",
"unit": "m³/h",
"entity_address": "ea1.2023-08.localhost:fm1.1",
"event_resolution": 10,
"generic_asset_id": 4,
"timezone": "UTC",
"status": 200,
}
headers = make_headers_for("test_supplier_user_4@seita.nl", client)
response = client.get(
url_for("SensorAPI:fetch_one", id=sensor_id),
headers=headers,
)
print("Server responded with:\n%s" % response.json)
assert response.status_code == 200
assert response.json == assert_response
assert response.json["name"] == "some gas sensor"
assert response.json["unit"] == "m³/h"
assert response.json["generic_asset_id"] == 4
assert response.json["timezone"] == "UTC"


def make_headers_for(user_email: str | None, client) -> dict:
Expand Down

0 comments on commit cf83385

Please sign in to comment.