@mock.patch('airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.get_dataset')
@mock.patch('airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.update_dataset')
def test_run_grant_dataset_view_access_granting(self, mock_update, mock_get):
    view_table = f'{TABLE_ID}_view'
    view_dataset = f'{DATASET_ID}_view'
    view_access = AccessEntry(role=None, entity_type='view', entity_id={'projectId': PROJECT_ID, 'datasetId': view_dataset, 'tableId': view_table})
    dataset = Dataset(DatasetReference.from_string(DATASET_ID, PROJECT_ID))
    dataset.access_entries = []
    mock_get.return_value = dataset
    self.hook.run_grant_dataset_view_access(source_dataset=DATASET_ID, view_dataset=view_dataset, view_table=view_table)
    mock_get.assert_called_once_with(project_id=PROJECT_ID, dataset_id=DATASET_ID)
    assert (view_access in dataset.access_entries)
    mock_update.assert_called_once_with(fields=['access'], dataset_resource=dataset.to_api_repr(), project_id=PROJECT_ID)
@mock.patch('airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.get_dataset')
@mock.patch('airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.update_dataset')
def test_run_grant_dataset_view_access_granting(self, mock_update, mock_get):
    view_table = f'{TABLE_ID}_view'
    view_dataset = f'{DATASET_ID}_view'
    view_access = AccessEntry(role=None, entity_type='view', entity_id={'projectId': PROJECT_ID, 'datasetId': view_dataset, 'tableId': view_table})
    dataset = Dataset(DatasetReference.from_string(DATASET_ID, PROJECT_ID))
    dataset.access_entries = []
    mock_get.return_value = dataset
    self.hook.run_grant_dataset_view_access(source_dataset=DATASET_ID, view_dataset=view_dataset, view_table=view_table)
    mock_get.assert_called_once_with(project_id=PROJECT_ID, dataset_id=DATASET_ID)
    assert (view_access in dataset.access_entries)
    mock_update.assert_called_once_with(fields=['access'], dataset_resource=dataset.to_api_repr(), project_id=PROJECT_ID)