diff --git a/tests/test_sqlite.py b/tests/test_sqlite.py index da50b47b290ff76beaf038b7d0c2bd84b23f23dd..0d3774f3712c6a89798cf283509fabceaa450342 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