Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,30 @@ jobs:
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Check ADCP version
id: version-check
run: |
VERSION=$(cat src/adcp/ADCP_VERSION)
echo "ADCP_VERSION=$VERSION"
# Check if version contains pre-release identifiers (alpha, beta, rc)
if echo "$VERSION" | grep -qE '(alpha|beta|rc)'; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "Pre-release version detected - will skip schema sync (may not be publicly accessible)"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "Stable version - will sync schemas from upstream"
fi

- name: Download latest schemas
if: steps.version-check.outputs.is_prerelease != 'true'
run: python scripts/sync_schemas.py

- name: Fix schema references
if: steps.version-check.outputs.is_prerelease != 'true'
run: python scripts/fix_schema_refs.py

- name: Generate models
if: steps.version-check.outputs.is_prerelease != 'true'
run: python scripts/generate_types.py

- name: Validate generated code syntax
Expand All @@ -132,6 +149,7 @@ jobs:
pytest tests/test_code_generation.py -v --tb=short

- name: Check for schema drift
if: steps.version-check.outputs.is_prerelease != 'true'
run: |
# Check if only generation timestamp changed (expected when CI regenerates)
if git diff --exit-code src/adcp/types/_generated.py schemas/cache/ | grep -v "^[-+]Generation date:"; then
Expand Down
38 changes: 31 additions & 7 deletions docs/examples/testing_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ def test_get_products_response_deserializes_from_protocol_json(self):
],
"pricing_options": [
{
"model": "cpm_fixed_rate",
"is_fixed": true,
"cpm": 5.50
"pricing_model": "cpm",
"pricing_option_id": "po-premium-1",
"currency": "USD",
"fixed_price": 5.50
}
]
}
Expand Down Expand Up @@ -182,7 +183,14 @@ async def test_buyer_discovers_products_for_coffee_campaign(self, mocker):
"property_tags": ["morning", "lifestyle"],
}
],
"pricing_options": [{"model": "cpm_fixed_rate", "is_fixed": True, "cpm": 4.50}],
"pricing_options": [
{
"pricing_model": "cpm",
"pricing_option_id": "po-breakfast-1",
"currency": "USD",
"fixed_price": 4.50,
}
],
}
]
}
Expand All @@ -207,7 +215,9 @@ async def test_buyer_discovers_products_for_coffee_campaign(self, mocker):

# Assert: Can plan budget from pricing
pricing = product.pricing_options[0]
assert pricing.model in ["cpm_fixed_rate", "cpm_auction"]
assert pricing.pricing_model == "cpm"
# Fixed pricing has fixed_price, auction pricing has floor_price
assert pricing.fixed_price is not None or pricing.floor_price is not None

@pytest.mark.asyncio
async def test_buyer_handles_no_products_available(self, mocker):
Expand Down Expand Up @@ -412,7 +422,14 @@ def test_anti_pattern_importing_generated_poc(self):
"property_ids": ["site1"],
}
],
"pricing_options": [{"model": "cpm_fixed_rate", "is_fixed": True, "cpm": 5.0}],
"pricing_options": [
{
"pricing_model": "cpm",
"pricing_option_id": "po-test-1",
"currency": "USD",
"fixed_price": 5.0,
}
],
}

product = Product.model_validate(product_json)
Expand Down Expand Up @@ -510,7 +527,14 @@ def sample_product_json():
"property_ids": ["homepage", "mobile_app"],
}
],
"pricing_options": [{"model": "cpm_fixed_rate", "is_fixed": True, "cpm": 5.50}],
"pricing_options": [
{
"pricing_model": "cpm",
"pricing_option_id": "po-premium-1",
"currency": "USD",
"fixed_price": 5.50,
}
],
}


Expand Down
32 changes: 25 additions & 7 deletions docs/testing-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def test_get_products_response_deserializes_from_protocol_json():
],
"pricing_options": [
{
"model": "cpm_fixed_rate",
"is_fixed": true,
"cpm": 5.50
"pricing_model": "cpm",
"pricing_option_id": "po-premium-1",
"currency": "USD",
"fixed_price": 5.50
}
]
}
Expand Down Expand Up @@ -191,7 +192,12 @@ async def test_buyer_discovers_products_for_coffee_campaign(mocker):
}
],
"pricing_options": [
{"model": "cpm_fixed_rate", "is_fixed": True, "cpm": 4.50}
{
"pricing_model": "cpm",
"pricing_option_id": "po-breakfast-1",
"currency": "USD",
"fixed_price": 4.50,
}
],
}
]
Expand Down Expand Up @@ -221,7 +227,9 @@ async def test_buyer_discovers_products_for_coffee_campaign(mocker):

# Assert: Can plan budget from pricing
pricing = product.pricing_options[0]
assert pricing.model in ["cpm_fixed_rate", "cpm_auction"]
assert pricing.pricing_model == "cpm"
# Fixed pricing has fixed_price, auction pricing has floor_price
assert pricing.fixed_price is not None or pricing.floor_price is not None
```

### Example: Handle Empty Results
Expand Down Expand Up @@ -410,7 +418,12 @@ def sample_product_json():
}
],
"pricing_options": [
{"model": "cpm_fixed_rate", "is_fixed": True, "cpm": 5.50}
{
"pricing_model": "cpm",
"pricing_option_id": "po-premium-1",
"currency": "USD",
"fixed_price": 5.50,
}
],
}
```
Expand Down Expand Up @@ -440,7 +453,12 @@ product_json = {
"property_ids": ["site1"],
}],
"pricing_options": [
{"model": "cpm_fixed_rate", "is_fixed": True, "cpm": 5.0}
{
"pricing_model": "cpm",
"pricing_option_id": "po-test-1",
"currency": "USD",
"fixed_price": 5.0,
}
],
}

Expand Down
Loading