import pandas as pd
import numpy as np
from wael_lib import TechAnalysis


def test_categorize_price_ranges_basic():
    ta = TechAnalysis()
    # create a monotonic series large enough for 250-period rolling
    series = pd.Series(np.linspace(1, 1000, 300))
    cats = ta.categorize_price_ranges(series)

    # allowed labels
    allowed = {"Very Low", "Low", "Moderate", "High", "Very High"}

    # Non-null entries should be subset of allowed labels
    non_null = cats.dropna()
    assert not non_null.empty
    assert set(non_null.unique()).issubset(allowed)

    # Initial positions (before rolling window) may be NaN
    assert cats.shape[0] == 300


def test_categorize_all_equal_values():
    ta = TechAnalysis()
    series = pd.Series([100.0] * 300)
    cats = ta.categorize_price_ranges(series)
    # All should be 'Moderate' because no variation
    assert (cats.dropna() == 'Moderate').all()
