120 lines
3.4 KiB
Python
120 lines
3.4 KiB
Python
"""Test data models."""
|
|
|
|
from datetime import date
|
|
|
|
from src.models import Bill, Legislator, Summary, Vote
|
|
|
|
|
|
def test_legislator_creation():
|
|
leg = Legislator(
|
|
id="L000001",
|
|
first_name="John",
|
|
last_name="Doe",
|
|
full_name="John Doe",
|
|
party="Democrat",
|
|
state="CA",
|
|
chamber="Senate",
|
|
birth_date=date(1960, 1, 15),
|
|
photo_url="https://example.com/photo.jpg",
|
|
url="https://example.com",
|
|
in_office=True,
|
|
start_date=date(2025, 1, 3),
|
|
end_date=None,
|
|
)
|
|
assert leg.id == "L000001"
|
|
assert leg.full_name == "John Doe"
|
|
assert leg.party == "Democrat"
|
|
assert leg.in_office is True
|
|
assert leg.start_date == date(2025, 1, 3)
|
|
assert leg.end_date is None
|
|
|
|
|
|
def test_legislator_defaults():
|
|
leg = Legislator(
|
|
id="L002", first_name="Jane", last_name="Smith", full_name="Jane Smith", party="", state="", chamber=""
|
|
)
|
|
assert leg.in_office is True
|
|
assert leg.birth_date is None
|
|
assert leg.photo_url is None
|
|
assert leg.url is None
|
|
assert leg.start_date is None
|
|
assert leg.end_date is None
|
|
|
|
|
|
def test_legislator_retired():
|
|
leg = Legislator(
|
|
id="M000355",
|
|
first_name="Mitch",
|
|
last_name="McConnell",
|
|
full_name="Mitch McConnell",
|
|
party="Republican",
|
|
state="KY",
|
|
chamber="Senate",
|
|
in_office=False,
|
|
start_date=date(1985, 1, 3),
|
|
end_date=date(2025, 12, 31),
|
|
)
|
|
assert leg.in_office is False
|
|
assert leg.start_date == date(1985, 1, 3)
|
|
assert leg.end_date == date(2025, 12, 31)
|
|
|
|
|
|
def test_bill_creation():
|
|
bill = Bill(bill_id="B100", title="Test Bill", subject="Education", text="Full bill text here", enacted=True)
|
|
assert bill.bill_id == "B100"
|
|
assert bill.enacted is True
|
|
assert bill.summary == ""
|
|
assert bill.key_measures == []
|
|
assert bill.api_response == ""
|
|
|
|
|
|
def test_bill_defaults():
|
|
bill = Bill(bill_id="119/hr/1", title="Test Bill")
|
|
assert bill.subject == ""
|
|
assert bill.text == ""
|
|
assert bill.summary == ""
|
|
assert bill.sponsor == ""
|
|
assert bill.committee == ""
|
|
assert bill.enacted is False
|
|
assert bill.enacted_date is None
|
|
|
|
|
|
def test_vote_creation():
|
|
vote = Vote(legislator_id="L001", roll_call_id="RC001", vote_type="Yea", bill_id="B100", bill_title="Test Bill")
|
|
assert vote.vote_type == "Yea"
|
|
assert vote.vote_date is None
|
|
|
|
|
|
def test_vote_with_date():
|
|
vote = Vote(
|
|
legislator_id="L001",
|
|
roll_call_id="RC001",
|
|
vote_type="Nay",
|
|
bill_id="119/hr/1",
|
|
vote_date=date(2025, 6, 15),
|
|
bill_title="Privacy Act",
|
|
)
|
|
assert vote.vote_type == "Nay"
|
|
assert vote.vote_date == date(2025, 6, 15)
|
|
assert vote.bill_title == "Privacy Act"
|
|
|
|
|
|
def test_summary_creation():
|
|
summary = Summary(bill_id="B100", summary_text="This bill does X, Y, Z.", key_measures=["Measure A", "Measure B"])
|
|
assert len(summary.key_measures) == 2
|
|
assert summary.model_name == ""
|
|
assert summary.generated_at is None
|
|
|
|
|
|
def test_summary_full():
|
|
summary = Summary(
|
|
bill_id="119/hr/1",
|
|
summary_text="Comprehensive summary.",
|
|
key_measures=["Provision 1", "Provision 2", "Provision 3"],
|
|
generated_at=None,
|
|
model_name="gpt-oss",
|
|
)
|
|
assert summary.bill_id == "119/hr/1"
|
|
assert len(summary.key_measures) == 3
|
|
assert summary.model_name == "gpt-oss"
|