test: baseline test suite — 86 tests covering auth, CRUD, settings, chat, terraform, reports, terminal
This commit is contained in:
111
backend/tests/test_adb_config.py
Normal file
111
backend/tests/test_adb_config.py
Normal file
@@ -0,0 +1,111 @@
|
||||
"""
|
||||
Tests for ADB (Autonomous Database) Config CRUD operations,
|
||||
including vector table management.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
_state: dict = {}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_create_adb_config(client, admin_headers):
|
||||
"""POST /api/adb/config — create via multipart form."""
|
||||
r = await client.post(
|
||||
"/api/adb/config",
|
||||
data={
|
||||
"config_name": "TestADB",
|
||||
"dsn": "test_high",
|
||||
"username": "testuser",
|
||||
"password": "testpass",
|
||||
},
|
||||
headers=admin_headers,
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
body = r.json()
|
||||
assert "id" in body
|
||||
_state["vid"] = body["id"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_list_adb_configs(client, admin_headers):
|
||||
"""GET /api/adb/configs — list must include created config."""
|
||||
r = await client.get("/api/adb/configs", headers=admin_headers)
|
||||
assert r.status_code == 200
|
||||
configs = r.json()
|
||||
assert isinstance(configs, list)
|
||||
assert any(c["id"] == _state["vid"] for c in configs)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_add_vector_table(client, admin_headers):
|
||||
"""POST /api/adb/{vid}/tables — add a vector table."""
|
||||
vid = _state["vid"]
|
||||
r = await client.post(
|
||||
f"/api/adb/{vid}/tables",
|
||||
json={"table_name": "TEST_TABLE"},
|
||||
headers=admin_headers,
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
body = r.json()
|
||||
assert "id" in body
|
||||
_state["tid"] = body["id"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_list_vector_tables(client, admin_headers):
|
||||
"""GET /api/adb/{vid}/tables — list must include created table."""
|
||||
vid = _state["vid"]
|
||||
r = await client.get(f"/api/adb/{vid}/tables", headers=admin_headers)
|
||||
assert r.status_code == 200
|
||||
tables = r.json()
|
||||
assert isinstance(tables, list)
|
||||
assert any(t["id"] == _state["tid"] for t in tables)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_update_vector_table(client, admin_headers):
|
||||
"""PUT /api/adb/{vid}/tables/{tid} — update description."""
|
||||
vid = _state["vid"]
|
||||
tid = _state["tid"]
|
||||
r = await client.put(
|
||||
f"/api/adb/{vid}/tables/{tid}",
|
||||
json={"description": "updated"},
|
||||
headers=admin_headers,
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_delete_vector_table(client, admin_headers):
|
||||
"""DELETE /api/adb/{vid}/tables/{tid} — remove table."""
|
||||
vid = _state["vid"]
|
||||
tid = _state["tid"]
|
||||
r = await client.delete(
|
||||
f"/api/adb/{vid}/tables/{tid}",
|
||||
headers=admin_headers,
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_update_adb_config(client, admin_headers):
|
||||
"""PUT /api/adb/configs/{vid} — update config_name via multipart form."""
|
||||
vid = _state["vid"]
|
||||
r = await client.put(
|
||||
f"/api/adb/configs/{vid}",
|
||||
data={
|
||||
"config_name": "UpdatedADB",
|
||||
"dsn": "test_high",
|
||||
"username": "testuser",
|
||||
},
|
||||
headers=admin_headers,
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_delete_adb_config(client, admin_headers):
|
||||
"""DELETE /api/adb/configs/{vid} — remove config."""
|
||||
vid = _state["vid"]
|
||||
r = await client.delete(f"/api/adb/configs/{vid}", headers=admin_headers)
|
||||
assert r.status_code == 200, r.text
|
||||
Reference in New Issue
Block a user