@@ -220,46 +220,33 @@ def test_sdf_wrap_range_source(self):
220220
221221
222222class UseSdfUnboundedSourcesTests (unittest .TestCase ):
223- """Mirrors UseSdfBoundedSourcesTests for the new UnboundedSource branch in
224- iobase.Read.expand(). Uses CountingSource from unbounded_source_test as the
225- fake finite UnboundedSource (avoids dragging the network in ).
223+ """Covers the UnboundedSource branch in
224+ `` iobase.Read.expand()`` . Uses ``UnboundedCountingSource`` from
225+ ``unbounded_source_test`` as a finite fake source (no network ).
226226 """
227- def test_read_dispatches_to_read_from_unbounded_source (self ):
228- from apache_beam .io .unbounded_source_test import CountingSource
229- with mock .patch (
230- 'apache_beam.io.unbounded_source.ReadFromUnboundedSource.expand'
231- ) as mock_expand :
232- mock_expand .side_effect = (
233- lambda pbegin : pbegin | beam .Impulse () | beam .Map (lambda _ : 'fake' ))
234- with beam .Pipeline () as p :
235- out = p | beam .io .Read (CountingSource (3 ))
236- assert_that (out , equal_to (['fake' ]))
237- mock_expand .assert_called_once ()
238-
239227 def test_read_end_to_end_unbounded (self ):
240- from apache_beam .io .unbounded_source_test import CountingSource
228+ from apache_beam .io .unbounded_source_test import UnboundedCountingSource
241229 with beam .Pipeline () as p :
242- out = p | beam .io .Read (CountingSource (5 ))
230+ out = p | beam .io .Read (UnboundedCountingSource (5 ))
243231 assert_that (out , equal_to ([0 , 1 , 2 , 3 , 4 ]))
244232
245233 def test_read_unbounded_pcollection_is_unbounded (self ):
246- from apache_beam .io .unbounded_source_test import CountingSource
234+ from apache_beam .io .unbounded_source_test import UnboundedCountingSource
247235 with beam .Pipeline () as p :
248- out = p | beam .io .Read (CountingSource (3 ))
236+ out = p | beam .io .Read (UnboundedCountingSource (3 ))
249237 self .assertFalse (out .is_bounded )
250238
251239 def test_to_runner_api_emits_unbounded_read_payload (self ):
252240 """``Read.to_runner_api_parameter`` must serialize an UnboundedSource as
253- ``READ.urn`` with ``IsBounded.UNBOUNDED``. The runner-side handler is W2
254- and ignores this enum today, but the wire format must round-trip
255- consistently for pipeline persistence / cross-runner submission.
241+ ``READ.urn`` with ``IsBounded.UNBOUNDED`` so the wire format round-trips
242+ consistently for pipeline persistence and cross-runner submission.
256243 """
257- from apache_beam .io .unbounded_source_test import CountingSource
244+ from apache_beam .io .unbounded_source_test import UnboundedCountingSource
258245 from apache_beam .portability import common_urns
259246 from apache_beam .portability .api import beam_runner_api_pb2
260247 from apache_beam .runners .pipeline_context import PipelineContext
261248
262- read = beam .io .Read (CountingSource (5 ))
249+ read = beam .io .Read (UnboundedCountingSource (5 ))
263250 urn , payload = read .to_runner_api_parameter (PipelineContext ())
264251
265252 self .assertEqual (urn , common_urns .deprecated_primitives .READ .urn )
@@ -274,12 +261,11 @@ def test_read_unbounded_round_trips_through_runner_api(self):
274261 transform must be a ``Read`` wrapping an equivalent UnboundedSource.
275262 """
276263 from apache_beam .io .unbounded_source import UnboundedSource
277- from apache_beam .io .unbounded_source_test import CountingSource
278- from apache_beam .portability import common_urns
264+ from apache_beam .io .unbounded_source_test import UnboundedCountingSource
279265 from apache_beam .portability .api import beam_runner_api_pb2
280266 from apache_beam .runners .pipeline_context import PipelineContext
281267
282- original = beam .io .Read (CountingSource (7 ))
268+ original = beam .io .Read (UnboundedCountingSource (7 ))
283269 context = PipelineContext ()
284270 urn , payload = original .to_runner_api_parameter (context )
285271
@@ -290,7 +276,7 @@ def test_read_unbounded_round_trips_through_runner_api(self):
290276
291277 self .assertIsInstance (restored , iobase .Read )
292278 self .assertIsInstance (restored .source , UnboundedSource )
293- self .assertIsInstance (restored .source , CountingSource )
279+ self .assertIsInstance (restored .source , UnboundedCountingSource )
294280 self .assertFalse (restored .source .is_bounded ())
295281 # Verify the source's internal state survived pickle round-trip.
296282 self .assertEqual (restored .source ._count , 7 )
0 commit comments