Skip to content

Fix test failures from timezone-aware datetime and exception message handling#90

Merged
azvoleff merged 3 commits intomasterfrom
copilot/fix-test-failures-again
Feb 6, 2026
Merged

Fix test failures from timezone-aware datetime and exception message handling#90
azvoleff merged 3 commits intomasterfrom
copilot/fix-test-failures-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

  • Fix timezone issue in test_reset_password_with_token_preserves_already_verified_user (datetime comparison)
  • Fix error message assertions in test_reset_password_with_invalid_token_fails
  • Fix error message assertions in test_reset_password_with_expired_token_fails
  • Fix error message assertions in test_reset_password_with_used_token_fails
  • Run Ruff linting to validate code quality
  • Fix Ruff format errors
  • All fixes committed and ready for CI validation

Changes Made:

  1. Error class fix: Added super().__init__(message) to pass message to base Exception
  2. Timezone consistency: Changed datetime.now(UTC) to datetime.utcnow() to match codebase pattern
  3. Test updates: Removed timezone-aware datetime usage in all test cases
  4. Ruff formatting: Applied automatic formatting to test_password_reset_token.py

All 4 failing tests should now pass in CI, and Ruff checks should pass.

Original prompt

Reference: https://github.com/ConservationInternational/trends.earth-API/commit/9aedd6193e2ce9a9927aa412f987e36e502d7731/checks?check_suite_id=56613643391

Review and fix these test failures


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Fixed Error class to properly pass message to Exception base class for pytest matching
- Fixed timezone handling in user_service.py to use utcnow() instead of now(UTC)
- Updated all test datetime instances to use timezone-naive datetimes (utcnow())
- Ensures consistency with existing database schema that doesn't support timezone-aware datetimes

Co-authored-by: azvoleff <107753+azvoleff@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix test failures in the API tests Fix test failures from timezone-aware datetime and exception message handling Feb 6, 2026
Copilot AI requested a review from azvoleff February 6, 2026 13:17
@azvoleff
Copy link
Contributor

azvoleff commented Feb 6, 2026

@copilot fix the ruff check and ruff format errors

Applied automatic Ruff formatting to test_password_reset_token.py to fix formatting issues

Co-authored-by: azvoleff <107753+azvoleff@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 6, 2026

@copilot fix the ruff check and ruff format errors

Fixed in commit 828bbb2. Applied Ruff formatting to test_password_reset_token.py.

@azvoleff azvoleff marked this pull request as ready for review February 6, 2026 14:15
@azvoleff azvoleff merged commit e442120 into master Feb 6, 2026
7 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.

2 participants