fix: script locust file remove /lessons path
This commit is contained in:
parent
2b6ec21633
commit
d28cab70fa
|
|
@ -139,7 +139,7 @@ def get_ordered_slugs(content_dir: str) -> list[str]:
|
||||||
if len(parts) <= 1:
|
if len(parts) <= 1:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
links = re.findall(r'\[([^\]]+)\]\((?:lesson/)?([^\)]+)\)', parts[1])
|
links = re.findall(r'\[([^\]]+)\]\((?:\/?lesson\/)?([^\)]+)\)', parts[1])
|
||||||
return [fn.replace('.md', '') for _, fn in links]
|
return [fn.replace('.md', '') for _, fn in links]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,20 +116,14 @@ class ElemesStudent(HttpUser):
|
||||||
if not data.get('success'):
|
if not data.get('success'):
|
||||||
resp.failure(f"Login failed: {data.get('message', f'HTTP {resp.status_code}')}")
|
resp.failure(f"Login failed: {data.get('message', f'HTTP {resp.status_code}')}")
|
||||||
|
|
||||||
# ── Task 1: Browse Lessons (weight=3) ──────────────────────────────
|
# ── Task 1: Browse Home Page (weight=3) ─────────────────────────────
|
||||||
|
|
||||||
@task(3)
|
@task(3)
|
||||||
def browse_lessons(self):
|
def browse_home_page(self):
|
||||||
"""Fetch lesson list — simulates landing on home page."""
|
"""Simulate student landing on the home page."""
|
||||||
with self.client.get(f'{API}/lessons', name='/lessons', catch_response=True) as resp:
|
with self.client.get('/', name='Home Page', catch_response=True) as resp:
|
||||||
data = safe_json(resp)
|
if resp.status_code != 200:
|
||||||
lessons = data.get('lessons', [])
|
resp.failure(f"Failed to load Home Page: HTTP {resp.status_code}")
|
||||||
if len(lessons) == 0:
|
|
||||||
resp.failure("No lessons returned")
|
|
||||||
elif len(lessons) != len(ALL_LESSONS):
|
|
||||||
resp.failure(
|
|
||||||
f"Expected {len(ALL_LESSONS)} lessons, got {len(lessons)}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── Task 2: View Lesson Detail (weight=5) ──────────────────────────
|
# ── Task 2: View Lesson Detail (weight=5) ──────────────────────────
|
||||||
|
|
||||||
|
|
@ -149,8 +143,12 @@ class ElemesStudent(HttpUser):
|
||||||
) as resp:
|
) as resp:
|
||||||
data = safe_json(resp)
|
data = safe_json(resp)
|
||||||
|
|
||||||
|
if resp.status_code != 200:
|
||||||
|
resp.failure(f"HTTP {resp.status_code}: {data.get('error', 'Lesson detail fetch failed')}")
|
||||||
|
return
|
||||||
|
|
||||||
if 'error' in data or not data:
|
if 'error' in data or not data:
|
||||||
resp.failure(f"Lesson {slug} not found")
|
resp.failure(f"Lesson {slug} not found: {data.get('error')}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Validate fields based on type
|
# Validate fields based on type
|
||||||
|
|
@ -413,7 +411,9 @@ class ElemesStudent(HttpUser):
|
||||||
) as resp:
|
) as resp:
|
||||||
data = safe_json(resp)
|
data = safe_json(resp)
|
||||||
if not data.get('success'):
|
if not data.get('success'):
|
||||||
resp.failure(f"Track progress failed: {data.get('message', f'HTTP {resp.status_code}')}")
|
# Include exact error message from server to help debugging
|
||||||
|
error_msg = data.get('message', f'HTTP {resp.status_code}')
|
||||||
|
resp.failure(f"Track progress failed for '{slug}': {error_msg}")
|
||||||
|
|
||||||
# ── Task 7: Progress Report (weight=1) ─────────────────────────────
|
# ── Task 7: Progress Report (weight=1) ─────────────────────────────
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue