fix: adapt autotest to updated service APIs
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
"""
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
|
||||
|
||||
# ── Хелперы ──
|
||||
@@ -48,6 +49,46 @@ class TestScenarioLifecycle:
|
||||
data = resp.get_json()
|
||||
assert isinstance(data, list)
|
||||
|
||||
def test_manual_create_delete_uses_local_polygon(self, app_client, monkeypatch):
|
||||
"""Ручной API приложения проводит create и delete через локальный Polygon."""
|
||||
from api.http_client import HttpClient
|
||||
from routes import api_test as api_test_routes
|
||||
|
||||
monkeypatch.setattr(api_test_routes, "_finish_op", lambda *args, **kwargs: None)
|
||||
monkeypatch.setattr(
|
||||
HttpClient,
|
||||
"raw_delete",
|
||||
lambda *args, **kwargs: pytest.fail("Polygon delete must not call external CMDB"),
|
||||
)
|
||||
|
||||
operations_response = app_client.get("/api/operations/1")
|
||||
assert operations_response.status_code == 200
|
||||
operations = operations_response.get_json()["operations"]
|
||||
create_id = next(op["svcOperationId"] for op in operations if op["operation"] == "create")
|
||||
delete_id = next(op["svcOperationId"] for op in operations if op["operation"] == "delete")
|
||||
|
||||
created = app_client.post("/api/test", json={
|
||||
"serviceId": 1,
|
||||
"operation": "create",
|
||||
"svcOperationId": create_id,
|
||||
"params": {},
|
||||
"displayName": "autotest-local-integration",
|
||||
})
|
||||
assert created.status_code == 200, created.get_json()
|
||||
create_result = app_client.get(f"/api/test/status/{created.get_json()['opUid']}").get_json()
|
||||
assert create_result["status"] == "OK"
|
||||
|
||||
deleted = app_client.post("/api/test", json={
|
||||
"serviceId": 1,
|
||||
"operation": "delete",
|
||||
"svcOperationId": delete_id,
|
||||
"instanceUid": created.get_json()["instanceUid"],
|
||||
"params": {},
|
||||
})
|
||||
assert deleted.status_code == 200, deleted.get_json()
|
||||
delete_result = app_client.get(f"/api/test/status/{deleted.get_json()['opUid']}").get_json()
|
||||
assert delete_result["status"] == "OK"
|
||||
|
||||
def test_create_and_run_simple_scenario(self, app_client):
|
||||
"""Сценарий create -> delete. Проверяем что оба шага OK."""
|
||||
steps = [
|
||||
|
||||
Reference in New Issue
Block a user