Skip to content

Commit

Permalink
feat: test case for asset_sensors API
Browse files Browse the repository at this point in the history
Signed-off-by: joshuaunity <[email protected]>
  • Loading branch information
joshuaunity committed Sep 25, 2024
1 parent f8ebe9b commit 5d9b547
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions flexmeasures/api/v3_0/tests/test_assets_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json

# from operator import is_

from flask import url_for
import pytest
from sqlalchemy import select, func
Expand All @@ -11,6 +9,7 @@
from flexmeasures.data.services.users import find_user_by_email
from flexmeasures.api.tests.utils import get_auth_token, UserContext, AccountContext
from flexmeasures.api.v3_0.tests.utils import get_asset_post_data
from flexmeasures.utils.unit_utils import is_valid_unit


@pytest.mark.parametrize(
Expand Down Expand Up @@ -119,27 +118,27 @@ def test_get_assets(
assert turbine
assert turbine["account_id"] == setup_accounts["Supplier"].id

# @pytest.mark.parametrize("requesting_user", ["[email protected]"], indirect=True)
# def test_fetch_asset_sensors(client, setup_api_test_data, requesting_user):
# """
# Retrieve all sensors associated with a specific asset.

# This endpoint returns a paginated list of sensors under the given asset.
# The response will include metadata such as the total number of records and
# filtered records when pagination is applied.
# """
# asset_id = 1

# response = client.get(url_for("AssetAPI:asset_sensors", id=asset_id))
@pytest.mark.parametrize("requesting_user", ["[email protected]"], indirect=True)
def test_fetch_asset_sensors(client, setup_api_test_data, requesting_user):
"""
Retrieve all sensors associated with a specific asset.
# print("Server responded with:\n%s" % response.json)
This endpoint returns a paginated list of sensors under the given asset.
The response will include metadata such as the total number of records and
filtered records when pagination is applied.
"""
asset_id = 5

# assert response.status_code == 200
# assert response.json["status"] == 200
# assert is_(response.json["data"]) == list
response = client.get(url_for("AssetAPI:asset_sensors", id=asset_id))

print("Server responded with:\n%s" % response.json)

# assert is_(response.json["data"][0]) == dict
assert response.status_code == 200
assert response.json["status"] == 200
assert isinstance(response.json["data"], list)
assert isinstance(response.json["data"][0], dict)
assert is_valid_unit(response.json["data"][0]["unit"])


@pytest.mark.parametrize("requesting_user", ["[email protected]"], indirect=True)
Expand Down

0 comments on commit 5d9b547

Please sign in to comment.