diff --git a/care/facility/api/viewsets/asset.py b/care/facility/api/viewsets/asset.py index caf784cb9f..2563dfaf45 100644 --- a/care/facility/api/viewsets/asset.py +++ b/care/facility/api/viewsets/asset.py @@ -401,7 +401,7 @@ def operate_assets(self, request, *args, **kwargs): asset_class: BaseAssetIntegration = AssetClasses[asset.asset_class].value( { **asset.meta, - "id": asset.external_id, + "id": str(asset.external_id), "middleware_hostname": middleware_hostname, } ) diff --git a/care/facility/tasks/asset_monitor.py b/care/facility/tasks/asset_monitor.py index 9c8701618c..1adfa725ae 100644 --- a/care/facility/tasks/asset_monitor.py +++ b/care/facility/tasks/asset_monitor.py @@ -65,7 +65,7 @@ def check_asset_status(): # noqa: PLR0912 ].value( { **asset.meta, - "id": asset.external_id, + "id": str(asset.external_id), "middleware_hostname": resolved_middleware, } ) diff --git a/care/facility/tests/test_asset_api.py b/care/facility/tests/test_asset_api.py index 3989a19eef..0e96498d4b 100644 --- a/care/facility/tests/test_asset_api.py +++ b/care/facility/tests/test_asset_api.py @@ -6,6 +6,7 @@ from care.facility.models import Asset, Bed from care.users.models import User from care.utils.assetintegration.asset_classes import AssetClasses +from care.utils.assetintegration.base import BaseAssetIntegration from care.utils.assetintegration.hl7monitor import HL7MonitorAsset from care.utils.assetintegration.onvif import OnvifAsset from care.utils.assetintegration.ventilator import VentilatorAsset @@ -39,6 +40,26 @@ def validate_invalid_meta(self, asset_class, meta): with self.assertRaises(ValidationError): asset_class(meta) + def test_asset_class_initialization(self): + asset = self.create_asset( + self.asset_location, + asset_class=AssetClasses.ONVIF.name, + meta={ + "local_ip_address": "192.168.0.1", + "camera_access_key": "username:password:access_key", + "middleware_hostname": "middleware.local", + "insecure_connection": True, + }, + ) + asset_class = AssetClasses[asset.asset_class].value( + { + **asset.meta, + "id": str(asset.external_id), + "middleware_hostname": "middleware.local", + } + ) + self.assertIsInstance(asset_class, BaseAssetIntegration) + def test_meta_validations_for_onvif_asset(self): valid_meta = { "local_ip_address": "192.168.0.1",