forked from sr2/cloud-api
tests: service tests standardised
This commit is contained in:
parent
71adc3fc6a
commit
1c394e9e23
1 changed files with 35 additions and 16 deletions
|
|
@ -2,28 +2,18 @@
|
||||||
409 on [POST]/service/ not tested because SQLite throws a different error than Postgres
|
409 on [POST]/service/ not tested because SQLite throws a different error than Postgres
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from httpx import AsyncClient
|
from httpx import AsyncClient
|
||||||
|
|
||||||
from .conftest import generate_query_and_status, generate_body_and_status
|
from .conftest import generate_query_and_status, generate_body_and_status, standard_test
|
||||||
|
|
||||||
pytestmark = [
|
pytestmark = [
|
||||||
pytest.mark.service_module,
|
pytest.mark.service_module,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
|
||||||
async def test_get_services_success(default_client: AsyncClient):
|
|
||||||
resp = await default_client.get("/service?org_id=1")
|
|
||||||
data = resp.json()
|
|
||||||
|
|
||||||
assert resp.status_code == 200
|
|
||||||
assert "services" in data
|
|
||||||
assert isinstance(data["services"], list)
|
|
||||||
assert data["services"][0]["id"] == 1
|
|
||||||
assert data["services"][0]["name"] == "Test Service"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["org_id"]))
|
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["org_id"]))
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_get_services_status_checks(
|
async def test_get_services_status_checks(
|
||||||
|
|
@ -91,7 +81,36 @@ async def test_patch_services_status_checks(
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_delete_service_success(default_client: AsyncClient):
|
async def test_get_services_standard(
|
||||||
resp = await default_client.delete("/service?service_id=1")
|
default_client: AsyncClient, route_data: dict[str, dict[str, Any]]
|
||||||
|
):
|
||||||
|
method = "GET"
|
||||||
|
path = "/service"
|
||||||
|
auth_level = "Root User"
|
||||||
|
query = "?org_id=1"
|
||||||
|
body = {}
|
||||||
|
expected_data = {
|
||||||
|
"services": [
|
||||||
|
{"id": 1, "name": "Test Service"},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
assert resp.status_code == 204
|
await standard_test(
|
||||||
|
default_client, method, path, auth_level, query, body, expected_data, route_data
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.anyio
|
||||||
|
async def test_delete_service_standard(
|
||||||
|
default_client: AsyncClient, route_data: dict[str, dict[str, Any]]
|
||||||
|
):
|
||||||
|
method = "DELETE"
|
||||||
|
path = "/service"
|
||||||
|
auth_level = "Super Admin"
|
||||||
|
query = "?service_id=1"
|
||||||
|
body = {}
|
||||||
|
expected_data = {}
|
||||||
|
|
||||||
|
await standard_test(
|
||||||
|
default_client, method, path, auth_level, query, body, expected_data, route_data
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue