Verify real CBB BOM imports and handle first-open native database updates
This commit is contained in:
1 parent
a332e7bd59
commit
1b39d802bd
9 files changed
+504
-9
No files matched your search
@@ -80,6 +80,22 @@ def test_unknown_project_rejected_before_any_collection_or_save(batch, tmp_path)
|
||||
assert not calls and all(not store.list_target_plan(task.task_id) for task in tasks)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('empty_inventory', [True, False])
|
||||
def test_matching_failure_identifies_the_project_and_keeps_all_plans_empty(batch, tmp_path, empty_inventory):
|
||||
service, store, tasks, targets, calls = batch
|
||||
records = list(records_for(tasks, targets))
|
||||
if empty_inventory:
|
||||
service.for_project_task(tasks[0].task_id)._quick_run_preparer.collect_inventory = lambda *a: ()
|
||||
else:
|
||||
records[0]['refdes'] = 'R9'
|
||||
path = write_bom_template(tmp_path / 'unmatched.xlsx', records)
|
||||
with pytest.raises(TaskCenterError) as caught:
|
||||
service.preview_bom_batch(tasks[0].task_id, path)
|
||||
assert tasks[0].name in caught.value.message
|
||||
assert str(targets[tasks[0].task_id][0].project_path) in caught.value.message
|
||||
assert all(not store.list_target_plan(task.task_id) for task in tasks)
|
||||
|
||||
|
||||
def test_missing_project_is_ambiguous_for_batch_and_never_guessed(batch, tmp_path):
|
||||
service, store, tasks, targets, calls = batch
|
||||
path = write_bom_template(tmp_path / 'missing-project.xlsx',
|
||||
|
||||
@@ -372,6 +372,23 @@ def test_native_database_runtime_updates_reject_different_inventories(tmp_path):
|
||||
preparer.collect_inventory(project, ('old',))
|
||||
|
||||
|
||||
def test_first_open_normalization_then_runtime_updates_need_two_equal_reads(tmp_path):
|
||||
project, preparer, calls = prepared(tmp_path)
|
||||
database = project.parent / 'database' / 'icdb.dat'
|
||||
database.parent.mkdir()
|
||||
database.write_text('initial database')
|
||||
original = preparer._discover_project_sheets
|
||||
def discover(*args, **kwargs):
|
||||
result = original(*args, **kwargs)
|
||||
if len(calls) == 1:
|
||||
project.write_text('normalized project')
|
||||
database.write_text('native session metadata ' + str(len(calls)))
|
||||
return result
|
||||
preparer._discover_project_sheets = discover
|
||||
assert preparer.collect_inventory(project, ('old',))[0].refdes == 'R1'
|
||||
assert len(calls) == 3
|
||||
|
||||
|
||||
def test_unverifiable_retry_after_known_churn_still_fails_closed(tmp_path, monkeypatch):
|
||||
from dx_productivity.trial_task_center import discovery_cache as module
|
||||
project, preparer, calls = prepared(tmp_path)
|
||||
|
||||
Reference in new issue
Block a user