Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions python/pyspark/streaming/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
#

import datetime as dt
import glob
import os
import sys
Expand Down Expand Up @@ -206,6 +207,21 @@ def func(dstream):
expected = [[len(x)] for x in input]
self._test_func(input, func, expected)

def test_slice(self):
"""Basic operation test for DStream.slice."""
eol_python2 = dt.datetime(2020, 1, 1)
five_secs = dt.timedelta(seconds=5)
input = [eol_python2 - five_secs, eol_python2]
def func(dstream):
return dstream.slice()
expected = [[dt.datetime(2019, 12, 31, 23, 55)],
[dt.datetime(2019, 12, 31, 23, 56)],
[dt.datetime(2019, 12, 31, 23, 57)],
[dt.datetime(2019, 12, 31, 23, 58)],
[dt.datetime(2019, 12, 31, 23, 59)],
[dt.datetime(2020, 1, 1)]]
self._test_func(input, func, expected)

def test_reduce(self):
"""Basic operation test for DStream.reduce."""
input = [range(1, 5), range(5, 9), range(9, 13)]
Expand Down