Skip to content

Commit 879d96c

Browse files
author
Aravindhan Palanisamy
committed
fix types
1 parent 3e319ab commit 879d96c

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

examples/assetmanagement/assets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
AssetBusType,
44
AssetDiscoveryType,
55
AssetLocationForCreate,
6+
AssetPresence,
67
AssetPresenceStatus,
78
AssetType,
89
CreateAssetRequest,
@@ -45,7 +46,7 @@
4546
is_NI_asset=True,
4647
workspace="846e294a-a007-47ac-9fc2-fac07eab240e",
4748
location=AssetLocationForCreate(
48-
state=AssetLocationForCreate(asset_presence=AssetPresenceStatus.PRESENT)
49+
state=AssetPresence(asset_presence=AssetPresenceStatus.PRESENT)
4950
),
5051
external_calibration=ExternalCalibration(
5152
temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)],

nisystemlink/clients/assetmanagement/_asset_management_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def create_assets(
5454

5555
@post("query-assets")
5656
def __query_assets(
57-
self, query: models.QueryAssetsRequest
57+
self, query: models._QueryAssetsRequest
5858
) -> models.QueryAssetsResponse:
5959
"""Query Assets.
6060
@@ -104,7 +104,7 @@ def query_assets(
104104

105105
query_params = {k: v for k, v in query_params.items() if v is not None}
106106

107-
query_request = models._QueryAssetRequest(**query_params)
107+
query_request = models._QueryAssetsRequest(**query_params)
108108

109109
return self.__query_assets(query=query_request)
110110

nisystemlink/clients/assetmanagement/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ._create_asset_request import CreateAssetRequest
44
from ._create_assets_partial_success_response import CreateAssetsPartialSuccessResponse
55
from ._delete_assets_response import DeleteAssetsResponse
6-
from ._query_assets_request import AssetField, QueryAssetsRequest, _QueryAssetRequest
6+
from ._query_assets_request import AssetField, QueryAssetsRequest, _QueryAssetsRequest
77
from ._query_assets_response import QueryAssetsResponse
88
from ._asset_location import (
99
AssetLocation,

nisystemlink/clients/assetmanagement/models/_asset_location.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class AssetPresence(JsonModel):
4747
"""Gets or sets the status of an asset's presence in a system."""
4848

4949

50-
class AssetLocation(JsonModel):
51-
"""Model for information about the asset location, presence and the connection status of the system."""
50+
class _AssetLocation(JsonModel):
51+
"""local model for information about the asset location, presence and the connection status of the system."""
5252

5353
minion_id: Optional[str] = None
5454
"""Gets or sets identifier of the minion where the asset is located."""
@@ -65,11 +65,15 @@ class AssetLocation(JsonModel):
6565
slot_number: Optional[int] = None
6666
"""Gets or sets the number of the slot in which the asset is located."""
6767

68+
69+
class AssetLocation(_AssetLocation):
70+
"""Model for information about the asset location, presence and the connection status of the system."""
71+
6872
state: AssetPresenceWithSystemConnection
6973
"""Presence of an asset and the connection of the system in which it resides."""
7074

7175

72-
class AssetLocationForCreate(AssetLocation):
76+
class AssetLocationForCreate(_AssetLocation):
7377
"""Model for information about the asset presence status of the system, used while create"""
7478

7579
state: AssetPresence

nisystemlink/clients/assetmanagement/models/_query_assets_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class QueryAssetsRequest(JsonModel):
7878
"""Gets or sets the filter criteria for assets. Consists of a string of queries composed using AND/OR operators."""
7979

8080

81-
class _QueryAssetRequest(JsonModel):
81+
class _QueryAssetsRequest(JsonModel):
8282
"""Model for object containing filters to apply when retrieving assets."""
8383

8484
projection: Optional[str] = None

tests/integration/assetmanagement/test_asset_management.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def create_asset(client: AssetManagementClient):
2828
responses: List[CreateAssetsPartialSuccessResponse] = []
2929

3030
def _create_assets(
31-
new_assets: CreateAssetRequest,
31+
new_assets: List[CreateAssetRequest],
3232
) -> CreateAssetsPartialSuccessResponse:
3333
response = client.create_assets(assets=new_assets)
3434
responses.append(response)
@@ -40,7 +40,9 @@ def _create_assets(
4040
for response in responses:
4141
if response.assets:
4242
created_assets = created_assets + response.assets
43-
client.delete_assets(ids=[asset.id for asset in created_assets])
43+
client.delete_assets(
44+
ids=[asset.id for asset in created_assets if asset.id is not None]
45+
)
4446

4547

4648
@pytest.fixture(scope="class")
@@ -161,7 +163,7 @@ def test__query_assets_with_take_value__returns_specific_number_of_assets(
161163

162164
assert response is not None
163165
assert response.assets is not None and len(response.assets) == 1
164-
assert response.total_count >= 1
166+
assert response.total_count is not None and response.total_count >= 1
165167

166168
def test_query_assets_with_projections__returns_the_assets_with_projected_properties(
167169
self, client: AssetManagementClient
@@ -172,6 +174,7 @@ def test_query_assets_with_projections__returns_the_assets_with_projected_proper
172174
response = client.query_assets(query=query_asset)
173175

174176
assert response is not None
177+
assert response.assets is not None
175178
assert all(
176179
asset.id is not None
177180
and asset.name is not None

0 commit comments

Comments
 (0)