コード例 #1
0
 def test_create_dataset_raises_valueerror_if_dataset_exists(self):
     dataset_name = 'test_dataset'
     self.mock_client.return_value.create_dataset.side_effect = [
         exceptions.Conflict('Dataset %s exists.', dataset_name)
     ]
     with self.assertRaises(ValueError):
         self.bigquery_client.create_dataset(dataset_name,
                                             fail_if_exists=True)
コード例 #2
0
def test_write_object_failure_bucket_not_exist(mock_file, mock_adapter, mock_bucket):
    mock_blob = Mock(spec=google.cloud.storage.blob.Blob)
    mock_blob.upload_from_filename.side_effect = exceptions.Conflict('string')
    mock_bucket.blob.return_value = mock_blob
    mock_adapter.client.get_bucket.return_value = mock_bucket
    result = mock_adapter.write_file('bucket', mock_file, mock_file, True)
    assert result is False
    assert mock_adapter.errors
コード例 #3
0
def test_write_string_api_error(mock_adapter, mock_bucket):
    mock_blob = Mock(spec=google.cloud.storage.blob.Blob)
    mock_blob.upload_from_string.side_effect = exceptions.Conflict('string')
    mock_bucket.blob.return_value = mock_blob
    mock_adapter.client.get_bucket.return_value = mock_bucket
    result = mock_adapter.write_string('bucket', 'destination', 'string to write')
    assert result is False
    assert mock_adapter.errors
コード例 #4
0
ファイル: test_verify.py プロジェクト: spotify/klio
def test_verify_gcs_bucket_exists(klio_config, mock_storage):
    test_path = "gs://bucket/blob"
    mock_storage.create_bucket.side_effect = api_ex.Conflict("test")

    job = verify.VerifyJob(klio_config, True)
    job._storage_client = mock_storage
    actual = job._verify_gcs_bucket(test_path)

    assert actual is True
コード例 #5
0
def test_create_topic_google_api_call_error(mock_publisher):
    mock_publisher.publish_client.create_topic.side_effect = exceptions.Conflict('message')
    mock_publisher.set_topic('test')
    result = mock_publisher.create_topic()
    assert result is False
    assert mock_publisher.errors
コード例 #6
0
def test_subscribe_google_api_call_error(mock_sub_future):
    mock_sub_future.subscriber_client.subscribe.side_effect = exceptions.Conflict('message')
    mock_sub_future.set_subscription('test')
    result = mock_sub_future.subscribe(callback)
    assert result is False
    assert mock_sub_future.errors
コード例 #7
0
def test_create_subscription_google_api_call_error(mock_subscriber_configured):
    mock_subscriber_configured.subscriber_client.create_subscription.side_effect = exceptions.Conflict('message')
    result = mock_subscriber_configured.create_subscription()
    assert result is False
    assert mock_subscriber_configured.errors
コード例 #8
0
def test_log_struct_google_api_call_error_exception(mock_logger):
    mock_logger.logger.log_struct.side_effect = exceptions.Conflict('string')
    return_value = mock_logger.log_struct({"test": "test"})
    assert return_value is False
    assert mock_logger.errors
コード例 #9
0
def test_create_bucket_failure(mock_adapter):
    mock_adapter.client.create_bucket.side_effect = exceptions.Conflict('string')
    result = mock_adapter.make_bucket('string')
    assert result is False
    assert mock_adapter.errors