Skip to content

Tests should run without live Google Cloud authentication #410

@kbighorse

Description

@kbighorse

Problem

The test tests/transfers/test_contact_with_multiple_wells.py::test_multiple_wells fails when Google Cloud credentials are expired or unavailable locally:

google.auth.exceptions.RefreshError: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate.

The test calls WellTransferer which invokes get_cached_elevations() that accesses Google Cloud Storage.

Suggested Solutions

  1. Mock GCS calls in tests - Use unittest.mock or pytest-mock to mock the get_storage_bucket() and related GCS functions during tests

  2. Skip tests requiring GCS when credentials unavailable - Add a pytest marker like @pytest.mark.requires_gcs and skip when GOOGLE_APPLICATION_CREDENTIALS is not set or invalid

  3. Use local fixtures - Provide cached elevation data as a test fixture instead of fetching from GCS

Benefits

  • Tests can run locally without cloud credentials
  • Faster test execution (no network calls)
  • More reliable CI/CD (not dependent on credential refresh)
  • Better test isolation

Affected Files

  • tests/transfers/test_contact_with_multiple_wells.py
  • transfers/well_transfer.py (get_cached_elevations(), WellTransferer)
  • transfers/util.py (download_blob_json())

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