Skip to content

Commit af1893c

Browse files
committed
fix: update mock server to be compliant with latest API specs
1 parent f682305 commit af1893c

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(),
@@ -143,6 +148,8 @@ async def create_app(app_data: Dict[str, Any]):
143148
"name": app_name,
144149
"next_run_at": None,
145150
"owner": "mock_owner",
151+
"pending_timeout": 300,
152+
"running_timeout": 0,
146153
"run_results": {
147154
"cancelled": 0,
148155
"crashed": 0,
@@ -222,7 +229,7 @@ async def deploy_app(name: str, response: Response):
222229
return {"version": deployed_version}
223230

224231

225-
@app.post("/v1/apps/{name}/runs")
232+
@app.post("/v1/apps/{name}/runs", status_code=201)
226233
async def run_app(name: str, run_params: Dict[str, Any]):
227234
if name not in mock_apps_db:
228235
raise HTTPException(status_code=404, detail=f"App '{name}' not found")
@@ -273,6 +280,7 @@ async def run_app(name: str, run_params: Dict[str, Any]):
273280
"is_scheduled": True,
274281
"initiator": {
275282
"type": "tower_cli",
283+
"details": {},
276284
},
277285
}
278286
mock_runs_db[run_id] = new_run
@@ -474,6 +482,7 @@ async def get_session():
474482
"is_subscribed_to_changelog": False,
475483
"last_name": "User",
476484
"profile_photo_url": "https://example.com/photo.jpg",
485+
"promo_code": "",
477486
},
478487
"teams": [
479488
{"name": "default", "type": "user", "token": {"jwt": "mock_jwt_token"}}
@@ -604,7 +613,7 @@ async def list_schedules():
604613
}
605614

606615

607-
@app.post("/v1/schedules")
616+
@app.post("/v1/schedules", status_code=201)
608617
async def create_schedule(schedule_data: Dict[str, Any]):
609618
"""Mock endpoint for creating a schedule."""
610619
app_name = schedule_data.get("app_name")
@@ -624,15 +633,15 @@ async def create_schedule(schedule_data: Dict[str, Any]):
624633
return {"schedule": new_schedule}
625634

626635

627-
@app.put("/v1/schedules/{schedule_id}")
628-
async def update_schedule(schedule_id: str, schedule_data: Dict[str, Any]):
636+
@app.put("/v1/schedules/{id_or_name}")
637+
async def update_schedule(id_or_name: str, schedule_data: Dict[str, Any]):
629638
"""Mock endpoint for updating a schedule."""
630-
if schedule_id not in mock_schedules_db:
639+
if id_or_name not in mock_schedules_db:
631640
raise HTTPException(
632-
status_code=404, detail=f"Schedule '{schedule_id}' not found"
641+
status_code=404, detail=f"Schedule '{id_or_name}' not found"
633642
)
634643

635-
schedule = mock_schedules_db[schedule_id]
644+
schedule = mock_schedules_db[id_or_name]
636645
if "cron" in schedule_data:
637646
schedule["cron"] = schedule_data["cron"]
638647
if "parameters" in schedule_data:

0 commit comments

Comments
 (0)