Simplified insight grabbers
This commit is contained in:
58
tests/README.md
Normal file
58
tests/README.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Tests
|
||||
|
||||
This directory contains tests for the meta_api_grabber project.
|
||||
|
||||
## Running Tests
|
||||
|
||||
Install test dependencies:
|
||||
```bash
|
||||
uv sync --extra test
|
||||
```
|
||||
|
||||
Run all tests:
|
||||
```bash
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
Run specific test file:
|
||||
```bash
|
||||
uv run pytest tests/test_field_schema_validation.py -v
|
||||
```
|
||||
|
||||
Run with coverage:
|
||||
```bash
|
||||
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:
|
||||
```python
|
||||
@pytest.mark.unit
|
||||
def test_something():
|
||||
pass
|
||||
|
||||
@pytest.mark.integration
|
||||
async def test_database_connection():
|
||||
pass
|
||||
```
|
||||
|
||||
Run only unit tests:
|
||||
```bash
|
||||
uv run pytest -m unit
|
||||
```
|
||||
|
||||
Run everything except integration tests:
|
||||
```bash
|
||||
uv run pytest -m "not integration"
|
||||
```
|
||||
Reference in New Issue
Block a user