Abacn commented on code in PR #25965:
URL: https://github.com/apache/beam/pull/25965#discussion_r1210679761
##########
sdks/python/apache_beam/io/gcp/bigquery_test.py:
##########
@@ -788,111 +788,116 @@ def noop(table, **kwargs):
with_auto_sharding=True,
test_client=client))
- @parameterized.expand([
- param(
- exception_type=exceptions.Forbidden if exceptions else None,
- error_message='accessDenied'),
- param(
- exception_type=exceptions.ServiceUnavailable if exceptions else None,
- error_message='backendError')
- ])
- def test_load_job_exception(self, exception_type, error_message):
-
- with mock.patch.object(bigquery_v2_client.BigqueryV2.JobsService,
- 'Insert') as mock_load_job,\
- mock.patch('apache_beam.io.gcp.internal.clients'
- '.storage.storage_v1_client.StorageV1.ObjectsService'),\
- mock.patch('time.sleep'),\
- self.assertRaises(Exception) as exc,\
- beam.Pipeline() as p:
-
- mock_load_job.side_effect = exception_type(error_message)
-
- _ = (
- p
- | beam.Create([{
- 'columnA': 'value1'
- }])
- | WriteToBigQuery(
- table='project:dataset.table',
- schema={
- 'fields': [{
- 'name': 'columnA', 'type': 'STRING', 'mode': 'NULLABLE'
- }]
- },
- create_disposition='CREATE_NEVER',
- custom_gcs_temp_location="gs://temp_location",
- method='FILE_LOADS'))
-
- mock_load_job.assert_called()
- self.assertIn(error_message, exc.exception.args[0])
-
- @parameterized.expand([
- param(
- exception_type=exceptions.ServiceUnavailable if exceptions else None,
- error_message='backendError'),
- param(
- exception_type=exceptions.InternalServerError if exceptions else
None,
- error_message='internalError'),
- ])
- def test_copy_load_job_exception(self, exception_type, error_message):
-
- from apache_beam.io.gcp import bigquery_file_loads
-
- old_max_file_size = bigquery_file_loads._DEFAULT_MAX_FILE_SIZE
- old_max_partition_size = bigquery_file_loads._MAXIMUM_LOAD_SIZE
- old_max_files_per_partition = bigquery_file_loads._MAXIMUM_SOURCE_URIS
- bigquery_file_loads._DEFAULT_MAX_FILE_SIZE = 15
- bigquery_file_loads._MAXIMUM_LOAD_SIZE = 30
- bigquery_file_loads._MAXIMUM_SOURCE_URIS = 1
-
- with mock.patch.object(bigquery_v2_client.BigqueryV2.JobsService,
- 'Insert') as mock_insert_copy_job, \
- mock.patch.object(BigQueryWrapper,
- 'perform_load_job') as mock_load_job, \
- mock.patch.object(BigQueryWrapper,
- 'wait_for_bq_job'), \
- mock.patch('apache_beam.io.gcp.internal.clients'
- '.storage.storage_v1_client.StorageV1.ObjectsService'), \
- mock.patch('time.sleep'), \
- self.assertRaises(Exception) as exc, \
- beam.Pipeline() as p:
-
- mock_insert_copy_job.side_effect = exception_type(error_message)
-
- dummy_job_reference =
beam.io.gcp.internal.clients.bigquery.JobReference()
- dummy_job_reference.jobId = 'job_id'
- dummy_job_reference.location = 'US'
- dummy_job_reference.projectId = 'apache-beam-testing'
-
- mock_load_job.return_value = dummy_job_reference
-
- _ = (
- p
- | beam.Create([{
- 'columnA': 'value1'
- }, {
- 'columnA': 'value2'
- }, {
- 'columnA': 'value3'
- }])
- | WriteToBigQuery(
- table='project:dataset.table',
- schema={
- 'fields': [{
- 'name': 'columnA', 'type': 'STRING', 'mode': 'NULLABLE'
- }]
- },
- create_disposition='CREATE_NEVER',
- custom_gcs_temp_location="gs://temp_location",
- method='FILE_LOADS'))
-
- bigquery_file_loads._DEFAULT_MAX_FILE_SIZE = old_max_file_size
- bigquery_file_loads._MAXIMUM_LOAD_SIZE = old_max_partition_size
- bigquery_file_loads._MAXIMUM_SOURCE_URIS = old_max_files_per_partition
- self.assertEqual(4, mock_insert_copy_job.call_count)
- self.assertIn(error_message, exc.exception.args[0])
+# ## Commented out due to unittest.skip not working
Review Comment:
How about put skip inside `parameterized.expand`? Or you can even skip it
inside the test.
--
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]