From 1a2d37391fba0220273197ca9dc2114a6d19e205 Mon Sep 17 00:00:00 2001 From: cortadocodes Date: Wed, 31 May 2023 12:22:10 +0100 Subject: [PATCH] TST: Update sensor coordinates in documentation and tests --- cloud_functions/big_query.py | 3 +- data_gateway/configuration.py | 2 +- docs/source/usage/configuration_files.rst | 138 ++-------------------- tests/test_cloud_functions/test_main.py | 6 +- tests/valid_configuration.json | 137 ++------------------- 5 files changed, 20 insertions(+), 266 deletions(-) diff --git a/cloud_functions/big_query.py b/cloud_functions/big_query.py index 58d6a25..2c99624 100644 --- a/cloud_functions/big_query.py +++ b/cloud_functions/big_query.py @@ -103,7 +103,8 @@ def add_sensor_data(self, data, node_id, configuration_id, installation_referenc batches = [rows[i : i + INSERT_BATCH_SIZE] for i in range(0, len(rows), INSERT_BATCH_SIZE)] for batch in batches: errors = self.client.insert_rows( - table=self.client.get_table(self.table_names["sensor_data"]), rows=batch + table=self.client.get_table(self.table_names["sensor_data"]), + rows=batch, ) if errors: diff --git a/data_gateway/configuration.py b/data_gateway/configuration.py index a6e1f70..06dd7ed 100644 --- a/data_gateway/configuration.py +++ b/data_gateway/configuration.py @@ -212,7 +212,7 @@ class NodeConfiguration: :param dict|None samples_per_packet: A map for each sensor, giving the number of samples sent in a packet from that sensor :param dict|None sensor_commands: :param dict|None sensor_conversion_constants: - :param dict sensor_coordinates: + :param dict sensor_coordinates: a mapping of sensor name to sensor coordinates reference :param list|None sensor_names: List of sensors present on the measurement node :param dict|None sleep_state: :return None: diff --git a/docs/source/usage/configuration_files.rst b/docs/source/usage/configuration_files.rst index 797f1f1..744567e 100644 --- a/docs/source/usage/configuration_files.rst +++ b/docs/source/usage/configuration_files.rst @@ -176,136 +176,13 @@ Here is an example of a more extensive configuration file. "battery_info": [1e6, 100, 256] }, "sensor_coordinates": { - "Mics": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Baros_P": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Baros_T": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Diff_Baros": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Acc": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Gyro": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Mag": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Analog Vbat": [[0, 0, 0]], - "Constat": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "battery_info": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ] + "Mics": "mics_coordinate_reference", + "Baros_P": "baros_coordinate_reference", + "Baros_T": "baros_coordinate_reference", + "Diff_Baros": "baros_coordinate_reference", + "Acc": "accelerometers_coordinate_reference", + "Gyro": "gyroscopes_coordinate_reference", + "Mag": "magnetometers_coordinate_reference" }, "sensor_names": [ "Mics", @@ -330,4 +207,3 @@ Here is an example of a more extensive configuration file. "description": null } } - diff --git a/tests/test_cloud_functions/test_main.py b/tests/test_cloud_functions/test_main.py index 883a7ed..7be92ab 100644 --- a/tests/test_cloud_functions/test_main.py +++ b/tests/test_cloud_functions/test_main.py @@ -390,7 +390,7 @@ def test_error_raised_if_installation_reference_already_exists(self): "reference": "hello", "receiver_firmware_version": "0.0.1", "turbine_id": "0", - "sensor_coordinates": {"blah_sensor": [[0, 0, 0]]}, + "sensor_coordinates": {"blah_sensor": "coordinate_reference"}, } ) @@ -408,7 +408,7 @@ def test_error_raised_if_internal_server_error_occurs(self): "reference": "hello", "receiver_firmware_version": "0.0.1", "turbine_id": "0", - "sensor_coordinates": {"blah_sensor": [[0, 0, 0]]}, + "sensor_coordinates": {"blah_sensor": "coordinate_reference"}, } ) @@ -444,7 +444,7 @@ def test_create_installation_with_only_required_inputs(self): "reference": "hello", "receiver_firmware_version": "0.0.1", "turbine_id": "0", - "sensor_coordinates": {"blah_sensor": [[0, 0, 0]]}, + "sensor_coordinates": {"blah_sensor": "coordinate_reference"}, } ) diff --git a/tests/valid_configuration.json b/tests/valid_configuration.json index ed87da8..1a4691c 100644 --- a/tests/valid_configuration.json +++ b/tests/valid_configuration.json @@ -221,136 +221,13 @@ "battery_info": [1e6, 100, 256] }, "sensor_coordinates": { - "Mics": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Baros_P": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Baros_T": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Diff_Baros": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Acc": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Gyro": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Mag": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "Analog Vbat": [[0, 0, 0]], - "Constat": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ], - "battery_info": [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0] - ] + "Mics": "mics_coordinate_reference", + "Baros_P": "baros_coordinate_reference", + "Baros_T": "baros_coordinate_reference", + "Diff_Baros": "baros_coordinate_reference", + "Acc": "accelerometers_coordinate_reference", + "Gyro": "gyroscopes_coordinate_reference", + "Mag": "magnetometers_coordinate_reference" }, "sensor_names": [ "Mics",