Skip to content

test: add API tests for alerts endpoint - #138

Merged
alimaandev merged 3 commits into
alimaandev:mainfrom
Hrugved-06:test-alerts-endpoint
Sep 10, 2026
Merged

alimaandev merged 3 commits into
alimaandev:mainfrom
Hrugved-06:test-alerts-endpoint

Conversation

@Hrugved-06

Copy link
Copy Markdown
Contributor

Description

Adds API test coverage for the /api/v1/alerts endpoint.

The tests cover:

  • Successful authenticated request returning HTTP 200 with an alerts list.
  • Unauthorized request without a valid API key returning HTTP 401.
  • Empty alerts store returning an empty list without an error.

Closes #111

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Performance improvement
  • CI / tooling

Checklist

  • Code follows the project's coding guidelines
  • python -m pytest tests/ passes
  • cd desktop && npx tsc --noEmit passes
  • cd desktop && npm run build succeeds
  • Docs updated if needed (README, CONTRIBUTING, etc.)
  • No new warnings or lint errors

Testing

Added a TestAlerts test class in tests/test_api_server.py.

All API server tests pass successfully:

56 passed

@alimaandev

Copy link
Copy Markdown
Owner

Thanks for the PR! The CI failed due to two issues:

  1. Duplicate TestAlerts class - You added a new TestAlerts class, but one already exists at line 441. Please merge your new tests into the existing TestAlerts class instead of creating a duplicate.

  2. Missing newline at end of file - The file needs a trailing newline at the end.

To fix:

  1. Remove the duplicate class TestAlerts: definition (the one you added around line 504)
  2. Move your three new test methods ( est_alerts_returns_list, est_alerts_requires_auth, est_alerts_empty) into the existing TestAlerts class (around line 441)
  3. Ensure the file ends with a newline

Once fixed, the CI should pass. Let me know if you need help!

@alimaandev

Copy link
Copy Markdown
Owner

The CI is still failing with two issues:

  1. Duplicate TestAlerts class - The diff shows you're adding a new class TestAlerts: at line 446, but one already exists at line 441. You need to merge your three new test methods into the existing TestAlerts class instead of creating a duplicate.

  2. Trailing whitespace - Line 494 has trailing whitespace: assert data["count"] == 0\n (has spaces after the newline)

To fix:

  1. Remove the duplicate class TestAlerts: definition you added
  2. Move your three new test methods (test_alerts_returns_list, test_alerts_requires_auth, test_alerts_empty) inside the existing TestAlerts class (around line 441, after test_alerts_list)
  3. Remove trailing whitespace on the line assert data["count"] == 0

Once fixed, push and CI should pass.

@alimaandev
alimaandev merged commit 461f66f into alimaandev:main Sep 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add API tests for the alerts endpoint

2 participants