"""Unit tests for DB model definitions (no DB required)."""
import datetime as dt


def test_issuer_master_fields():
    from libs.db.models import IssuerMaster
    m = IssuerMaster(
        issuer_id="ISSUER::0000320193",
        issuer_name="Apple Inc.",
        ticker="AAPL",
        is_active=True,
    )
    assert m.issuer_id == "ISSUER::0000320193"
    assert m.issuer_name == "Apple Inc."
    assert m.is_active is True


def test_document_defaults():
    from libs.db.models import Document
    doc = Document(
        document_id="DOC::test",
        source_name="sec",
        form_type="8-K",
        filing_date=dt.date(2026, 1, 29),
        parsed_status="pending",
    )
    assert doc.parsed_status == "pending"


def test_event_defaults():
    from libs.db.models import Event
    evt = Event(
        event_id="EVT::test",
        primary_document_id="DOC::test",
        event_type="earnings_release",
        event_direction="bullish",
        event_date=dt.date(2026, 1, 29),
        parser_version="rule-1.0.0",
        status="pending",
    )
    assert evt.status == "pending"


def test_job_run_fields():
    import uuid

    from libs.db.models import JobRun
    jr = JobRun(
        job_run_id=uuid.uuid4(),
        job_name="test_job",
        status="pending",
        records_seen=0,
        records_written=0,
    )
    assert jr.records_seen == 0
    assert jr.records_written == 0


def test_enums():
    from libs.db.enums import EventDirection, EventType, JobStatus, ParsedStatus, ParserKind
    assert JobStatus.succeeded.value == "succeeded"
    assert ParsedStatus.ready_for_parse.value == "ready_for_parse"
    assert EventDirection.bullish.value == "bullish"
    assert EventType.earnings_release.value == "earnings_release"
    assert ParserKind.rule.value == "rule"
