Beispiel #1
0
 def test_http_server(self):
     ss = ts.HTTPServerSource(json=True, host="127.0.0.1", port=12345)
     w = ts.Window(ss)
     out = ts.run(w, blocking=False)
     try:
         time.sleep(5)
         _ = requests.post("http://127.0.0.1:12345/",
                           json={
                               "test": 1,
                               "test2": 2
                           })
         time.sleep(5)
         assert w._accum == [{"test": 1, "test2": 2}]
     finally:
         asyncio.set_event_loop(asyncio.new_event_loop())
         try:
             out.stop()
         except RuntimeError:
             pass
    def test_http_server(self):
        inp = ts.Random(interval=1, count=2)
        ss = ts.HTTPServerSink(inp, json=True, port=12346)
        w = ts.Window(ss)
        out = ts.run(w, blocking=False)

        try:
            time.sleep(1.5)
            resp = requests.get("http://127.0.0.1:12346/")
            print(resp.json())
            time.sleep(1)
            resp = requests.get("http://127.0.0.1:12346/")
            print(resp.json())
            time.sleep(2)
            print(w._accum)
            assert len(w._accum) == 2
        finally:
            asyncio.set_event_loop(asyncio.new_event_loop())
            try:
                out.stop()
            except RuntimeError:
                pass
 def test_window_fixed_size_full_only(self):
     assert ts.run(ts.Window(ts.Foo(foo), size=2,
                             full_only=True)) == [[1, 2]]
 def test_window_fixed_size(self):
     assert ts.run(ts.Window(ts.Foo(foo), size=2)) == [[1], [1, 2]]
 def test_window_any_size(self):
     assert ts.run(ts.Window(ts.Foo(foo))) == [[1], [1, 2]]
Beispiel #6
0
 def test_window_any_size(self):
     assert ts.run(ts.Window(ts.Func(func))) == [[1], [1, 2]]