Skip to content

Commit 378a3d8

Browse files
committed
Added test_periodic_dataframes
1 parent 0fda93c commit 378a3d8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

streamz/tests/test_batch.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ def test_dataframes():
3737
assert result.z.tolist() == [3 * i for i in range(10)]
3838

3939

40+
def test_periodic_dataframes():
41+
pd = pytest.importorskip('pandas')
42+
from streamz.dataframe import PeriodicDataFrame
43+
from streamz.dataframe.core import random_datapoint
44+
df = random_datapoint()
45+
assert len(df)==1
46+
47+
def callback(**kwargs):
48+
return pd.DataFrame(dict(x=50, index=[pd.Timestamp.now()]))
49+
50+
df = PeriodicDataFrame(callback, interval='20ms')
51+
assert df.tail(0).x==50
52+
df.stop()
53+
54+
4055
def test_filter():
4156
a = Batch()
4257
f = a.filter(lambda x: x % 2 == 0)

0 commit comments

Comments
 (0)