import tributary.streaming as ts


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

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

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

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

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

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

    def test_api_inputs(self):
        # inputs
        assert hasattr(ts, "Console")
        assert hasattr(ts, "File")
        assert hasattr(ts, "FileSource")
        assert hasattr(ts, "HTTP")
        assert hasattr(ts, "HTTPSource")
        assert hasattr(ts, "HTTPServer")
        assert hasattr(ts, "HTTPServerSource")
        assert hasattr(ts, "Kafka")
        assert hasattr(ts, "KafkaSource")
        assert hasattr(ts, "Postgres")
        assert hasattr(ts, "PostgresSource")
        assert hasattr(ts, "SocketIO")
        assert hasattr(ts, "SocketIOSource")
        assert hasattr(ts, "SSE")
        assert hasattr(ts, "SSESource")
        assert hasattr(ts, "SubprocessSource")
        assert hasattr(ts, "WebSocket")
        assert hasattr(ts, "WebSocketServer")
        assert hasattr(ts, "WebSocketSource")

    def test_api_outputs(self):
        # outputs
        assert hasattr(ts.StreamingNode, "foo")
        assert hasattr(ts, "FooOutput")
        assert hasattr(ts.StreamingNode, "collect")
        assert hasattr(ts, "Collect")
        assert hasattr(ts.StreamingNode, "perspective")
        assert hasattr(ts, "Perspective")
        assert hasattr(ts.StreamingNode, "file")
        assert hasattr(ts, "FileSink")
        assert hasattr(ts.StreamingNode, "http")
        assert hasattr(ts, "HTTPSink")
        assert hasattr(ts.StreamingNode, "httpServer")
        assert hasattr(ts, "HTTPServerSink")
        assert hasattr(ts.StreamingNode, "kafka")
        assert hasattr(ts, "KafkaSink")
        assert hasattr(ts.StreamingNode, "postgres")
        assert hasattr(ts, "PostgresSink")
        assert hasattr(ts.StreamingNode, "socketio")
        assert hasattr(ts, "SocketIOSink")
        assert hasattr(ts.StreamingNode, "sse")
        assert hasattr(ts, "SSESink")
        assert hasattr(ts.StreamingNode, "websocket")
        assert hasattr(ts, "WebSocketSink")
        assert hasattr(ts.StreamingNode, "websocketServer")
        assert hasattr(ts, "WebSocketServerSink")
        assert hasattr(ts.StreamingNode, "email")
        assert hasattr(ts, "EmailSink")
        assert hasattr(ts.StreamingNode, "textMessage")
        assert hasattr(ts, "TextMessageSink")
        assert hasattr(ts.StreamingNode, "queue")
        assert hasattr(ts, "QueueSink")

    def test_api_other_inputs(self):
        # Other inputs
        assert hasattr(ts, "Timer")
        assert hasattr(ts, "Const")
        assert hasattr(ts, "Curve")
        assert hasattr(ts, "Foo")
        assert hasattr(ts, "Queue")
        assert hasattr(ts, "Random")

    def test_api_streaming_specific(self):
        """apis specific to streaming nodes"""
        # Timing and stream mapping
        assert hasattr(ts.StreamingNode, "delay")
        assert hasattr(ts, "Delay")
        assert hasattr(ts.StreamingNode, "debounce")
        assert hasattr(ts, "Debounce")
        assert hasattr(ts.StreamingNode, "apply")
        assert hasattr(ts, "Apply")
        assert hasattr(ts.StreamingNode, "window")
        assert hasattr(ts, "Window")
        assert hasattr(ts.StreamingNode, "unroll")
        assert hasattr(ts, "Unroll")
        assert hasattr(ts.StreamingNode, "unrollDataFrame")
        assert hasattr(ts, "UnrollDataFrame")
        assert hasattr(ts.StreamingNode, "merge")
        assert hasattr(ts, "Merge")
        assert hasattr(ts.StreamingNode, "listMerge")
        assert hasattr(ts, "ListMerge")
        assert hasattr(ts.StreamingNode, "dictMerge")
        assert hasattr(ts, "DictMerge")
        assert hasattr(ts.StreamingNode, "map")
        assert hasattr(ts, "FixedMap")
        assert hasattr(ts.StreamingNode, "reduce")
        assert hasattr(ts, "Reduce")
        assert hasattr(ts.StreamingNode, "proc")
        assert hasattr(ts, "Subprocess")
