20 lines
1.6 KiB
Python
20 lines
1.6 KiB
Python
from pathlib import Path
|
|
import hashlib, json, re, shutil, subprocess
|
|
R=Path(__file__).resolve().parent.parent; P=R/'storage/app/private/investmoz-v2/portal-audit'
|
|
plan=json.loads((P/'onboarding-governance-plan.json').read_text()); S=Path(plan['source'])
|
|
assert S.parent==P and S.name.startswith('onboarding-qa-') and plan['target']['port']==55441
|
|
for row in plan['files']:
|
|
assert hashlib.sha256((S/row['path']).read_bytes()).hexdigest()==row['after_sha256']
|
|
if row['before_sha256']: assert hashlib.sha256((R/row['path']).read_bytes()).hexdigest()==row['before_sha256']
|
|
if (P/'onboarding-governance-tests.xml').exists():
|
|
shutil.copyfile(P/'onboarding-governance-tests.xml',P/'onboarding-governance-first-run.xml')
|
|
result=subprocess.run(['C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe',str(R/'tools/portal-onboarding-readiness.php'),'prepare-tests'],cwd=R,check=True,capture_output=True,text=True)
|
|
target=json.loads(result.stdout)['isolated_test_database']; assert target['port']==55441 and target['database'].endswith('_test')
|
|
old=plan['target']['database']; new=target['database']
|
|
for path in [S/'.env', S/'onboarding-phpunit.xml']:
|
|
text=path.read_text(); assert old in text; path.write_text(text.replace(old,new),encoding='utf-8')
|
|
plan['previous_test_database']=plan['target'];plan['target']=target
|
|
(P/'onboarding-governance-plan.json').write_text(json.dumps(plan,indent=2),encoding='utf-8')
|
|
shutil.copyfile(R/'tools/portal-onboarding-governance-test.php',S/'tests/Feature/PortalProfilePreparationTest.php')
|
|
print(json.dumps({'result':'fresh_isolated_QA_test_database','database':new,'port':55441,'active_changes':0}))
|