49 lines
3.3 KiB
Python
49 lines
3.3 KiB
Python
from pathlib import Path
|
|
from datetime import datetime, timezone
|
|
from urllib.parse import urlencode
|
|
import importlib.util, json, hashlib
|
|
OUT = Path(__file__).resolve().parent
|
|
ROOT = OUT.parent.parent
|
|
spec = importlib.util.spec_from_file_location('transport', OUT/'consumer-lot-lib.py')
|
|
lib = importlib.util.module_from_spec(spec); spec.loader.exec_module(lib)
|
|
dest = OUT/'option-B6-portfolio-recovery-HTTP.json'; assert not dest.exists()
|
|
pre = json.loads((OUT/'option-B6-preflight.json').read_text(encoding='utf-8'))
|
|
proof = {'at': datetime.now(timezone.utc).isoformat(), 'target': lib.TARGET,
|
|
'active_writes': 0, 'browser_observed': False, 'details': []}
|
|
for role, path in [('QA_before', ROOT/'storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742/storage/app/private/option-B6-before/InvestmentRelations.php'),
|
|
('QA_after', ROOT/'storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742/app/Services/InvestmentRelations.php'),
|
|
('active_read_only', ROOT/'app/Services/InvestmentRelations.php')]:
|
|
proof[role] = hashlib.sha256(path.read_bytes()).hexdigest()
|
|
c = lib.Client()
|
|
private_keys = {'management_draft','workflow_context','payload_ciphertext','opportunity_documents','password','two_factor_secret','storage_path','private_path'}
|
|
def check(value):
|
|
if isinstance(value,dict):
|
|
assert not set(value)&private_keys
|
|
for v in value.values(): check(v)
|
|
elif isinstance(value,list):
|
|
for v in value: check(v)
|
|
try:
|
|
for row in pre['public_portfolios']:
|
|
kind = 'corridor' if row['corridor_id'] else 'project' if row['project_id'] else 'cluster'
|
|
p = c.call('GET','/carteira/'+row['id'],json_response=False)
|
|
assert p['record']['id']==row['id'] and p['management'] is False
|
|
check({k:p[k] for k in ['record','related','geography','opportunities']})
|
|
if kind=='corridor': assert p['geography']['source_evidence']==[]
|
|
proof['details'].append({'id':row['id'],'kind':kind,'HTTP':200,
|
|
'source_evidence_count':len(p['geography']['source_evidence']),
|
|
'geography_keys':list(p['geography'])})
|
|
corridor = next(r for r in pre['public_portfolios'] if r['corridor_id'])
|
|
filtered=c.call('GET','/carteira?'+urlencode({'kind':'corridor','q':'Inhambane'}),json_response=False)
|
|
assert any(r['id']==corridor['id'] for r in filtered['records']['data'])
|
|
empty=c.call('GET','/carteira?q=QA-NO-MATCH-B6-20261013',json_response=False)
|
|
assert empty['records']['total']==0
|
|
proof.update(result='passed',filtered_existing_corridor=True,empty_result_count=0,
|
|
no_geometry_or_source_association_created=True,previous_map_cases_reused='option-B6-public-map-portfolio-HTTP.json',
|
|
visual_pending=['map rendering','filters visible and restored','keyboard/focus and absence messages'])
|
|
except Exception as e:
|
|
proof.update(result='stopped',error_type=type(e).__name__,missing_key=str(e) if isinstance(e,KeyError) else None)
|
|
proof['requests']=lib.events
|
|
dest.write_text(json.dumps(proof,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
|
|
print(json.dumps({k:v for k,v in proof.items() if k!='requests'},ensure_ascii=False))
|
|
raise SystemExit(0 if proof['result']=='passed' else 1)
|