diff --git a/README.rst b/README.rst index 4606de6..205e239 100644 --- a/README.rst +++ b/README.rst @@ -216,6 +216,7 @@ Changelog 3.2.0 ~~~~~ * Relax constraint on jellyfish dependency +* Add the 2020 TIGER URLs to shapefile_urls() 3.1.1 diff --git a/us/states.py b/us/states.py index 1e67ffc..bc1e15c 100644 --- a/us/states.py +++ b/us/states.py @@ -49,16 +49,21 @@ def shapefile_urls(self) -> Optional[Dict[str, str]]: if not fips: return None - base = "https://www2.census.gov/geo/tiger/TIGER2010/" + base = "https://www2.census.gov/geo/tiger/TIGER2020/" urls = { - "tract": urljoin(base, f"TRACT/2010/tl_2010_{fips}_tract10.zip"), - "cd": urljoin(base, f"CD/111/tl_2010_{fips}_cd111.zip"), - "county": urljoin(base, f"COUNTY/2010/tl_2010_{fips}_county10.zip"), - "state": urljoin(base, f"STATE/2010/tl_2010_{fips}_state10.zip"), - "zcta": urljoin(base, f"ZCTA5/2010/tl_2010_{fips}_zcta510.zip"), - "block": urljoin(base, f"TABBLOCK/2010/tl_2010_{fips}_tabblock10.zip"), - "blockgroup": urljoin(base, f"BG/2010/tl_2010_{fips}_bg10.zip"), + "tract": urljoin(base, f"TRACT/tl_2020_{fips}_tract.zip"), + "block": urljoin(base, f"TABBLOCK/tl_2020_{fips}_tabblock10.zip"), + "blockgroup": urljoin(base, f"BG/tl_2020_{fips}_bg.zip"), + "cd": urljoin(base, f"CD/CD118/tl_2020_{fips}_cd118.zip"), + "county": urljoin(base, "COUNTY/tl_2020_us_county.zip"), + "state": urljoin(base, "STATE/tl_2020_us_state.zip"), + "zcta": urljoin(base, "ZCTA5/tl_2020_us_zcta510.zip"), } + # unicameral legislatures don't have a lower chamber + if self.abbr not in ["DC", "NE", "AS", "GU", "MP", "VI"]: + urls["lowerchamber"] = urljoin(base, f"SLDL/2022/tl_2020_{fips}_sldl.zip") + if self.abbr not in ["AS", "GU", "MP", "VI"]: + urls["upperchamber"] = urljoin(base, f"SLDU/tl_2020_{fips}_sldu.zip") return urls diff --git a/us/tests/test_us.py b/us/tests/test_us.py index 02a8c76..6a892a9 100644 --- a/us/tests/test_us.py +++ b/us/tests/test_us.py @@ -124,14 +124,14 @@ def test_dc(): # shapefiles -@pytest.mark.skip -def test_head(): +shapefile_urls = [url for state in us.STATES_AND_TERRITORIES for url in state.shapefile_urls().values()] + +@pytest.mark.parametrize("url", shapefile_urls) +def test_shapefiles_head(url): import requests - for state in us.STATES_AND_TERRITORIES: - for url in state.shapefile_urls().values(): - resp = requests.head(url) - assert resp.status_code == 200 + resp = requests.head(url) + assert resp.status_code == 200 # counts