Пример #1
0
 def test_database_delete_missing_project_id(self, mock_hook):
     mock_hook.return_value.get_database.return_value = {"name": DB_ID}
     op = CloudSpannerInstanceDatabaseDeleteOperator(
         instance_id=INSTANCE_ID, database_id=DB_ID, task_id="id")
     result = op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id="google_cloud_default")
     mock_hook.return_value.delete_database.assert_called_once_with(
         project_id=None, instance_id=INSTANCE_ID, database_id=DB_ID)
     self.assertTrue(result)
Пример #2
0
 def test_database_delete_exits_and_succeeds_if_database_does_not_exist(
         self, mock_hook):
     mock_hook.return_value.get_database.return_value = None
     op = CloudSpannerInstanceDatabaseDeleteOperator(
         project_id=PROJECT_ID,
         instance_id=INSTANCE_ID,
         database_id=DB_ID,
         task_id="id")
     result = op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id="google_cloud_default")
     mock_hook.return_value.delete_database.assert_not_called()
     self.assertTrue(result)
 def test_database_delete_exits_and_succeeds_if_database_does_not_exist(self,
                                                                        mock_hook):
     mock_hook.return_value.get_database.return_value = None
     op = CloudSpannerInstanceDatabaseDeleteOperator(
         project_id=PROJECT_ID,
         instance_id=INSTANCE_ID,
         database_id=DB_ID,
         task_id="id"
     )
     result = op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id="google_cloud_default")
     mock_hook.return_value.delete_database.assert_not_called()
     self.assertTrue(result)
 def test_database_delete_missing_project_id(self, mock_hook):
     mock_hook.return_value.get_database.return_value = {"name": DB_ID}
     op = CloudSpannerInstanceDatabaseDeleteOperator(
         instance_id=INSTANCE_ID,
         database_id=DB_ID,
         task_id="id"
     )
     result = op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id="google_cloud_default")
     mock_hook.return_value.delete_database.assert_called_once_with(
         project_id=None, instance_id=INSTANCE_ID, database_id=DB_ID
     )
     self.assertTrue(result)