Skip to content

Commit

Permalink
fix issues raised by ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
sheenacodes committed Oct 9, 2023
1 parent 79dc417 commit 0542d45
Showing 1 changed file with 24 additions and 35 deletions.
59 changes: 24 additions & 35 deletions tests/test_api_cesva.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import os
from datetime import datetime, timedelta, timezone
import json
import httpx

Expand All @@ -11,39 +10,27 @@


# query params
PARAMS = {
"x-api-key": API_TOKEN
}
PARAMS = {"x-api-key": API_TOKEN}

# Body
PAYLOAD = {"sensors":[
{
"sensor":"TA120-T246187-N",
"observations":[
{"value":"61.2", "timestamp":"24/02/2022T17:45:15UTC"}
]
},{
"sensor":"TA120-T246187-O",
"observations":[
{"value":"false", "timestamp":"24/02/2022T17:45:15UTC"}
]
},{
"sensor":"TA120-T246187-U",
"observations":[
{"value":"false", "timestamp":"24/02/2022T17:45:15UTC"}
]
},{
"sensor":"TA120-T246187-M",
"observations":[
{"value":"77", "timestamp":"24/02/2022T17:45:15UTC"}
]
},{
"sensor":"TA120-T246187-S",
"observations":[
{"value":"060.6,0,0;060.8,0,0;060.4,0,0;059.9,0,0;059.9,0,0;060.6,0,0;060.7,0,0;060.4,0,0;059.9,0,0;059.9,0,0;060.2,0,0;060.4,0,0;060.8,0,0;059.9,0,0;059.7,0,0;060.6,0,0;061.1,0,0;061.1,0,0;060.6,0,0;061.3,0,0;061.4,0,0;060.6,0,0;060.7,0,0;060.6,0,0;061.4,0,0;061.3,0,0;061.0,0,0;060.3,0,0;059.6,0,0;059.6,0,0;060.4,0,0;062.0,0,0;062.6,0,0;061.7,0,0;061.8,0,0;062.5,0,0;061.8,0,0;062.1,0,0;061.6,0,0;061.1,0,0;063.0,0,0;061.2,0,0;061.1,0,0;060.6,0,0;060.1,0,0;061.8,0,0;062.1,0,0;062.4,0,0;061.5,0,0;061.9,0,0;062.5,0,0;061.9,0,0;061.1,0,0;061.8,0,0;062.0,0,0;062.2,0,0;062.2,0,0;062.9,0,0;062.2,0,0;061.3,0,0", "timestamp":"24/02/2022T17:45:15UTC"}
]
}
]}
PAYLOAD = {
"sensors": [
{"sensor": "TA120-T246187-N", "observations": [{"value": "61.2", "timestamp": "24/02/2022T17:45:15UTC"}]},
{"sensor": "TA120-T246187-O", "observations": [{"value": "false", "timestamp": "24/02/2022T17:45:15UTC"}]},
{"sensor": "TA120-T246187-U", "observations": [{"value": "false", "timestamp": "24/02/2022T17:45:15UTC"}]},
{"sensor": "TA120-T246187-M", "observations": [{"value": "77", "timestamp": "24/02/2022T17:45:15UTC"}]},
{
"sensor": "TA120-T246187-S",
"observations": [
{
"value": "060.6,0,0;060.8,0,0;060.4,0,0;059.9,0,0;059.9,0,0;060.6,0,0; \
060.7,0,0;060.4,0,0;059.9,0,0;059.9,0,0;060.2,0,0;060.4,0,0;",
"timestamp": "24/02/2022T17:45:15UTC",
}
],
},
]
}


def test_service_up():
Expand All @@ -57,7 +44,9 @@ def test_cesva_endpoint_up():
url = f"{API_BASE_URL}/api/v1/cesva"
resp = httpx.put(url)
assert resp.status_code == 401, "error: /api/v1/cesva accessible without token"
assert resp.text.startswith("Missing or invalid authentication token"), "error: /api/v1/cesva accessible without token"
assert resp.text.startswith(
"Missing or invalid authentication token"
), "error: /api/v1/cesva accessible without token"


def test_cesva_endppoint_authenticated_access():
Expand All @@ -75,8 +64,8 @@ def test_cesva_endppoint_authenticated_access():


def main():
#test_service_up()
#test_cesva_endpoint_up()
# test_service_up()
# test_cesva_endpoint_up()
test_cesva_endppoint_authenticated_access()


Expand Down

0 comments on commit 0542d45

Please sign in to comment.