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

20 lines
2.7 KiB
Python

from http_common import *
state=json.loads((private/'post-use-before.json').read_text('utf-8'));manager=login('manager');anon=session();top=state['zone_id']
actual=call(manager,'/api/v2/investment/admin/zones/'+top)['record']
check('old_editor_actual_save_new_text_recovered',actual['description']==state['description_after_old_editor'] and actual['version_no']==state['T1']['version_no']+1)
for name in ['resources','activities','area_components','source_evidence','id','code','public_version_no']:
check('old_editor_save_preserves_'+name,actual[name]==state['T1'][name])
check('old_editor_save_P1_unchanged',call(anon,'/api/v2/investment/zones/'+top)==state['P1'])
view=call(manager,'/investimentos/'+state['case_id']);check('compatible_reader_same_UUID_consulted_version',view['zone_contexts']==state['zone_contexts'])
hashes=json.loads((out/'PUBLIC-T1-HASHES.json').read_text('utf-8'))
for i,(path,expected) in enumerate(hashes.items()):
call(anon,path);check('old_editor_save_public_consumer_unchanged_'+str(i+1),proof['events'][-1]['body_sha256']==expected)
manifest=json.loads((private/'source/public/build/manifest.json').read_text('utf-8'));entry=manifest['resources/js/pages/investment/zone.tsx']['file']
assets=json.loads((out/'EDITOR-ATIVOS-OBSERVADOS.json').read_text('utf-8'));check('old_editor_asset_observed_in_browser',any(a['url']==f['url']+'/build/'+entry for a in assets['assets']))
raw=urllib.request.urlopen(f['url']+'/build/'+entry,timeout=10).read();asset_hash=hashlib.sha256(raw).hexdigest()
check('served_old_editor_asset_matches_coherent_compatibility_build',asset_hash==hashlib.sha256((private/'compatibility-build'/entry).read_bytes()).hexdigest())
call(manager,'/api/v2/investment/admin/zones/'+top,{**{k:v for k,v in state['T1'].items() if k in ['version_no','code','category','name','description','resources','activities']},'version_no':state['T1']['version_no']},method='PUT',expected=409)
record={'zone_id':top,'working_before':state['T1']['version_no'],'working_after':actual['version_no'],'public_version':actual['public_version_no'],'resources_equal':actual['resources']==state['T1']['resources'],'activities_equal':actual['activities']==state['T1']['activities'],'context_equal':view['zone_contexts']==state['zone_contexts'],'public_equal':True,'old_editor_source_sha256':json.loads((out/'REVERSAO-APLICADA-QA.json').read_text('utf-8'))['old_editor_sha256'],'served_editor_asset':entry,'served_editor_sha256':asset_hash,'normal_MFA_new_session_recovery':True,'actual_save':f"Browser old editor, description only; HTTP server revision {actual['version_no']} recovered",'retained_functional_sources':7}
(out/'PROVA-POS-USO-QA.json').write_text(json.dumps(record,ensure_ascii=False,indent=2)+'\n','utf-8')
print(json.dumps(record))