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

32 lines
3.3 KiB
Python

from pathlib import Path
from datetime import datetime, timezone
import hashlib, json, zipfile, shutil
R=Path(__file__).resolve().parent.parent;P=R/'storage/app/private/investmoz-v2/portal-audit';O=R/'outputs/investmoz-internal-designation-20261011';O.mkdir(exist_ok=True)
load=lambda p:json.loads(p.read_text(encoding='utf-8-sig')); sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
plan=load(P/'internal-designation-plan.json'); S=Path(plan['source']); tests=load(P/'internal-designation-test-proof.json');browser=load(P/'internal-designation-browser.json')
assert tests['result']==browser['result']=='passed' and plan['production_build_passed'] and plan['target']['port']==55441
assert plan['delta_sha256']==hashlib.sha256(json.dumps(plan['files'],sort_keys=True).encode()).hexdigest()
for x in plan['files']:
assert sha(S/x['path'])==x['after_sha256']
assert (sha(R/x['path']) if (R/x['path']).is_file() else None)==x['before_sha256']
expected={x['path']:x['after_sha256'] for x in plan['files']}|{x['path']:x['sha256'] for x in plan['assets']}
package=O/('delta-designacao-interna-'+plan['delta_sha256'][:12]+'.zip');assert not package.exists()
with zipfile.ZipFile(package,'w',zipfile.ZIP_DEFLATED) as z:
for f,value in expected.items():assert sha(S/f)==value;z.write(S/f,f)
with zipfile.ZipFile(package) as z:
assert len(z.namelist())==len(set(z.namelist())) and set(z.namelist())==set(expected)
for f,h in expected.items():assert hashlib.sha256(z.read(f)).hexdigest()==h
manifest={k:plan[k] for k in ['delta_sha256','files','assets','production_build_passed','production_manifest_sha256']}
manifest.update({'prepared_at':datetime.now(timezone.utc).isoformat(),'active_base':'41caea0f900f','prior_delta_preserved':'41a5ce778932',
'package':package.name,'package_sha256':sha(package),'QA_only':True,'active_application_changes':0,'active_database_writes':0,
'new_tables':0,'new_columns':0,'automatic_accounts_organizations_representations_grants':0,
'services_configuration_changes':0,'country_preserved':True,'operational_workflow_enabled_in_destination':False,
'configuration_to_enable_after_separate_release_authorization':{'PORTAL_PROFILE_ADMINISTRATION_ENABLED':True,'PORTAL_PROFILE_ACCESS_ENABLED':False},
'scope':'Prepare internally designated portal staff through the existing authenticated administration; preserve actual opportunity promoter and approved independence',
'QA_tests':tests,'browser_criteria':browser['criteria'],'real_accounts_own_email_and_MFA':'pending; no credentials requested',
'operator_organization_metadata_storage':'Identity in existing organizations; contact/director/function/provenance in versioned audit snapshot linked to the same organization ID',
'deployment':'not authorized or executed for this revision'})
(O/'manifesto.json').write_text(json.dumps(manifest,indent=2,ensure_ascii=False),encoding='utf-8')
for src,dest in [('internal-designation-browser.json','navegador-qa.json'),('internal-designation-tests.xml','tests-qa.xml'),('internal-designation-administration-qa.png','atribuicoes-qa.png'),('internal-designation-real-promoter-draft-qa.png','rascunho-promotor-real-qa.png')]:shutil.copyfile(P/src,O/dest)
print(json.dumps({'result':'fixed_QA_package_verified','revision':plan['delta_sha256'][:12],'package_sha256':sha(package),'source_files':len(plan['files']),'assets':len(plan['assets']),'active_changes':0}))