File size: 1,404 Bytes
452f691 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import os
import pytest
from ai_models import (
analyze_crypto_sentiment,
analyze_financial_sentiment,
analyze_market_text,
analyze_social_sentiment,
registry_status,
)
from config import get_settings
settings = get_settings()
pytestmark = pytest.mark.skipif(
not os.getenv("HF_TOKEN") and not os.getenv("HF_TOKEN_ENCODED"),
reason="HF token not configured",
)
@pytest.mark.skipif(not registry_status()["transformers_available"], reason="transformers not available")
def test_crypto_sentiment_structure() -> None:
result = analyze_crypto_sentiment("Bitcoin continues its bullish momentum")
assert "label" in result
assert "score" in result
@pytest.mark.skipif(not registry_status()["transformers_available"], reason="transformers not available")
def test_multi_model_sentiments() -> None:
financial = analyze_financial_sentiment("Equities rallied on strong earnings")
social = analyze_social_sentiment("The community on twitter is excited about ETH")
assert "label" in financial
assert "label" in social
@pytest.mark.skipif(not registry_status()["transformers_available"], reason="transformers not available")
def test_market_text_router() -> None:
response = analyze_market_text("Summarize Bitcoin market sentiment today")
assert "summary" in response
assert "signals" in response
assert "crypto" in response["signals"]
|