05-Specifications / 05.09.API-Fix-Duplicate-Tests.spec

05.09.API Fix Duplicate Tests.spec

05.09. API Fix Duplicate Tests.spec

Overview

Analysis of the bnc-cpt-api test suite reveals several areas of duplication, particularly in the payment service tests. Many tests are repeated across multiple files at both the service layer and the endpoint layer without clear separation of concerns.

Pinpointed Duplications

1. Payment Service Logic

2. Authentication Logic

3. Tesla Provider Logic

Proposed Action Plan

  1. Surgical Merge: Move TestPaymentServiceUnit from test_payment.py to test_payment_service.py if anything is missing there, then delete it from test_payment.py.
  2. Refactor Auth Tests: Remove logic-heavy tests from test_auth.py and ensure they are covered in test_auth_service.py.
  3. Tesla Test Consolidation: Group Tesla-related tests by responsibility:
    • test_tesla_api.py: Router/Endpoint tests.
    • test_tesla_service.py: Business logic and orchestration.
    • test_tesla_provider.py: Low-level provider/client tests (Tesla Fleet API specifics).
  4. Shared Fixtures: Move common mocks (like mock_redis, mock_stripe, mock_tesla) to a central conftest.py to reduce boilerplate duplication in before blocks.