def test_instance_query_dml(self, mock_hook): mock_hook.return_value.execute_dml.return_value = None op = SpannerQueryDatabaseInstanceOperator( project_id=PROJECT_ID, instance_id=INSTANCE_ID, database_id=DB_ID, query=INSERT_QUERY, task_id="id" ) op.execute(None) mock_hook.assert_called_once_with(gcp_conn_id="google_cloud_default") mock_hook.return_value.execute_dml.assert_called_once_with( project_id=PROJECT_ID, instance_id=INSTANCE_ID, database_id=DB_ID, queries=[INSERT_QUERY] )
def test_instance_query_missing_project_id(self, mock_hook): mock_hook.return_value.execute_sql.return_value = None op = SpannerQueryDatabaseInstanceOperator( instance_id=INSTANCE_ID, database_id=DB_ID, query=INSERT_QUERY, task_id="id" ) result = op.execute(None) # pylint: disable=assignment-from-no-return mock_hook.assert_called_once_with(gcp_conn_id="google_cloud_default") mock_hook.return_value.execute_dml.assert_called_once_with( project_id=None, instance_id=INSTANCE_ID, database_id=DB_ID, queries=[INSERT_QUERY] ) self.assertIsNone(result)