Skip to content

Without this refresh, the next line fails due to expecting to delete osd<->facility configurations

Daniel Lyons requested to merge fix-context-cleanup-for-osds into main

Some changes on main are not deterministically passing the tests. They fail if there are facility configurations on OSDs. The error is:

FAILED allocate/domain_layer/services/test/test_serialize_proposal_summary_to_csv.py::test_serialize_proposal_summary_to_csv_good - 
sqlalchemy.orm.exc.StaleDataError: DELETE statement on table 'observation_specification_disposition_facility_configurations' 
expected to delete 2 row(s); Only ...

However, the stack trace shows this:

testdata/application_layer/services/src/context.py:560: in cleanup
    self.cleanup_proposal(p)
testdata/application_layer/services/src/context.py:612: in cleanup_proposal
    self.repo.proposal_copy_repo.delete(copy)

Examining the code, I see that self.repo.session.refresh(ar) is needed before a delete on the previous line. So I copy that line here and it solves the problem.

The proposal generated in this test can be passed a seed value; I tried values 1-6 and 3,4,5 generated OSD<->facility configuration rows while the others did not. But the tests pass after this change.

Merge request reports

Loading