35 lines
785 B
Python
35 lines
785 B
Python
"""Geography and time keys. No national crosswalk."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from lead.spine import geography_key, time_key
|
|
|
|
|
|
def test_a_five_digit_fips_is_the_geography_key():
|
|
assert geography_key(fips="01001") == "01001"
|
|
|
|
|
|
def test_a_short_fips_raises():
|
|
with pytest.raises(ValueError):
|
|
geography_key(fips="1001")
|
|
|
|
|
|
def test_a_five_digit_zcta_is_the_geography_key():
|
|
assert geography_key(zcta="02138") == "02138"
|
|
|
|
|
|
def test_fips_and_zcta_together_raise():
|
|
with pytest.raises(ValueError):
|
|
geography_key(fips="01001", zcta="02138")
|
|
|
|
|
|
def test_time_key_is_year_and_quarter():
|
|
assert time_key(2027, 4) == "2027Q4"
|
|
|
|
|
|
def test_a_quarter_outside_1_to_4_raises():
|
|
with pytest.raises(ValueError):
|
|
time_key(2027, 5)
|