"""Basic tests for Redis key conventions."""
from services.shared.redis_keys import (
    QUEUE_INGESTION,
    QUEUE_PARSING,
    cache_key,
    dedupe_key,
    lock_key,
    queue_key,
    rate_limit_key,
)


def test_lock_key_format():
    assert lock_key("scheduler") == "stonks:lock:scheduler"


def test_rate_limit_key_format():
    assert rate_limit_key("news_api", "202604111200") == "stonks:ratelimit:news_api:202604111200"


def test_queue_key_format():
    assert queue_key(QUEUE_INGESTION) == "stonks:queue:ingestion"
    assert queue_key(QUEUE_PARSING) == "stonks:queue:parsing"


def test_dedupe_key_format():
    assert dedupe_key("abc123").startswith("stonks:dedupe:")


def test_cache_key_format():
    assert cache_key("companies", "AAPL") == "stonks:cache:companies:AAPL"
