5252 from google .cloud import dataflow
5353except ImportError :
5454 apiclient = None # type: ignore
55+ dataflow = None # type: ignore
5556# pylint: enable=wrong-import-order, wrong-import-position
5657
5758
@@ -266,6 +267,7 @@ def setup_mock_client_result(self, counter_list=None):
266267 mock_job_result .is_in_terminal_state .return_value = False
267268 return mock_client , mock_job_result
268269
270+ @unittest .skipIf (apiclient is None , 'GCP dependencies are not installed' )
269271 def test_cache_functions (self ):
270272 mock_client , mock_job_result = self .setup_mock_client_result (
271273 self .STRUCTURED_COUNTER_LIST )
@@ -283,6 +285,7 @@ def test_cache_functions(self):
283285 dm .query ()
284286 self .assertTrue (dm ._cached_metrics )
285287
288+ @unittest .skipIf (apiclient is None , 'GCP dependencies are not installed' )
286289 def test_query_structured_metrics (self ):
287290 mock_client , mock_job_result = self .setup_mock_client_result (
288291 self .STRUCTURED_COUNTER_LIST )
@@ -335,6 +338,7 @@ def test_translate_portable_job_step_name(self):
335338 'MyTestParDo' ,
336339 dm ._translate_step_name ('ref_AppliedPTransform_MyTestParDo_14' ))
337340
341+ @unittest .skipIf (apiclient is None , 'GCP dependencies are not installed' )
338342 def test_query_counters (self ):
339343 mock_client , mock_job_result = self .setup_mock_client_result (
340344 self .ONLY_COUNTERS_LIST )
@@ -358,6 +362,7 @@ def test_query_counters(self):
358362 sorted (query_result ['counters' ], key = lambda x : x .key .metric .name ),
359363 sorted (expected_counters , key = lambda x : x .key .metric .name ))
360364
365+ @unittest .skipIf (apiclient is None , 'GCP dependencies are not installed' )
361366 def test_system_counters_set_labels_and_step_name (self ):
362367 mock_client , mock_job_result = self .setup_mock_client_result (
363368 self .SYSTEM_COUNTERS_LIST )
0 commit comments