-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: test case for asset_sensors API
Signed-off-by: joshuaunity <[email protected]>
- Loading branch information
1 parent
f8ebe9b
commit 5d9b547
Showing
1 changed file
with
17 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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( | ||
|
@@ -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) | ||
|