chamikaramj commented on code in PR #17487:
URL: https://github.com/apache/beam/pull/17487#discussion_r863116796
##########
sdks/python/apache_beam/io/gcp/bigquery_tools_test.py:
##########
@@ -242,6 +254,19 @@ def test_temporary_dataset_is_unique(self,
patched_time_sleep):
wrapper.create_temporary_dataset('project_id', 'location')
self.assertTrue(client.datasets.Get.called)
+ @mock.patch('time.sleep', return_value=None)
+ def test_user_agent_passed(self, sleep_mock):
+ wrapper = beam.io.gcp.bigquery_tools.BigQueryWrapper()
+ request_mock = mock.Mock()
+ wrapper.client._http.request = request_mock
+ try:
+ wrapper.create_temporary_dataset('project_id', 'location')
+ except: # pylint: disable=bare-except
+ # Ignore errors
Review Comment:
Ditto.
##########
sdks/python/apache_beam/io/gcp/bigquery_tools_test.py:
##########
@@ -220,6 +220,18 @@ def test_delete_dataset_retries_for_timeouts(self,
patched_time_sleep):
wrapper._delete_dataset('', '')
self.assertTrue(client.datasets.Delete.called)
+ @mock.patch('time.sleep', return_value=None)
+ @mock.patch('google.cloud._http.JSONConnection.http')
+ def test_user_agent_insert_all(self, http_mock, patched_sleep):
+ wrapper = beam.io.gcp.bigquery_tools.BigQueryWrapper()
+ try:
+ wrapper._insert_all_rows('p', 'd', 't', [{'name': 'any'}], None)
+ except: # pylint: disable=bare-except
+ # Ignore errors
Review Comment:
Let's explain why :)
##########
sdks/python/apache_beam/io/gcp/gcsio_test.py:
##########
@@ -420,6 +420,19 @@ def test_delete(self):
self.assertFalse(
gcsio.parse_gcs_path(file_name) in self.client.objects.files)
+ @mock.patch(
+ 'apache_beam.io.gcp.gcsio.auth.get_service_credentials',
+ wraps=lambda: None)
+ @mock.patch('apache_beam.io.gcp.gcsio.get_new_http')
+ def test_user_agent_passed(self, get_new_http_mock, get_service_creds_mock):
+ client = gcsio.GcsIO()
+ try:
+ client.get_bucket('mabucket')
+ except: # pylint: disable=bare-except
+ pass
Review Comment:
Ditto.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]