Skip to content

Add route-level tests for EarthMind's API and fix two small routing bugs #1138

Open

Description

@A1L13N

Context

EarthMind's tests (earthmind/tests/test_anomaly.py, test_trends.py) only cover the pure services in src/services/. The HTTP layer in earthmind/src/index.py (Default.fetch ~line 56 and the _* handlers) has no tests. While writing them you'll hit two real bugs:

  1. limit is parsed with int(...) (~lines 167, 204), so ?limit=abc raises and returns an unhandled 500 instead of a 400.
  2. /api/alerts/<id>/resolve (~line 93) resolves an alert for any HTTP method, including GET. A link preview or crawler can resolve alerts. It should be POST-only.

What to do

  • Add earthmind/tests/test_routes.py with a minimal fake env (DB.prepare().bind().all()/run()/first(), AI.run) and a fake request.
  • Test at least: /api/health, GET/POST /api/data, /api/anomalies without parameter (400), /api/alerts list/create, resolve, and unknown routes (404).
  • Fix both bugs: return 400 for non-integer limit, and return 405 for non-POST requests to /resolve (update the dashboard JS in src/static/ if it calls resolve with another method).

Acceptance criteria

  • New route tests pass along with the existing 67.
  • ?limit=abc returns 400; GET /api/alerts/1/resolve returns 405.
  • README API Reference says resolve is POST.

Files

  • earthmind/src/index.py
  • earthmind/src/static/index.py
  • earthmind/tests/test_routes.py (new)
  • earthmind/README.md

Helpful links

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

Activity

  1. added
    good first issue
    gsoc-2027
    on Nov 2, 2026
  2. github-actions commented on Nov 2, 2026

    @github-actions
  3. reopened this on Nov 2, 2026
  4. added
    2026-11
    on Nov 2, 2026
  5. Taha254511 commented on Nov 2, 2026

    @Taha254511
    Contributor

    i am interested to work on this issue ,please assign this issue to me

  6. github-actions commented on Nov 2, 2026

    @github-actions
    Contributor

    You can't take this task yet. You still have uncompleted issues: #1133. Please complete them before requesting another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    2026-11good first issuegsoc-2027project: earthmindtests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions