anki/pylib/tests
Damien Elmes 6b0fe4b381 undoable ops now return changes directly; add new *_ops.py files
- Introduced a new transact() method that wraps the return value
in a separate struct that describes the changes that were made.
- Changes are now gathered from the undo log, so we don't need to
guess at what was changed - eg if update_note() is called with identical
note contents, no changes are returned. Card changes will only be set
if cards were actually generated by the update_note() call, and tag
will only be set if a new tag was added.
- mw.perform_op() has been updated to expect the op to return the changes,
or a structure with the changes in it, and it will use them to fire the
change hook, instead of fetching the changes from undo_status(), so there
is no risk of race conditions.
- the various calls to mw.perform_op() have been split into separate
files like card_ops.py. Aside from making the code cleaner, this works
around a rather annoying issue with mypy. Because we run it with
no_strict_optional, mypy is happy to accept an operation that returns None,
despite the type signature saying it requires changes to be returned.
Turning no_strict_optional on for the whole codebase is not practical
at the moment, but we can enable it for individual files.

Still todo:
- The cursor keeps moving back to the start of a field when typing -
we need to ignore the refresh hook when we are the initiator.
- The busy cursor icon should probably be delayed a few hundreds ms.
- Still need to think about a nicer way of handling saveNow()
- op_made_changes(), op_affects_study_queue() might be better embedded
as properties in the object instead
2021-03-19 19:45:21 +10:00
..
support tweaking the folder names again 2020-01-03 07:48:38 +10:00
__init__.py tweaking the folder names again 2020-01-03 07:48:38 +10:00
run_format.py Update mypy and black format check to python version 3.8 2020-11-11 09:24:28 +00:00
run_mypy.py initial Bazel conversion 2020-11-01 14:26:58 +10:00
run_pylint.py initial Bazel conversion 2020-11-01 14:26:58 +10:00
run_pytest.py implement fuzzing 2021-02-22 21:31:53 +10:00
shared.py fix errorsAfterMidnight 2020-04-08 10:05:19 +10:00
test_cards.py make backend instance on col private 2021-01-31 18:56:16 +10:00
test_collection.py Simplify note adding and the deck/notetype choosers 2021-03-10 11:53:27 +10:00
test_decks.py move drag/drop deck logic to backend 2021-01-31 13:46:31 +10:00
test_exporting.py rework v2 scheduler upgrade; drop downgrade 2021-02-21 15:50:41 +10:00
test_find.py undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
test_flags.py make flag changes in the reviewer undoable 2021-03-10 11:53:27 +10:00
test_importing.py make mark toggling undoable 2021-03-10 11:53:27 +10:00
test_latex.py remove print statement from unit tests 2020-11-18 13:56:44 +10:00
test_media.py Merge pull request #793 from nwwt/object-audio-tags-support 2020-11-11 10:33:31 +10:00
test_models.py make mark toggling undoable 2021-03-10 11:53:27 +10:00
test_sched2021.py use different approach to running tests twice 2021-03-01 12:47:39 +10:00
test_schedv1.py make flag changes in the reviewer undoable 2021-03-10 11:53:27 +10:00
test_schedv2.py split out common scheduler code into base.py, use scheduler/ dir 2021-03-12 14:07:52 +10:00
test_stats.py d->col in tests 2020-07-17 06:58:32 +02:00
test_template.py d->col in tests 2020-07-17 06:58:32 +02:00
test_undo.py commit immediately when there's no active checkpoint 2021-03-10 11:47:53 +10:00