From 18cdf7e25299730fd422193b1f2d5c81283f3960 Mon Sep 17 00:00:00 2001
From: Christoph Alt <christoph.alt@fau.de>
Date: Fri, 9 Sep 2022 15:59:22 +0200
Subject: [PATCH] added a test to test the time conversion

---
 tests/test_sqlite.py | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/tests/test_sqlite.py b/tests/test_sqlite.py
index da50b47..0d3774f 100644
--- a/tests/test_sqlite.py
+++ b/tests/test_sqlite.py
@@ -1,19 +1,15 @@
-import pytest
-from cbutil.postprocessing.sqlite_helper import (select_stmt,
-                                                 from_stmt,
-                                                 where_stmt,
-                                                 join_stmt,
-                                                 table_name_query,
-                                                 query_builder,
-                                                 )
+from datetime import datetime
 
-from cbutil.postprocessing.sqlite import (get_all_table_names,
-                                          tables2dict,
-                                          query_join,
-                                          iterate_all_tables,
-                                          build_iterate_query)
+import pytest
 
-from cbutil.postprocessing.sqlite import sqlite_context
+from cbutil.postprocessing.sqlite import (build_iterate_query,
+                                          get_all_table_names,
+                                          iterate_all_tables, query_join,
+                                          sqlite_context, tables2dict)
+from cbutil.postprocessing.sqlite_helper import (from_stmt, join_stmt,
+                                                 query_builder, select_stmt,
+                                                 table_name_query, where_stmt)
+from cbutil.util import time_conversion
 
 
 def test_select():
@@ -91,3 +87,13 @@ def test_build_iterate():
         for res in build_iterate_query(connection, from_table="timingPool",
                                        where_args=["runId", 1]):
             pass
+
+
+def test_time_stamp():
+    pattern = "%Y-%m-%d %H:%M:%S"
+    with sqlite_context("tests/benchmark.sqlite") as connection:
+        dicts = list(tables2dict(query_join(connection, "runs", "timingPool", "runId")))
+        for run in dicts:
+            ts = time_conversion(run["timestamp"], pattern=pattern)
+            date = datetime.fromtimestamp(ts).strftime(pattern)
+            assert run["timestamp"] == date
-- 
GitLab