Files
Investidor-V2/tools/portal-internal-designation-run-tests.py
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

17 lines
2.0 KiB
Python

from pathlib import Path
import json, subprocess, xml.etree.ElementTree as ET
R=Path(__file__).resolve().parent.parent;P=R/'storage/app/private/investmoz-v2/portal-audit'
plan=json.loads((P/'internal-designation-plan.json').read_text()); S=Path(plan['source']); d=plan['target']['database']
assert plan['target']['port']==55441 and d=='onboarding_internal_20261011_191450_test' and S.name.startswith('onboarding-qa-internal-')
pg='C:/Program Files/PostgreSQL/17/bin/psql.exe'
probe=subprocess.run([pg,'-h','127.0.0.1','-p','55441','-U','investmoz_test','-d',d,'-At','-c','SELECT current_database(),inet_server_port();'],capture_output=True,text=True,check=True)
assert probe.stdout.strip()==d+'|55441'
# Only the synthetic disposable test database. migrate:fresh does not remove this extension schema.
subprocess.run([pg,'-h','127.0.0.1','-p','55441','-U','investmoz_test','-d',d,'-v','ON_ERROR_STOP=1','-c','DROP SCHEMA IF EXISTS skills_edu CASCADE; DROP SCHEMA public CASCADE; CREATE SCHEMA public AUTHORIZATION investmoz_test;'],capture_output=True,text=True,check=True)
with (P/'internal-designation-tests.log').open('w',encoding='utf-8') as log:
result=subprocess.run(['C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe',str(R/'vendor/phpunit/phpunit/phpunit'),'--configuration',str(S/'phpunit.xml'),'--filter','PortalInternalDesignationTest|PortalProfilePreparationTest','--log-junit',str(P/'internal-designation-tests.xml')],cwd=R,stdout=log,stderr=subprocess.STDOUT,timeout=180)
root=ET.parse(P/'internal-designation-tests.xml').getroot(); cases=list(root.iter('testcase'))
failed=[{'test':c.get('name'),'issue':(next(iter(c),None).text or '')[:450]} for c in cases if c.find('failure') is not None or c.find('error') is not None]
proof={'result':'passed' if result.returncode==0 else 'stopped','tests':len(cases),'failures':failed,'QA_database':d,'port':55441,'active_writes':0}
(P/'internal-designation-test-proof.json').write_text(json.dumps(proof,indent=2,ensure_ascii=False),encoding='utf-8'); print(json.dumps(proof,ensure_ascii=False));raise SystemExit(result.returncode)