Skip to content

test: add Sensors API behavior coverage#171

Open
bhudevbhanpuriya wants to merge 2 commits into
istSOS:mainfrom
bhudevbhanpuriya:fix/sensors-api-test-coverage
Open

test: add Sensors API behavior coverage#171
bhudevbhanpuriya wants to merge 2 commits into
istSOS:mainfrom
bhudevbhanpuriya:fix/sensors-api-test-coverage

Conversation

@bhudevbhanpuriya
Copy link
Copy Markdown
Contributor

Summary

This PR improves API test coverage and removes a brittle source-code assertion.

Changes

  • Adds behavior tests for Sensors endpoints:

    • GET /Sensors streaming response
    • GET /Sensors empty result handling
    • POST /Sensors JSON content-type validation
    • POST /Sensors created response location header
    • PATCH /Sensors(id) missing sensor response
    • DELETE /Sensors(id) missing sensor response
  • Rewrites test_update_user_error_message.py to call update_user() directly instead of reading source code as text.

  • Updates pytest.ini so default pytest collection includes api/tests.

Why

The previous test checked implementation text instead of runtime behavior, which could fail after harmless refactors or pass despite broken behavior. Also, Sensors endpoints had no direct test coverage.


Before v After

image

Testing

Ran syntax validation:

.venv/bin/python -m py_compile api/tests/test_sensor_endpoints.py api/tests/test_update_user_error_message.py

Fixes #170

@bhudevbhanpuriya
Copy link
Copy Markdown
Contributor Author

Testing

I set up a clean local test environment and ran the focused tests for the changes in this PR.

Focused endpoint tests passed locally:

image ---

These tests cover the new Sensors endpoint behavior tests and the rewritten update_user regression test.

@bhudevbhanpuriya bhudevbhanpuriya changed the title Add Sensors API behavior tests test: add Sensors API behavior coverage Apr 21, 2026
@bhudevbhanpuriya bhudevbhanpuriya force-pushed the fix/sensors-api-test-coverage branch from fed68bf to 07a2516 Compare April 23, 2026 18:03
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 behavior tests for Sensors API and replace brittle source-string assertion

1 participant