@@ -333,6 +333,60 @@ def read_from_q():
333333 assert end - start >= 0.2
334334
335335
336+ # TODO: looks like gen_test and pytest.mark.parametrize don't play nicely together:
337+ # TypeError: test_timed_window_unique() missing 5 required positional arguments: 'interval', 'key', 'keep', 'elements', and 'exp_result'
338+ # I think gen_test() needs to be modified for this to work, but unsure how
339+ # TODO: fix tests' exp_result values and the logic inside, once it runs without ^ error
340+ # @gen_test()
341+ # @pytest.mark.parametrize(
342+ # "interval,key,keep,elements,exp_result",
343+ # [
344+ # (0.2, sz.identity, "first", [1, 2, 1, 3, 1, 3, 3, 2], [(1, 2, 3), (1, 3, 2)]),
345+ # (0.2, sz.identity, "last", [1, 2, 1, 3, 1, 3, 3, 2], [(2, 1, 3), (1, 3, 2)]),
346+ # (
347+ # 0.02,
348+ # len,
349+ # "last",
350+ # ["f", "fo", "f", "foo", "f", "foo", "foo", "fo"],
351+ # [("fo", "f", "foo"), ("f", "foo", "fo")],
352+ # ),
353+ # (
354+ # 0.02,
355+ # "id",
356+ # "first",
357+ # [{"id": 0, "foo": "bar"}, {"id": 0, "foo": "baz"}, {"id": 1, "foo": "bat"}],
358+ # [({"id": 0, "foo": "bar"}, {"id": 1, "foo": "bat"})],
359+ # ),
360+ # (
361+ # 0.02,
362+ # "id",
363+ # "last",
364+ # [{"id": 0, "foo": "bar"}, {"id": 0, "foo": "baz"}, {"id": 1, "foo": "bat"}],
365+ # [({"id": 0, "foo": "baz"}, {"id": 1, "foo": "bat"})],
366+ # ),
367+ # ]
368+ # )
369+ # def test_timed_window_unique(interval, key, keep, elements, exp_result):
370+ # import pdb; pdb.set_trace()
371+ # source = Stream(asynchronous=True)
372+ # a = source.timed_window_unique(interval, key, keep)
373+
374+ # assert a.loop is IOLoop.current()
375+ # L = a.sink_to_list()
376+
377+ # for ele in elements:
378+ # yield source.emit(ele)
379+ # yield gen.sleep(0.006)
380+ # yield gen.sleep(a.interval)
381+
382+ # assert L
383+ # assert all(len(x) <= 3 for x in L)
384+ # assert any(len(x) >= 2 for x in L)
385+
386+ # yield gen.sleep(0.1)
387+ # assert not L[-1]
388+
389+
336390@gen_test ()
337391def test_timed_window ():
338392 source = Stream (asynchronous = True )
0 commit comments