Moves query logger duration into pytest.ini file

This commit is contained in:
Mouse Reeve 2024-08-09 13:39:06 -07:00
parent cc7250770c
commit 26b6699b26
2 changed files with 7 additions and 1 deletions

View file

@ -1,5 +1,10 @@
""" Log query runtimes for testing """
import time
from environs import Env
env = Env()
env.read_env()
MAX_QUERY_DURATION = float(env("MAX_QUERY_DURATION"))
class QueryLogger:
@ -30,7 +35,7 @@ class QueryLogger:
self.queries.append(current_query)
def raise_long_query_runtime(queries, threshold=0.0006):
def raise_long_query_runtime(queries, threshold=MAX_QUERY_DURATION):
"""Raises an exception if any query took longer than the threshold"""
for query in queries:
if query["duration"] > threshold:

View file

@ -28,3 +28,4 @@ env =
EMAIL_HOST_PASSWORD =
EMAIL_USE_TLS = true
ENABLE_PREVIEW_IMAGES = false
MAX_QUERY_DURATION = 0.005