summaryrefslogtreecommitdiffstats
path: root/openbb_platform/obbject_extensions/charting/tests/test_charting_core_ta_helpers.py
blob: 1804a9df3a4a8275cb703c02871f4e8b92c51f0b (plain)
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
"""Test the charting core ta helpers."""

import pandas as pd
import pytest
from obbject_extensions.charting.openbb_charting.core.plotly_ta.ta_helpers import (
    check_columns,
)


def test_check_columns():
    """Test check_columns."""
    data = pd.DataFrame(
        {
            "open": [1, 2, 3, 4, 5],
            "high": [1, 2, 3, 4, 5],
            "low": [1, 2, 3, 4, 5],
            "close": [1, 2, 3, 4, 5],
            "volume": [1, 2, 3, 4, 5],
        }
    )
    result = check_columns(data)
    assert result


def test_check_columns_fail():
    """Test check_columns."""
    data = pd.DataFrame(
        {
            "open": [1, 2, 3, 4, 5],
            "volume": [1, 2, 3, 4, 5],
        }
    )
    with pytest.raises(IndexError):
        check_columns(data)