def setUp(self): with mock.patch( GCS_STRING.format('GoogleCloudBaseHook.__init__'), new=mock_base_gcp_hook_default_project_id, ): self.gcs_hook = gcs.GoogleCloudStorageHook( google_cloud_storage_conn_id='test')
def setUp(self): with mock.patch(BASE_STRING.format('GoogleCloudBaseHook.__init__')): self.gcs_hook = gcs.GoogleCloudStorageHook( google_cloud_storage_conn_id='test') # generate a 384KiB test file (larger than the minimum 256KiB multipart chunk size) self.testfile = tempfile.NamedTemporaryFile(delete=False) self.testfile.write(b"x" * 393216) self.testfile.flush()
def test_storage_client_creation(self, mock_client, mock_get_creds_and_project_id, mock_client_info): hook = gcs.GoogleCloudStorageHook() result = hook.get_conn() # test that Storage Client is called with required arguments mock_client.assert_called_once_with(client_info="CLIENT_INFO", credentials="CREDENTIALS", project="PROJECT_ID") self.assertEqual(mock_client.return_value, result)