Files
Investidor-V2/outputs/investmoz-editorial-QA-20261018/test-prefill.py
T
nala cf003c8623
tests / ci (push) Canceled after 0s
versao nrgocios 4
2026-10-18 15:57:06 +02:00

15 lines
2.1 KiB
Python

from pathlib import Path
scope={'__file__':str(Path(__file__).parent/'test-QA.py')};exec((Path(__file__).parent/'test-QA.py').read_text('utf8').split('try:\n a=login')[0],scope);globals().update(scope)
try:
a=login('authorized');v=session();original={'format':'investmoz-legacy-article-v1','title':'Artigo legado sintético QA','content_html':'<p>Primeiro parágrafo preservado.</p><p>Segundo parágrafo preservado.</p>','source_url':'https://example.invalid/editorial-qa','author':'Entidade sintética QA','legacy_category':'QA','published_at':'2026-10-18T00:00:00Z','modified_at':'2026-10-18T00:00:00Z','legacy_id':999001}
d=upload(a,'artigo-legado-sintetico-qa.txt',json.dumps(original).encode(),'application/json')
subprocess.run(['C:/Users/macbook/.config/investmoz/php-8.5.11/php.exe',str(p/'source/artisan'),'queue:work','--stop-when-empty','--tries=1','--max-time=100'],check=True,capture_output=True)
r,data=resource(a,d,'Artigo legado sintético QA');id=r['id'];path='/management/portal-services/resources/'+str(id)+'/article'
prefill=props(a,path)['content'];ck('Corpo original estruturado recuperado no editor sem digitação técnica','Primeiro parágrafo preservado.' in prefill['body'] and 'Segundo parágrafo preservado.' in prefill['body'])
call(a,path,{'body':prefill['body']+'\n\nAdaptação sintética QA.','image_resource_id':None,'metadata_version':r['metadata_version']},method='PUT',expected=(302,303))
call(a,'/management/portal-services/resources/'+str(id),{'published':True},expected=(302,303));ck('Original não sobrescrito',hashlib.sha256(call(v,'/documentos/'+str(id)+'/download')).hexdigest()==d['sha256'])
call(v,'/sectores/sector-editorial-qa',expected=404);ck('Ligação direta de novo sector retirado não divulga rascunho',True)
except Exception as e:checks.append({'criterio':'Delta de recuperação','resultado':'falhou','evidencia':str(e)})
finally:
(o/'PROVAS-PREENCHIMENTO-QA.json').write_text(json.dumps({'checks':checks,'events':events,'active_changes':0},ensure_ascii=False,indent=2),'utf8');print(json.dumps({'checks':len(checks),'failed':[c for c in checks if c['resultado']=='falhou']},ensure_ascii=True))