Add utilities for testing

This commit is contained in:
Colin Goutte 2021-09-27 15:23:47 +02:00
parent 6942d66154
commit 6f75ce0adf
2 changed files with 32 additions and 0 deletions

View File

@ -1,3 +1,5 @@
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
@ -6,6 +8,7 @@ from papi.main import app
from papi.main import sondes
from papi import __version__
from . import utils as testutils
client = TestClient(app)

29
tests/utils.py Normal file
View File

@ -0,0 +1,29 @@
statuses = ("error", "warning", "pending", "ok")
def probe_sample_body(
*, channel_name: str = "Test channel", channel_id: int = -1, status: str = "ok"
):
if status not in statuses:
raise ValueError(f"{status} not in f{statuses}")
return {
"date": "2021-09-16T14:17:33.563Z",
"channels": [
{
"channelType": "fm",
"lastTimestamp": "2021-09-16T14:15:29.000Z",
"status": status,
"alarms": {
"noSignal": False,
"qualityIndexStatus": "warning",
"noWatermark": False,
"timestampDrift": True,
"unexpectedWatermark": False,
},
"name": channel_name,
"lastWatermarkId": 33336,
"id": channel_id,
},
],
}