mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 11:06:32 +00:00
[AZ-137] [AZ-138] Decompose test tasks and scaffold E2E test infrastructure
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
from flask import Flask, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
_mode = "normal"
|
||||
_annotations: list = []
|
||||
|
||||
|
||||
def _fail():
|
||||
return _mode == "error"
|
||||
|
||||
|
||||
@app.route("/annotations", methods=["POST"])
|
||||
def annotations():
|
||||
if _fail():
|
||||
return "", 503
|
||||
_annotations.append(request.get_json(silent=True))
|
||||
return "", 200
|
||||
|
||||
|
||||
@app.route("/auth/refresh", methods=["POST"])
|
||||
def auth_refresh():
|
||||
if _fail():
|
||||
return "", 503
|
||||
return {"token": "refreshed-test-token"}
|
||||
|
||||
|
||||
@app.route("/mock/config", methods=["POST"])
|
||||
def mock_config():
|
||||
global _mode
|
||||
body = request.get_json(silent=True) or {}
|
||||
mode = body.get("mode", "normal")
|
||||
if mode not in ("normal", "error"):
|
||||
return "", 400
|
||||
_mode = mode
|
||||
return "", 200
|
||||
|
||||
|
||||
@app.route("/mock/reset", methods=["POST"])
|
||||
def mock_reset():
|
||||
global _mode, _annotations
|
||||
_mode = "normal"
|
||||
_annotations.clear()
|
||||
return "", 200
|
||||
|
||||
|
||||
@app.route("/mock/status", methods=["GET"])
|
||||
def mock_status():
|
||||
return {
|
||||
"mode": _mode,
|
||||
"annotation_count": len(_annotations),
|
||||
"annotations": list(_annotations),
|
||||
}
|
||||
|
||||
|
||||
@app.route("/mock/annotations", methods=["GET"])
|
||||
def mock_annotations_list():
|
||||
return {"annotations": list(_annotations)}
|
||||
Reference in New Issue
Block a user