Skip to content

Add comprehensive unit tests #4

@genro

Description

@genro

Context

Core logic needs unit tests to ensure correctness and prevent regressions. Priority is TokenManager, providers, and storage.

Goal

Achieve >80% code coverage with fast unit tests.

Implementation

  • Create tests/test_opaque_provider.py
    • Test generate() creates valid tokens
    • Test validate() accepts valid tokens
    • Test validate() rejects invalid/expired tokens
    • Test refresh() creates new token pair
    • Test revoke() removes tokens
  • Create tests/test_token_manager.py
    • Test manager with configured provider
    • Test configuration API
    • Test error handling
  • Create tests/test_memory_storage.py
    • Test set/get/delete operations
    • Test datetime serialization
    • Test clear() method
  • Create tests/conftest.py with fixtures
  • Run pytest with coverage

Acceptance Criteria

  • All tests pass
  • Coverage >80%
  • Tests run in <5 seconds
  • No external dependencies (no Redis, DB)
  • Clear test names (test_validate_returns_none_for_expired_token)

Dependencies

Notes

  • Use pytest
  • Mock time for expiration tests
  • Test edge cases: expired, invalid, malformed tokens
  • Test concurrency safety (if needed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions