Files
meta_api_grabber/tests/README.md
2025-11-10 11:27:54 +01:00

1.2 KiB

Tests

This directory contains tests for the meta_api_grabber project.

Running Tests

Install test dependencies:

uv sync --extra test

Run all tests:

uv run pytest

Run specific test file:

uv run pytest tests/test_field_schema_validation.py -v

Run with coverage:

uv run pytest --cov=meta_api_grabber

Test Files

test_field_schema_validation.py

Validates that all fields requested by the grab_* methods in scheduled_grabber.py exist in the database schema. This ensures:

  • Field compatibility between Meta API and database
  • Early detection of schema mismatches
  • Consistency across all insight levels (account, campaign, adset, country)

Why this test is important: When new fields are added to the Meta API field lists, this test quickly alerts you if the corresponding database columns need to be added.

Writing Tests

Use markers to categorize tests:

@pytest.mark.unit
def test_something():
    pass

@pytest.mark.integration
async def test_database_connection():
    pass

Run only unit tests:

uv run pytest -m unit

Run everything except integration tests:

uv run pytest -m "not integration"