Repository: kangasta/fdbk

Issue:
Data tools should ignore template topics
Do not add warning for missing data if topic is template topic.

Discussion:

Patch:
diff --git a/fdbk/_db_connection.py b/fdbk/_db_connection.py
index af155fe..66bcf62 100644
--- a/fdbk/_db_connection.py
+++ b/fdbk/_db_connection.py
@@ -312,6 +312,9 @@ class DBConnection:
             aggregate_always,
         )
         for topic_d in topics.values():
+            if topic_d["type"] == "template":
+                continue
+
             jobs.append(
                 executor.submit(
                     self._get_topic_statistics, topic_d, *params))


Test patch:
diff --git a/tst/test_db_connection.py b/tst/test_db_connection.py
index d4c1b8a..f368696 100644
--- a/tst/test_db_connection.py
+++ b/tst/test_db_connection.py
@@ -308,3 +308,18 @@ class DBConnectionTest(TestCase):
         result = C.get_summary(topic_id, aggregate_to=3)
         data = result["statistics"][0]["payload"]["data"]["datasets"][0]["data"]
         self.assertEqual(len(data), 3)
+
+    def test_overview_ignores_templates(self):
+        data_tools = [
+            {"field":"number", "method":"line"},
+        ]
+
+        units_d = {"field":"number", "unit":"scalar"}
+
+        C = DictConnection()
+        C.add_topic("Test template", type_str="template", fields=['number'], units=[units_d], data_tools=data_tools)
+        C.add_topic("Test topic", template="Test template")
+
+        data = C.get_overview()
+        self.assertEqual(len(data["warnings"]), 1)
+        self.assertNotIn(data["warnings"][0], "template")