[Feature] Add USDA FAS Agriculture Commodity Endpoints (#7298)

* add endpoint  with  as provider to return a PDF widget with historical data by commodity, year, and month

* lint

* add weather bulletins

* codespell

* codespell

* grammar police

* better examples

* add psd data endpoint

* it's 'aggregate_regions', not 'aggregate_region'

* codespell

* missing annotation

* missing unit test

* fix a test expectations for the new year
This commit is contained in:
Danglewood
2026-01-02 14:11:04 -08:00
committed by GitHub
parent 98fc5ac9c6
commit 67940fd576
24 changed files with 68602 additions and 6 deletions

View File

@@ -98,3 +98,122 @@ def test_commodity_short_term_energy_outlook(params, obb):
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"commodity": "sugar",
"year": 2025,
"month": 5,
"provider": "government_us",
}
),
],
)
@pytest.mark.integration
def test_commodity_psd_report(params, obb):
"""Test Commodity PSD Report endpoint."""
result = obb.commodity.psd_report(**params)
assert result
assert isinstance(result, dict)
assert result["data_format"]["data_type"] == "pdf"
@pytest.mark.parametrize(
"params",
[
(
{
"year": 2025,
"month": 5,
"week": 2,
"provider": "government_us",
}
),
],
)
@pytest.mark.integration
def test_commodity_weather_bulletins(params, obb):
"""Test Commodity Weather Bulletins endpoint."""
result = obb.commodity.weather_bulletins(**params)
assert result
assert isinstance(result, list)
assert len(result) > 0
for bulletin in result:
assert bulletin["label"]
assert bulletin["value"]
@pytest.mark.parametrize(
"params",
[
(
{
"urls": [
"https://esmis.nal.usda.gov/sites/default/release-files/cj82k728n/vx023b997/z890tr81b/wwcb1825.pdf",
"https://esmis.nal.usda.gov/sites/default/release-files/cj82k728n/w6635s43r/x059dz29h/wwcb1924.pdf",
],
"provider": "government_us",
}
),
],
)
@pytest.mark.integration
def test_commodity_weather_bulletins_download(params, obb):
"""Test Commodity Weather Bulletins Download endpoint."""
result = obb.commodity.weather_bulletins_download(**params)
assert result
assert isinstance(result, list)
assert len(result) > 0
for bulletin in result:
assert isinstance(bulletin, dict)
assert bulletin["content"]
assert bulletin["data_format"]["data_type"] == "pdf"
@pytest.mark.parametrize(
"params",
[
(
{
"provider": "government_us",
}
),
(
{
"provider": "government_us",
"report_id": "coffee_summary",
"commodity": None,
"country": None,
"attribute": None,
"start_year": None,
"end_year": None,
"aggregate_regions": False,
}
),
(
{
"report_id": "world_crop_production_summary", # ignored if commodity is set
"commodity": "corn",
"country": "united_states,argentina",
"attribute": "exports",
"start_year": 2025,
"end_year": 2025,
"provider": "government_us",
"aggregate_regions": False,
}
),
],
)
@pytest.mark.integration
def test_commodity_psd_data(params, obb):
"""Test Commodity PSD Data endpoint."""
params = {p: v for p, v in params.items() if v is not None}
result = obb.commodity.psd_data(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0