From c73bb40ee921d54768fed534de42f4820de6b06e Mon Sep 17 00:00:00 2001 From: Tyler Nguyen Date: Wed, 24 Jul 2024 12:37:01 -0500 Subject: [PATCH] Reverted all changes --- .../measurement/service.py | 5 +--- .../example.ErrorAnnotations.serviceconfig | 19 -------------- .../example.ErrorCollections.serviceconfig | 19 -------------- .../example.ErrorDisplayName.serviceconfig | 19 -------------- .../example.ErrorTags.serviceconfig | 19 -------------- packages/service/tests/unit/test_service.py | 25 ------------------- 6 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 packages/service/tests/assets/check_char/example.ErrorAnnotations.serviceconfig delete mode 100644 packages/service/tests/assets/check_char/example.ErrorCollections.serviceconfig delete mode 100644 packages/service/tests/assets/check_char/example.ErrorDisplayName.serviceconfig delete mode 100644 packages/service/tests/assets/check_char/example.ErrorTags.serviceconfig diff --git a/packages/service/ni_measurement_plugin_sdk_service/measurement/service.py b/packages/service/ni_measurement_plugin_sdk_service/measurement/service.py index 625faf454..ab8718563 100644 --- a/packages/service/ni_measurement_plugin_sdk_service/measurement/service.py +++ b/packages/service/ni_measurement_plugin_sdk_service/measurement/service.py @@ -210,10 +210,7 @@ def __init__( raise RuntimeError(f"File does not exist. {service_config_path}") with open(service_config_path) as service_config_file: - try: - service_config = json.loads(service_config_file.read()) - except json.decoder.JSONDecodeError: - raise NameError(f"Invalid character(s) in {service_config_path}") + service_config = json.load(service_config_file) if service_class is None: service = next(iter(service_config["services"]), None) diff --git a/packages/service/tests/assets/check_char/example.ErrorAnnotations.serviceconfig b/packages/service/tests/assets/check_char/example.ErrorAnnotations.serviceconfig deleted file mode 100644 index 5a070d54f..000000000 --- a/packages/service/tests/assets/check_char/example.ErrorAnnotations.serviceconfig +++ /dev/null @@ -1,19 +0,0 @@ -{ - "services": [ - { - "displayName": "SampleMeasurement", - "serviceClass": "SampleMeasurement_Python", - "descriptionUrl": "https://www.example.com/SampleMeasurement.html", - "providedInterfaces": [ - "ni.measurementlink.measurement.v1.MeasurementService", - "ni.measurementlink.measurement.v2.MeasurementService" - ], - "path": "start.bat", - "annotations": { - "ni/service.description": """, - "ni/service.collection": "CurrentTests.Inrush", - "ni/service.tags": [ "powerup", "current" ] - } - } - ] -} \ No newline at end of file diff --git a/packages/service/tests/assets/check_char/example.ErrorCollections.serviceconfig b/packages/service/tests/assets/check_char/example.ErrorCollections.serviceconfig deleted file mode 100644 index 1dc3c2f05..000000000 --- a/packages/service/tests/assets/check_char/example.ErrorCollections.serviceconfig +++ /dev/null @@ -1,19 +0,0 @@ -{ - "services": [ - { - "displayName": "SampleMeasurement\", - "serviceClass": "SampleMeasurement_Python", - "descriptionUrl": "https://www.example.com/SampleMeasurement.html", - "providedInterfaces": [ - "ni.measurementlink.measurement.v1.MeasurementService", - "ni.measurementlink.measurement.v2.MeasurementService" - ], - "path": "start.bat", - "annotations": { - "ni/service.description": "Measure inrush current with a shorted load and validate results against configured limits.", - "ni/service.collection": "\", - "ni/service.tags": [ "powerup", "current" ] - } - } - ] -} \ No newline at end of file diff --git a/packages/service/tests/assets/check_char/example.ErrorDisplayName.serviceconfig b/packages/service/tests/assets/check_char/example.ErrorDisplayName.serviceconfig deleted file mode 100644 index 7df8043f4..000000000 --- a/packages/service/tests/assets/check_char/example.ErrorDisplayName.serviceconfig +++ /dev/null @@ -1,19 +0,0 @@ -{ - "services": [ - { - "displayName": "\\SampleMeasurement\", - "serviceClass": "SampleMeasurement_Python", - "descriptionUrl": "https://www.example.com/SampleMeasurement.html", - "providedInterfaces": [ - "ni.measurementlink.measurement.v1.MeasurementService", - "ni.measurementlink.measurement.v2.MeasurementService" - ], - "path": "start.bat", - "annotations": { - "ni/service.description": "Measure inrush current with a shorted load and validate results against configured limits.", - "ni/service.collection": "CurrentTests.Inrush", - "ni/service.tags": [ "powerup", "current" ] - } - } - ] -} \ No newline at end of file diff --git a/packages/service/tests/assets/check_char/example.ErrorTags.serviceconfig b/packages/service/tests/assets/check_char/example.ErrorTags.serviceconfig deleted file mode 100644 index 053b7430a..000000000 --- a/packages/service/tests/assets/check_char/example.ErrorTags.serviceconfig +++ /dev/null @@ -1,19 +0,0 @@ -{ - "services": [ - { - "displayName": "SampleMeasurement\", - "serviceClass": "SampleMeasurement_Python", - "descriptionUrl": "https://www.example.com/SampleMeasurement.html", - "providedInterfaces": [ - "ni.measurementlink.measurement.v1.MeasurementService", - "ni.measurementlink.measurement.v2.MeasurementService" - ], - "path": "start.bat", - "annotations": { - "ni/service.description": "Measure inrush current with a shorted load and validate results against configured limits.", - "ni/service.collection": "CurrentTests.Inrush", - "ni/service.tags": [ "powerup", "\"" ] - } - } - ] -} \ No newline at end of file diff --git a/packages/service/tests/unit/test_service.py b/packages/service/tests/unit/test_service.py index 06b07e39e..46450ddd4 100644 --- a/packages/service/tests/unit/test_service.py +++ b/packages/service/tests/unit/test_service.py @@ -426,31 +426,6 @@ def test___service_config___create_measurement_service___service_info_matches_se assert measurement_service.service_info.annotations == provided_annotations -@pytest.mark.parametrize( - "service_config", - [ - "example.ErrorDisplayName.serviceconfig", - "example.ErrorAnnotations.serviceconfig", - "example.ErrorTags.serviceconfig", - "example.ErrorCollections.serviceconfig", - ], -) -def test___service_config___check_service_config___name_error_exception( - test_assets_directory: pathlib.Path, - service_config: str, -): - try: - MeasurementService( - service_config_path=test_assets_directory / f"check_char/{service_config}", - version="1.0.0.0", - ui_file_paths=[], - ) - error_occurred = False - except NameError: - error_occurred = True - assert error_occurred - - @pytest.mark.parametrize( "display_name,type,default_value,enum_type", [