Skip to content

Commit

Permalink
[BEAM-8575] Test DoFn context params (#10130)
Browse files Browse the repository at this point in the history
* [BEAM-8575] Test DoFn context params

* fixup
  • Loading branch information
liumomo315 authored and chamikaramj committed Dec 10, 2019
1 parent 659039e commit bdd70ab
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions sdks/python/apache_beam/pipeline_test.py
Expand Up @@ -26,6 +26,7 @@
from builtins import range

import mock
from nose.plugins.attrib import attr

import apache_beam as beam
from apache_beam import typehints
Expand Down Expand Up @@ -641,6 +642,25 @@ def process(self, element, prefix, suffix=DoFn.SideInputParam):
assert_that(result, equal_to(['zyx-%s-xyz' % x for x in words_list]))
pipeline.run()

@attr('ValidatesRunner')
def test_element_param(self):
pipeline = TestPipeline()
input = [1, 2]
pcoll = (pipeline
| 'Create' >> Create(input)
| 'Ele param' >> Map(lambda element=DoFn.ElementParam: element))
assert_that(pcoll, equal_to(input))
pipeline.run()

@attr('ValidatesRunner')
def test_key_param(self):
pipeline = TestPipeline()
pcoll = (pipeline
| 'Create' >> Create([('a', 1), ('b', 2)])
| 'Key param' >> Map(lambda _, key=DoFn.KeyParam: key))
assert_that(pcoll, equal_to(['a', 'b']))
pipeline.run()

def test_window_param(self):
class TestDoFn(DoFn):
def process(self, element, window=DoFn.WindowParam):
Expand Down

0 comments on commit bdd70ab

Please sign in to comment.