feat(shipping-notice): 收敛订单处理状态与履约门禁
This commit is contained in:
1 parent
bffcd55b40
commit
70dd0051b8
153 files changed
+10916
-4296
No files matched your search
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
backend/tests/test_shipping_processing_projection.py
|
||||
|
||||
???????? processing ?????OT ??????PDF ???????
|
||||
???Flask/SQLite?create_order_extraction_run?project_conversation_processing?
|
||||
????? queued / frozen-failed / completed???? PDF ????????hash ?????
|
||||
processing OT PDF
|
||||
Flask/SQLite?create_order_extraction_run?project_conversation_processing?
|
||||
queued / frozen-failed / completed PDF hash
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -29,11 +29,11 @@ from tests.test_shipping_order_extraction_runs import _seed_run_input
|
||||
|
||||
def _ensure_run_order_task(*, run, intake, document) -> None:
|
||||
"""
|
||||
????????? Candidate + OT???? Run.user_task_no?
|
||||
Candidate + OT Run.user_task_no?
|
||||
|
||||
??????? test_shipping_conversation_processing_api ???
|
||||
Candidate ? Run ???? OT ????? order_task ??
|
||||
????? OT ???????
|
||||
test_shipping_conversation_processing_api
|
||||
Candidate ? Run OT order_task
|
||||
OT
|
||||
"""
|
||||
candidate = ShippingOrderCandidate.query.filter_by(
|
||||
order_extraction_run_id=int(run.id),
|
||||
@@ -63,7 +63,7 @@ def _ensure_run_order_task(*, run, intake, document) -> None:
|
||||
|
||||
|
||||
def test_project_conversation_processing_groups_and_dedupes_user_tasks(app):
|
||||
"""???? Run ?????????? OT ??????"""
|
||||
""" Run OT """
|
||||
with app.app_context():
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='PROJ-A')
|
||||
run_processing, _ = create_order_extraction_run(
|
||||
@@ -135,10 +135,10 @@ def test_project_conversation_processing_groups_and_dedupes_user_tasks(app):
|
||||
completed_nos = {row['user_task_no'] for row in projection.get('completed') or []}
|
||||
assert run_processing.user_task_no in processing_nos
|
||||
assert run_failed.user_task_no in needs_nos
|
||||
# ???? completed ????????? completed ???
|
||||
# completed completed
|
||||
assert run_done.user_task_no in completed_nos
|
||||
|
||||
# ????????? OT ??????
|
||||
# OT
|
||||
all_nos = list(processing_nos | needs_nos | completed_nos)
|
||||
assert len(all_nos) == len(set(all_nos)) == 3
|
||||
|
||||
@@ -150,7 +150,7 @@ def test_project_conversation_processing_groups_and_dedupes_user_tasks(app):
|
||||
assert 'view_details' in (failed_task.get('available_actions') or [])
|
||||
primary = failed_task.get('primary_action')
|
||||
assert primary
|
||||
# ???cancel / view_details ???? CTA?BE-01??
|
||||
# cancel / view_details CTA?BE-01
|
||||
assert primary not in {'cancel_task', 'cancel_run', 'view_details'}
|
||||
|
||||
done_task = next(
|
||||
@@ -244,7 +244,7 @@ def test_same_attachment_fingerprint_across_ots_keeps_two_cards(app):
|
||||
|
||||
|
||||
def test_completed_current_run_hidden_after_viewed(app):
|
||||
"""UI-04??? completed ?????????"""
|
||||
"""UI-04 completed """
|
||||
with app.app_context():
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='PROJ-DONE')
|
||||
run, _ = create_order_extraction_run(
|
||||
@@ -273,14 +273,14 @@ def test_completed_current_run_hidden_after_viewed(app):
|
||||
)
|
||||
shown = after['processing'] + after['needs_action'] + list(after.get('completed') or [])
|
||||
assert all(row['user_task_no'] != run.user_task_no for row in shown)
|
||||
# ?????? completed ?? history?????????
|
||||
# completed history
|
||||
history_nos = {row['user_task_no'] for row in (after.get('history') or [])}
|
||||
assert run.user_task_no in history_nos
|
||||
assert after['summary']['history'] >= 1
|
||||
|
||||
|
||||
def _set_run_documents(run, documents: list[dict]) -> None:
|
||||
"""?? Run ?? documents????????PDF ?????"""
|
||||
""" Run documentsPDF """
|
||||
snapshot = dict(run.input_snapshot_json or {})
|
||||
intakes = list(snapshot.get('intakes') or [])
|
||||
if not intakes:
|
||||
@@ -293,7 +293,7 @@ def _set_run_documents(run, documents: list[dict]) -> None:
|
||||
|
||||
|
||||
def test_single_pdf_task_title_is_none_for_frontend_unified_label(app):
|
||||
"""BE-05?? PDF ?? title ?? None?????? document_names / objects?"""
|
||||
"""BE-05 PDF title None document_names / objects?"""
|
||||
with app.app_context():
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='PROJ-1PDF')
|
||||
run, _ = create_order_extraction_run(
|
||||
@@ -321,7 +321,7 @@ def test_single_pdf_task_title_is_none_for_frontend_unified_label(app):
|
||||
row for row in projection['processing'] + projection['needs_action']
|
||||
if row['user_task_no'] == run.user_task_no
|
||||
)
|
||||
# ???????????????????????????? title?
|
||||
# title?
|
||||
assert task['title'] is None
|
||||
assert task['file_count'] == 1
|
||||
assert task['display_kind'] == 'single_document_task'
|
||||
@@ -332,7 +332,7 @@ def test_single_pdf_task_title_is_none_for_frontend_unified_label(app):
|
||||
|
||||
|
||||
def test_multi_pdf_task_does_not_use_first_filename_as_title(app):
|
||||
"""? PDF ???title ???file_count=2?objects ????? PDF?"""
|
||||
"""? PDF title file_count=2?objects PDF?"""
|
||||
with app.app_context():
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='PROJ-2PDF')
|
||||
run, _ = create_order_extraction_run(
|
||||
@@ -485,7 +485,7 @@ def test_partial_reparse_keeps_unaffected_pdf_from_source_run(app):
|
||||
|
||||
|
||||
def test_same_filename_different_hash_counts_as_two_pdfs(app):
|
||||
"""???? hash?file_count=2???????????"""
|
||||
""" hash?file_count=2"""
|
||||
with app.app_context():
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='PROJ-SAME-NAME')
|
||||
run, _ = create_order_extraction_run(
|
||||
@@ -525,7 +525,7 @@ def test_same_filename_different_hash_counts_as_two_pdfs(app):
|
||||
|
||||
|
||||
def test_same_hash_different_document_id_counts_as_one_pdf(app):
|
||||
"""? hash ?? document_id?????file_count=1?"""
|
||||
"""? hash document_idfile_count=1?"""
|
||||
with app.app_context():
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='PROJ-SAME-HASH')
|
||||
run, _ = create_order_extraction_run(
|
||||
@@ -564,7 +564,7 @@ def test_same_hash_different_document_id_counts_as_one_pdf(app):
|
||||
)
|
||||
assert task['file_count'] == 1
|
||||
assert task['display_kind'] == 'single_document_task'
|
||||
# BE-05: title ?? None?? hash ???????????
|
||||
# BE-05: title None hash
|
||||
assert task['title'] is None
|
||||
doc_objects = [obj for obj in (task.get('objects') or []) if obj.get('kind') == 'document']
|
||||
assert len(doc_objects) == 1
|
||||
@@ -572,7 +572,7 @@ def test_same_hash_different_document_id_counts_as_one_pdf(app):
|
||||
|
||||
|
||||
def test_sparse_snapshot_enriched_by_extraction_units(app):
|
||||
"""??? 1 PDF ? Unit ?? 2 ?????? multi + file_count=2?"""
|
||||
""" 1 PDF ? Unit 2 multi + file_count=2?"""
|
||||
from app.models import (
|
||||
FileAsset,
|
||||
ShippingOrderDocument,
|
||||
@@ -619,7 +619,7 @@ def test_sparse_snapshot_enriched_by_extraction_units(app):
|
||||
keep_input_open=True,
|
||||
)
|
||||
_ensure_run_order_task(run=run, intake=intake, document=document)
|
||||
# ???? 1 ???????????????????????
|
||||
# 1
|
||||
_set_run_documents(run, [{
|
||||
'document_id': int(document.id),
|
||||
'root_document_id': int(document.id),
|
||||
@@ -660,7 +660,7 @@ def test_sparse_snapshot_enriched_by_extraction_units(app):
|
||||
|
||||
@pytest.mark.skip(reason='workflow ledger removed')
|
||||
def test_sparse_snapshot_enriched_by_workflow_items(app):
|
||||
"""??? 1 PDF ?? Run ?? 2 ? WorkflowItem ????? multi?"""
|
||||
""" 1 PDF Run 2 ? WorkflowItem multi?"""
|
||||
with app.app_context():
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='PROJ-SPARSE-W')
|
||||
from app.models import FileAsset, ShippingOrderDocument
|
||||
|
||||
Reference in new issue
Block a user