[CmdletBinding()] param( [Parameter(Mandatory=$true)][string]$MessageId, [Parameter(Mandatory=$true)][string]$Recipient ) $ErrorActionPreference = "Stop" if ([string]::IsNullOrWhiteSpace($env:SCHEDULING_TEST_DATABASE)) { throw "Set SCHEDULING_TEST_DATABASE to an isolated test ledger." } $projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path $pythonCommand = Get-Command python -ErrorAction SilentlyContinue if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." } $env:PYTHONPATH = Join-Path $projectRoot "src" $env:SCHEDULING_TEST_MESSAGE_ID = $MessageId $env:SCHEDULING_TEST_RECIPIENT = $Recipient try { & $pythonCommand.Source (Join-Path $PSScriptRoot "record_supervised_postmark_confirmation_delivery.py"); exit $LASTEXITCODE } finally { Remove-Item Env:\PYTHONPATH,Env:\SCHEDULING_TEST_MESSAGE_ID,Env:\SCHEDULING_TEST_RECIPIENT -ErrorAction SilentlyContinue }