Files
Investidor-V2/outputs/investmoz-parques-QA-20261016/prove-pending-location.py
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

15 lines
2.2 KiB
Python

from http_common import *
manager=login('manager');anon=session();top='0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1';admin='/api/v2/investment/admin/zones/'
public=call(anon,'/api/v2/investment/zones/'+top);detail=call(manager,admin+top);record=detail['record'];location=detail['locations'][0]
keys=['version_no','code','category','name','name_en','description','description_en','province','district','operator_id','legal_source_id','physical_category','legal_regime','operational_status','development_status','availability_status','area_components','source_evidence','area_value','area_unit','aliases','activities','resources','parent_zone_id','historical_territory']
data={k:v for k,v in record.items() if k in keys};data['resources'][0]['private_note']='QA-T2-PRIVADO-PRESERVAR';data['resources'][0]['support_document_ids']=[json.loads((out/'SUPORTE-QA-CORRIGIDO.json').read_text('utf-8'))['document_id']]
data['locations']=[{'geo_location_id':location['id'],'scope_type':location['scope_type'],'source_reference':location['source_reference']}]
saved=call(manager,admin+top,data,method='PUT');after=call(manager,admin+top)
check('existing_pending_location_control_not_blocked',saved['version_no']==12 and saved['public_version_no']==11)
check('same_location_does_not_duplicate_or_revalidate',after['locations']==detail['locations'])
check('location_explicit_save_preserves_public_11',call(anon,'/api/v2/investment/zones/'+top)==public)
case=json.loads((out/'CONTEXTO-QA.json').read_text('utf-8'))['existing_case'];owner=session('owner');dossier=call(owner,'/investimentos/'+case)
state={'zone_id':top,'T1':saved,'P1':public,'case_id':case,'zone_contexts':dossier['zone_contexts'],'description_after_old_editor':'SIMULAÇÃO QA — editor anterior: detalhes e controlo territorial preservados.'}
(private/'post-use-before.json').write_text(json.dumps(state,ensure_ascii=False,indent=2),'utf-8');(out/'T1-RESUMO-FINAL.json').write_text(json.dumps({'working_version':12,'public_version':11,'zone_id':top,'resources_sha256':hashlib.sha256(json.dumps(saved['resources'],sort_keys=True).encode()).hexdigest(),'reason':'Directed regression after preserving the existing pending-location control'},indent=2),'utf-8')
print(json.dumps({'working':12,'public':11,'locations_preserved':True}))