Spaces:
Running
Running
| """Coverage manifest tests.""" | |
| from datetime import date | |
| from coastwise.coverage import SF_COAST_COVERAGE, validate_regional_coverage | |
| from coastwise.schemas import HarvestStatus, RuleCard | |
| def test_sf_coast_manifest_includes_required_public_page_groups(): | |
| required = set(SF_COAST_COVERAGE.required_entries) | |
| for entry in ( | |
| "rockfish", | |
| "yelloweye rockfish", | |
| "cabezon", | |
| "lingcod", | |
| "leopard shark", | |
| "pacific halibut", | |
| "california halibut", | |
| "surfperch", | |
| "white seabass", | |
| "green sturgeon", | |
| "dungeness crab", | |
| "mussels", | |
| "clams", | |
| "marine aquatic plants", | |
| "ocean salmon", | |
| "red abalone", | |
| "unknown organism", | |
| ): | |
| assert entry in required | |
| def test_validate_regional_coverage_reports_missing_entries(): | |
| card = RuleCard( | |
| key="mussels", | |
| display_name="Mussels", | |
| category="shellfish", | |
| aliases=("mussel", "mussels"), | |
| covered_species=("California mussel",), | |
| region_keys=(SF_COAST_COVERAGE.key,), | |
| photo_supported=True, | |
| default_status=HarvestStatus.VERIFY_BEFORE_HARVEST, | |
| short_answer="Verify before harvest.", | |
| rule_notes=("Check current CDFW and CDPH guidance.",), | |
| safety_warnings=(), | |
| source_names=("CDFW Ocean Sport Fishing",), | |
| source_urls=("https://wildlife.ca.gov/Fishing/Ocean/Regulations",), | |
| cache_date=date(2026, 6, 1), | |
| ) | |
| issues = validate_regional_coverage(SF_COAST_COVERAGE, [card]) | |
| assert issues | |
| assert any(issue.entry == "rockfish" for issue in issues) | |
| assert all(issue.severity in {"missing", "exception_not_strict"} for issue in issues) | |