示例#1
0
 def test_delete_execute_empty_project_id(self, mock_hook):
     op = BigtableDeleteInstanceOperator(instance_id=INSTANCE_ID,
                                         task_id="id",
                                         gcp_conn_id=GCP_CONN_ID)
     op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.delete_instance.assert_called_once_with(
         project_id=None, instance_id=INSTANCE_ID)
示例#2
0
 def test_deleting_instance_that_doesnt_exists_empty_project_id(
         self, mock_hook):
     op = BigtableDeleteInstanceOperator(instance_id=INSTANCE_ID,
                                         task_id="id",
                                         gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.delete_instance.side_effect = mock.Mock(
         side_effect=google.api_core.exceptions.NotFound(
             "Instance not found."))
     op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.delete_instance.assert_called_once_with(
         project_id=None, instance_id=INSTANCE_ID)
示例#3
0
    def test_different_error_reraised(self, mock_hook):
        op = BigtableDeleteInstanceOperator(project_id=PROJECT_ID,
                                            instance_id=INSTANCE_ID,
                                            task_id="id",
                                            gcp_conn_id=GCP_CONN_ID)
        mock_hook.return_value.delete_instance.side_effect = mock.Mock(
            side_effect=google.api_core.exceptions.GoogleAPICallError('error'))

        with self.assertRaises(google.api_core.exceptions.GoogleAPICallError):
            op.execute(None)

        mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
        mock_hook.return_value.delete_instance.assert_called_once_with(
            project_id=PROJECT_ID, instance_id=INSTANCE_ID)
示例#4
0
 def test_delete_execute(self, mock_hook):
     op = BigtableDeleteInstanceOperator(
         project_id=PROJECT_ID,
         instance_id=INSTANCE_ID,
         task_id="id",
         gcp_conn_id=GCP_CONN_ID,
         impersonation_chain=IMPERSONATION_CHAIN,
     )
     op.execute(None)
     mock_hook.assert_called_once_with(
         gcp_conn_id=GCP_CONN_ID,
         impersonation_chain=IMPERSONATION_CHAIN,
     )
     mock_hook.return_value.delete_instance.assert_called_once_with(
         project_id=PROJECT_ID, instance_id=INSTANCE_ID)
示例#5
0
 def test_deleting_instance_that_doesnt_exists(self, mock_hook):
     op = BigtableDeleteInstanceOperator(
         project_id=PROJECT_ID,
         instance_id=INSTANCE_ID,
         task_id="id",
         gcp_conn_id=GCP_CONN_ID,
         impersonation_chain=IMPERSONATION_CHAIN,
     )
     mock_hook.return_value.delete_instance.side_effect = mock.Mock(
         side_effect=google.api_core.exceptions.NotFound(
             "Instance not found."))
     op.execute(None)
     mock_hook.assert_called_once_with(
         gcp_conn_id=GCP_CONN_ID,
         impersonation_chain=IMPERSONATION_CHAIN,
     )
     mock_hook.return_value.delete_instance.assert_called_once_with(
         project_id=PROJECT_ID, instance_id=INSTANCE_ID)