Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,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
Original file line number Diff line number Diff line change
Expand Up @@ -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):

"""!
Expand Down
Loading