Add tests for learn's survey API handlers

Aperta
#1,127 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Start with learn/tests/test_quizzes.py to see how MockDB and make_stmt from learn/tests/helpers.py are used, and check learn/tests/conftest.py for the Workers stubs. Then read the six survey handlers in learn/src/worker.py (around lines 3894 to 4201) to see their auth, validation and ownership checks. Done means a new learn/tests/test_surveys.py with a success and a failure test per handler, passing via cd learn && python -m pytest -q in under a second, with worker.py unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

2026-11 good first issue gsoc-2027 project: learn tests
Context

learn has six survey endpoints with no tests at all: api_list_surveys (~line 3894), api_create_survey (~3931), api_get_survey (~4075), api_submit_survey (~4087), api_delete_survey (~4163) and api_survey_results (~4201) in learn/src/worker.py. No file under learn/tests/ references them. Run the suite with cd learn && pip install pytest pytest-asyncio && python -m pytest -q (no Cloudflare account needed; tests/conftest.py stubs the Workers runtime).

What to do
  • Create learn/tests/test_surveys.py, following the style of test_quizzes.py (it uses the same MockDB / make_stmt helpers).
  • Cover: unauthenticated requests (401), validation errors (400) on create/submit, a non-owner trying to delete or read results (403/404), and the happy path for each handler.
  • If you find a real bug while writing the tests, open a separate issue or fix it in its own commit with a regression test.
Acceptance criteria
  • Each of the six handlers has at least one success and one failure test.
  • The new file passes locally and does not slow the suite noticeably (< 1 s).
  • No changes to worker.py unless they fix a bug a new test exposes.
Files
  • learn/tests/test_surveys.py (new)
  • learn/tests/test_quizzes.py (pattern to copy)
  • learn/tests/helpers.py
  • learn/src/worker.py (survey handlers)
Helpful links
  • learn/public/surveys.html (the UI that calls these endpoints)

Part of GSoC 2027 onboarding — see https://gsoc.alphaonelabs.com

Lingua principale
HTML
Stelle
66
Fork
181
Merge medio
2h 21m
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di alphaonelabs/website

Tutte le issue di alphaonelabs/website

Issue simili

Altre issue su Testing & QA

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.