From dd57c1d24f7983dec356026b504e8f215071c30b Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 16 Nov 2026 04:55:19 +0000 Subject: [PATCH 1/2] Test: the Metrics component is in the list of components the Engine returns The on-premise device detection specification says the Metrics component MUST also be added to the list of components returned by the Engine (device-detection-specification/pipeline-elements/device-detection-on-premise.md line 464 at dbaf099c712e2bd3a2a80bfb4eaf284b079f05eb). DD-21. --- .../tests/test_properties.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/device-detection/fiftyone_devicedetection_onpremise/tests/test_properties.py b/device-detection/fiftyone_devicedetection_onpremise/tests/test_properties.py index 172b81b2..876eb1c7 100644 --- a/device-detection/fiftyone_devicedetection_onpremise/tests/test_properties.py +++ b/device-detection/fiftyone_devicedetection_onpremise/tests/test_properties.py @@ -158,6 +158,39 @@ def test_match_metrics_metadata(self): "component": "Metrics"}, properties_list[name.lower()]) + def test_components_include_metrics(self): + + """! + Tests that the components the engine returns are those of the data + file followed by "Metrics", the component of the match metric + properties, as the specification says it MUST also be added to the + list of components returned by the Engine. + """ + + native = deviceDetectionOnPremiseEngine.engine.getMetaData() \ + .getComponents() + from_data_file = [ + native.getByIndex(index).getName() + for index in range(native.getSize())] + + components = deviceDetectionOnPremiseEngine.get_components() + + self.assertNotIn("Metrics", from_data_file) + self.assertEqual(from_data_file + ["Metrics"], components) + + def test_every_property_component_is_listed(self): + + """! + Tests that the component of every property the engine lists, the + match metric properties included, is in the list of components the + engine returns. + """ + + components = deviceDetectionOnPremiseEngine.get_components() + + for meta in deviceDetectionOnPremiseEngine.get_properties().values(): + self.assertIn(meta["component"], components, meta["name"]) + def test_match_metrics_follow_the_data_file_properties(self): """! From 556719d8777ab452fbc5c094d2ae7cb5551ed9c4 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 16 Nov 2026 04:55:43 +0000 Subject: [PATCH 2/2] Fix: the on-premise engine returns its components with Metrics added get_components gives the names of the data file's components followed by Metrics, the component of the match metric properties, as device-detection-specification/pipeline-elements/device-detection-on-premise.md line 464 at dbaf099c712e2bd3a2a80bfb4eaf284b079f05eb requires. DD-21. --- .../devicedetection_onpremise.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/device-detection/fiftyone_devicedetection_onpremise/src/fiftyone_devicedetection_onpremise/devicedetection_onpremise.py b/device-detection/fiftyone_devicedetection_onpremise/src/fiftyone_devicedetection_onpremise/devicedetection_onpremise.py index 8827f80a..2bb32bdd 100644 --- a/device-detection/fiftyone_devicedetection_onpremise/src/fiftyone_devicedetection_onpremise/devicedetection_onpremise.py +++ b/device-detection/fiftyone_devicedetection_onpremise/src/fiftyone_devicedetection_onpremise/devicedetection_onpremise.py @@ -522,3 +522,27 @@ def process_internal(self, flow_data): def get_component(self, property): return self.engine.getMetaData().getComponentForProperty(property).getName() + + def get_components(self): + + """! + The names of the components the engine returns: those of the data + file in use, in the order the native code gives them, followed by + "Metrics", the component of the match metric properties, which the + native code does not give. The list is read from the data file each + time, so it follows a refresh. + + @rtype: list + @return: the component names + """ + + if getattr(self, "engine", None) is None: + raise Exception(ENGINE_CLOSED) + + components = self.engine.getMetaData().getComponents() + names = [ + components.getByIndex(index).getName() + for index in range(components.getSize())] + if MATCH_METRICS_COMPONENT not in names: + names.append(MATCH_METRICS_COMPONENT) + return names