Files
service-aware-frontend/pkgs/clan-cli/tests/test_db_api.py
2023-11-27 22:18:45 +01:00

34 lines
1.1 KiB
Python

import pytest
import json
from api import TestClient
#########################
# #
# Producer #
# #
#########################
def test_producer(api: TestClient) -> None:
request_body = {
"uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df",
"service_name": "Carlo'\''s Printing",
"service_type": "3D Printing",
"endpoint_url": "http://127.0.0.1:8000",
"status": "unknown",
"other": {
"test": "test"
},
"entity_did": "did:sov:test:1234"
}
#test post
response = api.post(f"/api/v1/create_producer",
data=json.dumps(request_body),
headers={"Content-Type": "application/json"})
assert response.status_code == 200
assert response.json() == request_body
#test get
response = api.get(f"api/v1/get_producer?entity_did=did%3Asov%3Atest%3A1234&skip=0&limit=100")
assert response.status_code == 200
assert response.json() == [request_body]