Skip to content

Commit

Permalink
add test without mock
Browse files Browse the repository at this point in the history
  • Loading branch information
ihji committed May 7, 2022
1 parent ef8618c commit 38ce39f
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,29 @@ def test_glob_filter(self):
FullyQualifiedNamedTransform._resolve('apache_beam.Row')

@patch('importlib.import_module')
def test_resolve(self, mock_import_module):
def test_resolve_by_path_segment(self, mock_import_module):
mock_import_module.return_value = None
with FullyQualifiedNamedTransform.with_filter('*'):
FullyQualifiedNamedTransform._resolve('a.b.c.d')
mock_import_module.assert_has_calls(
[call('a'), call('a.b'), call('a.b.c'), call('a.b.c.d')])

def test_resolve(self):
# test _resolve with the module that is not exposed to the top level
with FullyQualifiedNamedTransform.with_filter('*'):
dataframe_transform = FullyQualifiedNamedTransform._resolve(
'apache_beam.dataframe.transforms.DataframeTransform')
from apache_beam.dataframe.transforms import DataframeTransform
self.assertIs(dataframe_transform, DataframeTransform)

# test _resolve with the module that will never be exposed
# to the top level in the future
with FullyQualifiedNamedTransform.with_filter('*'):
argument_placeholder = FullyQualifiedNamedTransform._resolve(
'apache_beam.internal.util.ArgumentPlaceholder')
from apache_beam.internal.util import ArgumentPlaceholder
self.assertIs(argument_placeholder, ArgumentPlaceholder)


class _TestTransform(beam.PTransform):
@classmethod
Expand Down

0 comments on commit 38ce39f

Please sign in to comment.