def test_to_set(self): pipeline = TestPipeline() the_list = [6, 3, 1, 1, 9, 1, 5, 2, 0, 6] pcoll = pipeline | 'start' >> Create(the_list) result = pcoll | 'to set' >> combine.ToSet() def matcher(expected): def match(actual): equal_to(expected[0])(actual[0]) return match assert_that(result, matcher(set(the_list)))
def test_to_set(self): pipeline = TestPipeline() the_list = [6, 3, 1, 1, 9, 1, 5, 2, 0, 6] timestamp = 0 pcoll = pipeline | 'start' >> Create(the_list) result = pcoll | 'to set' >> combine.ToSet() # Now for global combines without default timestamped = pcoll | Map(lambda x: TimestampedValue(x, timestamp)) windowed = timestamped | 'window' >> WindowInto(FixedWindows(60)) result_windowed = ( windowed | 'to set wo defaults' >> combine.ToSet().without_defaults()) def matcher(expected): def match(actual): equal_to(expected[0])(actual[0]) return match assert_that(result, matcher(set(the_list))) assert_that( result_windowed, matcher(set(the_list)), label='to-set-wo-defaults')