test_keynote_locks
Hosted unit tests for releasing Keynote Manager locks.
Run from Revit via the DevTools "Run All Tests" button, which discovers every
test_* module in this package. The tests pin the contract of the Release
Locks button in keynotesdb: a crashed session's record lock is released,
locks held by the current window are never offered, and a write sidecar is
only deleted while it is still the stale one the user agreed to release.
Breaking any of these lets two writes overlap and lose keynote changes.
Attributes
KEYNOTES_BUNDLE_DIR = op.join(EXTENSIONS_DEFAULT_DIR, 'pyRevitTools.extension', 'pyRevit.tab', 'Drawing Set.panel', 'Keynotes.pushbutton')
module-attribute
CRASHED_USER = 'crashed-user'
module-attribute
kdb = _load_keynotesdb()
module-attribute
Classes
StaleWriteLockTests
Bases: _KeynoteFileTestCase
Releasing the sidecar DeffrelDB holds while it writes the file.
Methods:
test_sidecar_is_named_without_the_file_extension()
DeffrelDB guards Keynotes.txt with Keynotes.lock.
test_save_in_progress_is_not_stale()
A sidecar younger than the threshold belongs to a live save.
test_missing_sidecar_is_not_stale()
No sidecar means there is nothing to release.
test_unchanged_stale_sidecar_is_released()
The stale sidecar the user confirmed is deleted, with no leftovers.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
test_sidecar_replaced_during_confirmation_is_kept()
A live save's new sidecar survives a release confirmed on the old one.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
test_live_sidecar_is_put_back_after_being_claimed()
A sidecar that is no longer stale is restored, not deleted.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
test_sidecar_cleared_elsewhere_reports_nothing_released()
A sidecar someone else already removed is not an error.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
setUp()
Create an empty keynote file in a new scratch folder.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
RecordLockReleaseTests
Bases: _KeynoteFileTestCase
Releasing lock rows a crashed session left in the keynote file.
Methods:
setUp()
Open a crashed session holding A.01 and a live window connection.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
tearDown()
Close both connections before the scratch folder goes.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
test_crashed_session_lock_is_offered()
The crashed session's lock is the one Release Locks lists.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
test_crashed_session_lock_is_released()
After release the record can be locked and saved again.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
test_window_locks_are_never_offered()
Locks held by the window's own connections are left alone.
Source code in pyrevitlib/pyrevit/unittests/test_keynote_locks.py
test_window_commit_does_not_bring_a_released_lock_back()
A window that was mid-edit during the release does not restore it.