import tributary.lazy as tl


class TestAPI:
    def test_api_ops(self):
        # Ops
        assert hasattr(tl.LazyNode, "__add__")
        assert hasattr(tl, "Add")
        assert hasattr(tl.LazyNode, "__radd__")
        assert hasattr(tl, "Sub")
        assert hasattr(tl.LazyNode, "__sub__")
        assert hasattr(tl.LazyNode, "__rsub__")
        assert hasattr(tl, "Mult")
        assert hasattr(tl.LazyNode, "__mul__")
        assert hasattr(tl.LazyNode, "__rmul__")
        assert hasattr(tl.LazyNode, "__div__")
        assert hasattr(tl, "Div")
        assert hasattr(tl.LazyNode, "__rdiv__")
        assert hasattr(tl, "RDiv")
        assert hasattr(tl.LazyNode, "__truediv__")
        assert hasattr(tl.LazyNode, "__rtruediv__")
        assert hasattr(tl.LazyNode, "__pow__")
        assert hasattr(tl, "Pow")
        assert hasattr(tl.LazyNode, "__rpow__")
        assert hasattr(tl.LazyNode, "__mod__")
        assert hasattr(tl, "Mod")
        assert hasattr(tl.LazyNode, "__rmod__")
        assert hasattr(tl.LazyNode, "invert")
        assert hasattr(tl, "Invert")
        assert hasattr(tl.LazyNode, "__and__")
        assert hasattr(tl, "And")
        assert hasattr(tl.LazyNode, "__or__")
        assert hasattr(tl, "Or")
        assert hasattr(tl.LazyNode, "__invert__")
        assert hasattr(tl.LazyNode, "__bool__")
        assert hasattr(tl, "Bool")
        assert hasattr(tl.LazyNode, "int")
        assert hasattr(tl, "Int")
        assert hasattr(tl.LazyNode, "float")
        assert hasattr(tl, "Float")
        assert hasattr(tl.LazyNode, "__str__")
        assert hasattr(tl, "Str")
        assert hasattr(tl.LazyNode, "__lt__")
        assert hasattr(tl, "Lt")
        assert hasattr(tl.LazyNode, "__le__")
        assert hasattr(tl, "Le")
        assert hasattr(tl.LazyNode, "__gt__")
        assert hasattr(tl, "Gt")
        assert hasattr(tl.LazyNode, "__ge__")
        assert hasattr(tl, "Ge")
        assert hasattr(tl.LazyNode, "__eq__")
        assert hasattr(tl, "Equal")
        assert hasattr(tl.LazyNode, "__ne__")
        assert hasattr(tl, "NotEqual")
        assert hasattr(tl.LazyNode, "__neg__")
        assert hasattr(tl, "Negate")
        assert hasattr(tl.LazyNode, "log")
        assert hasattr(tl, "Log")
        assert hasattr(tl.LazyNode, "sin")
        assert hasattr(tl, "Sin")
        assert hasattr(tl.LazyNode, "cos")
        assert hasattr(tl, "Cos")
        assert hasattr(tl.LazyNode, "tan")
        assert hasattr(tl, "Tan")
        assert hasattr(tl.LazyNode, "asin")
        assert hasattr(tl, "Arcsin")
        assert hasattr(tl.LazyNode, "acos")
        assert hasattr(tl, "Arccos")
        assert hasattr(tl.LazyNode, "atan")
        assert hasattr(tl, "Arctan")
        assert hasattr(tl.LazyNode, "abs")
        assert hasattr(tl, "Abs")
        assert hasattr(tl.LazyNode, "sqrt")
        assert hasattr(tl, "Sqrt")
        assert hasattr(tl.LazyNode, "exp")
        assert hasattr(tl, "Exp")
        assert hasattr(tl.LazyNode, "erf")
        assert hasattr(tl, "Erf")
        assert hasattr(tl.LazyNode, "round")
        assert hasattr(tl, "Round")
        assert hasattr(tl.LazyNode, "__round__")
        assert hasattr(tl.LazyNode, "floor")
        assert hasattr(tl, "Floor")
        assert hasattr(tl.LazyNode, "__floor__")
        assert hasattr(tl.LazyNode, "ceil")
        assert hasattr(tl, "Ceil")
        assert hasattr(tl.LazyNode, "__ceil__")
        assert hasattr(tl.LazyNode, "sum")
        assert hasattr(tl, "Sum")
        assert hasattr(tl.LazyNode, "average")
        assert hasattr(tl, "Average")
        assert hasattr(tl.LazyNode, "mean")
        assert hasattr(tl, "Mean")

    def test_api_basket(self):
        # Basket
        assert hasattr(tl.LazyNode, "__len__")
        assert hasattr(tl.LazyNode, "len")
        assert hasattr(tl, "Len")
        assert hasattr(tl.LazyNode, "countBasket")
        assert hasattr(tl, "CountBasket")
        assert hasattr(tl.LazyNode, "minBasket")
        assert hasattr(tl, "MinBasket")
        assert hasattr(tl.LazyNode, "maxBasket")
        assert hasattr(tl, "MaxBasket")
        assert hasattr(tl.LazyNode, "sumBasket")
        assert hasattr(tl, "SumBasket")
        assert hasattr(tl.LazyNode, "averageBasket")
        assert hasattr(tl, "AverageBasket")
        assert hasattr(tl.LazyNode, "meanBasket")
        assert hasattr(tl, "MeanBasket")

    def test_api_common_outputs(self):
        # Output
        assert hasattr(tl.LazyNode, "graph")
        assert hasattr(tl, "Graph")
        # assert hasattr(tl.LazyNode, 'pprint')
        # assert hasattr(tl, 'PPrint')
        assert hasattr(tl.LazyNode, "graphviz")
        assert hasattr(tl, "GraphViz")
        assert hasattr(tl.LazyNode, "dagre")
        assert hasattr(tl, "Dagre")
        assert hasattr(tl.LazyNode, "print")
        assert hasattr(tl, "Print")
        # assert hasattr(tl.LazyNode, "logging")
        # assert hasattr(tl, "Logging")

    def test_api_control_flow(self):
        # Control flow
        assert hasattr(tl.LazyNode, "if_")
        assert hasattr(tl, "If")

    def test_api_rolling(self):
        # rolling
        assert hasattr(tl.LazyNode, "rollingCount")
        assert hasattr(tl, "RollingCount")
        assert hasattr(tl.LazyNode, "rollingSum")
        assert hasattr(tl, "RollingSum")
        assert hasattr(tl.LazyNode, "rollingMin")
        assert hasattr(tl, "RollingMin")
        assert hasattr(tl.LazyNode, "rollingMax")
        assert hasattr(tl, "RollingMax")
        assert hasattr(tl.LazyNode, "rollingAverage")
        assert hasattr(tl, "RollingAverage")
        assert hasattr(tl.LazyNode, "diff")
        assert hasattr(tl, "Diff")
        assert hasattr(tl.LazyNode, "sma")
        assert hasattr(tl, "SMA")
        assert hasattr(tl.LazyNode, "ema")
        assert hasattr(tl, "EMA")
        assert hasattr(tl.LazyNode, "last")
        assert hasattr(tl, "Last")
        assert hasattr(tl.LazyNode, "first")
        assert hasattr(tl, "First")

    def test_api_finance(self):
        # Finance
        assert hasattr(tl.LazyNode, "rsi")
        assert hasattr(tl, "RSI")
        assert hasattr(tl.LazyNode, "macd")
        assert hasattr(tl, "MACD")

    def test_api_lazy_specific(self):
        """apis specific to lazy nodes"""
        # expiration/interval functions
        assert hasattr(tl.LazyNode, "expire")
        assert hasattr(tl, "Expire")
        assert hasattr(tl.LazyNode, "interval")
        assert hasattr(tl, "Interval")
