Skip to content

Commit 6522719

Browse files
committed
fix: update mock server to be compliant with latest API specs
1 parent 4c5643f commit 6522719

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

-14.5 MB
Binary file not shown.

tests/integration/features/steps/cli_steps.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ def step_run_cli_command(context, command):
3131
test_env["FORCE_COLOR"] = "1" # Force colored output
3232
test_env["CLICOLOR_FORCE"] = "1" # Force colored output
3333
test_env["TOWER_URL"] = context.tower_url # Use mock API
34-
test_env["TOWER_JWT"] = "mock_jwt_token"
3534

36-
# Override HOME to use test session
35+
# Override HOME to use test session (which contains auth credentials)
3736
test_home = Path(__file__).parent.parent.parent / "test-home"
3837
test_env["HOME"] = str(test_home.absolute())
3938

tests/mock-api-server/main.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ async def log_requests(request: Request, call_next):
5959
"created_at": datetime.datetime.now().isoformat(),
6060
"next_run_at": None,
6161
"health_status": "healthy",
62+
"pending_timeout": 300,
63+
"running_timeout": 0,
6264
"run_results": {
6365
"cancelled": 0,
6466
"crashed": 0,
@@ -83,13 +85,16 @@ def now_iso():
8385

8486

8587
def create_schedule_object(
86-
schedule_id, app_name, cron, environment="default", parameters=None
88+
schedule_id, app_name, cron, environment="default", parameters=None, name=None
8789
):
8890
return {
8991
"id": schedule_id,
92+
"name": name or f"{app_name}-schedule",
9093
"app_name": app_name,
94+
"app_status": "active",
9195
"cron": cron,
9296
"environment": environment,
97+
"overlap_policy": "skip",
9398
"status": "active",
9499
"created_at": now_iso(),
95100
"updated_at": now_iso(),
@@ -139,6 +144,8 @@ async def create_app(app_data: Dict[str, Any]):
139144
"name": app_name,
140145
"next_run_at": None,
141146
"owner": "mock_owner",
147+
"pending_timeout": 300,
148+
"running_timeout": 0,
142149
"run_results": {
143150
"cancelled": 0,
144151
"crashed": 0,
@@ -197,7 +204,7 @@ async def deploy_app(name: str, response: Response):
197204
return {"version": deployed_version}
198205

199206

200-
@app.post("/v1/apps/{name}/runs")
207+
@app.post("/v1/apps/{name}/runs", status_code=201)
201208
async def run_app(name: str, run_params: Dict[str, Any]):
202209
if name not in mock_apps_db:
203210
raise HTTPException(status_code=404, detail=f"App '{name}' not found")
@@ -248,6 +255,7 @@ async def run_app(name: str, run_params: Dict[str, Any]):
248255
"is_scheduled": True,
249256
"initiator": {
250257
"type": "tower_cli",
258+
"details": {},
251259
},
252260
}
253261
mock_runs_db[run_id] = new_run
@@ -449,6 +457,7 @@ async def get_session():
449457
"is_subscribed_to_changelog": False,
450458
"last_name": "User",
451459
"profile_photo_url": "https://example.com/photo.jpg",
460+
"promo_code": "",
452461
},
453462
"teams": [
454463
{"name": "default", "type": "user", "token": {"jwt": "mock_jwt_token"}}
@@ -579,7 +588,7 @@ async def list_schedules():
579588
}
580589

581590

582-
@app.post("/v1/schedules")
591+
@app.post("/v1/schedules", status_code=201)
583592
async def create_schedule(schedule_data: Dict[str, Any]):
584593
"""Mock endpoint for creating a schedule."""
585594
app_name = schedule_data.get("app_name")
@@ -599,15 +608,15 @@ async def create_schedule(schedule_data: Dict[str, Any]):
599608
return {"schedule": new_schedule}
600609

601610

602-
@app.put("/v1/schedules/{schedule_id}")
603-
async def update_schedule(schedule_id: str, schedule_data: Dict[str, Any]):
611+
@app.put("/v1/schedules/{id_or_name}")
612+
async def update_schedule(id_or_name: str, schedule_data: Dict[str, Any]):
604613
"""Mock endpoint for updating a schedule."""
605-
if schedule_id not in mock_schedules_db:
614+
if id_or_name not in mock_schedules_db:
606615
raise HTTPException(
607-
status_code=404, detail=f"Schedule '{schedule_id}' not found"
616+
status_code=404, detail=f"Schedule '{id_or_name}' not found"
608617
)
609618

610-
schedule = mock_schedules_db[schedule_id]
619+
schedule = mock_schedules_db[id_or_name]
611620
if "cron" in schedule_data:
612621
schedule["cron"] = schedule_data["cron"]
613622
if "parameters" in schedule_data:

0 commit comments

Comments
 (0)