Commit Graph

92 Commits

Author SHA1 Message Date
Austin Siew
accbc53e5d added modelTemplateRename, modelTemplateReposition, modelTemplateAdd, modelTemplateRemove 2023-04-13 19:30:49 -06:00
Austin Siew
ed508babbf merged with master 2023-03-31 00:54:32 -06:00
Ren Tatsumoto
8d16822cb5 add a test for getMediaDirPath() 2023-03-23 06:06:44 +03:00
introt
2f50c747fb Add getNoteTags, updateNoteTags and updateNote
getNoteTags returns [str ...] of tags for a given note (note: int)

updateNoteTags removes the existing tags and sets new tags

updateNote combines the old updateNoteFields and the new updateNoteTags

Closes #369
2022-12-30 13:13:31 +02:00
Austin Siew
a96e10e840 made the test more precise by checking the anki version 2022-12-28 18:54:22 -07:00
Austin Siew
69baea296a added tests & documentation, removed dead code 2022-12-28 18:37:05 -07:00
introt
336dc8bb31 Added modelFieldDescriptions
Similar to modelFieldNames, returns a list of
note field decriptions (the text seen in the gui
editor when the field is empty)
2022-11-26 14:56:34 +02:00
Austin Siew
a8905a4c22 getReviewsOfCards: changed inner lists into dictionaries, removed cid within the inner list 2022-09-20 17:46:26 -06:00
Austin Siew
c0c922d27c changed getReviewsOfCard -> getReviewsOfCards, changed result to be formatted in a dictionary rather than a list 2022-09-13 17:12:20 -06:00
Austin Siew
6e4bbfa0d6 Added getReviewsOfCard 2022-09-05 00:29:03 -06:00
Austin Siew
83cc55769b fixed function styling issue in test case 2022-08-16 20:11:44 -06:00
Austin Siew
8ec078393a removed the bulk action in favor of the already existing 'multi' action 2022-08-16 19:35:32 -06:00
Austin Siew
ebdca1db6b Added model field name api points and skeleton documentation to README 2022-08-16 19:23:09 -06:00
Alexei Yatskov
99d6256ade
Merge pull request #324 from toasted-nutbread/api-reflect
apiReflect
2022-05-29 12:58:38 -07:00
Alexei Yatskov
1d5b87b3f4
Merge pull request #322 from ZhengPeiRu21/fixDeckStatsTest
Fix getDeckStats test
2022-05-29 12:57:18 -07:00
Alexei Yatskov
23c25dd7ae
Merge pull request #319 from oakkitten/fix-bad-json-error
Produce a better error in case of malformed JSON
2022-05-29 12:56:51 -07:00
郑佩茹
1d7bf6969a Correct line endings 2022-05-23 11:37:18 -06:00
toasted-nutbread
e842dc78e0 Add test 2022-05-20 17:19:29 -04:00
郑佩茹
b55ac78f84 Fix getDeckStats test 2022-05-16 13:36:02 -06:00
oakkitten
9c3310a8b6 Don't crash if JSON is valid but of wrong schema 2022-05-11 20:32:09 +01:00
oakkitten
bffbb051f2 Produce a better error in case of malformed JSON
$ curl localhost:8777 -X POST -i -d '{"action": "version", "version": 6},' && echo ␄
HTTP/1.1 200 OK
Content-Type: text/json
Access-Control-Allow-Origin: http://localhost
Access-Control-Allow-Headers: *
Content-Length: 67

{"result": null, "error": "Extra data: line 1 column 36 (char 35)"}␄

$ curl localhost:8777 -X POST -i -d '{"action": "version", "version": 6},' -H "Origin: foo" && echo ␄
HTTP/1.1 403 Forbidden
Access-Control-Allow-Origin: http://localhost
Access-Control-Allow-Headers: *

␄
2022-05-11 20:32:08 +01:00
郑佩茹
137554f522 Add getDeckStats action 2022-05-03 15:59:33 -06:00
oakkitten
700c6ae218 Explicitly require Anki >= 2.1.45
Consolidate Anki version checks across files
2022-04-26 15:22:06 +01:00
oakkitten
056e722187 Edit dialog: fix editor buttons on Anki 2.1.50
Also add a few tests for the buttons to make sure
that they get actually added and enabled/disabled.
2022-04-26 15:22:06 +01:00
oakkitten
901d92b067 Tests: make tests pass for Anki 2.1.50 (Qt6)
* Import things from `aqt.qt` not `PyQt5`/`PyQt6`
* When testing with Qt6, disable Anki's Qt5 compatibility mode
* Depend on `pytest-anki` that is also Qt version agnostic
2022-04-26 15:22:06 +01:00
oakkitten
e025a44ea3 Tests: make tests pass for Anki 2.1.50 (Qt5)
* require Python 3.10
* prevent Anki from doing backups, again
* restore cwd that deck exporter changes for some wild reason
2022-04-26 15:22:06 +01:00
oakkitten
6643dca83e Tests: patch waitress to reduce test flakiness
Waitress is a WSGI server that Anki starts to serve css etc to
its web views. It seems to have a race condition issue;
the main loop thread is trying to `select.select` the sockets
which a worker thread is closing because of a dead connection.

This makes waitress skip actually closing the sockets.
2022-04-14 01:55:41 +01:00
oakkitten
c688895c0e Edit dialog: make browser button show all history
Before, pressing the Browse button would only show browser
with the cards or notes corresponding to the currently edited note.

Now, it shows all cards or notes from the dialog history,
in reverse order (last seen on top),
with the currently edited note or its cards selected.
2022-04-14 01:55:41 +01:00
oakkitten
849ab43be7 Tests: simplify profile removal
It turns out that `pytest-anki` does what we are trying to do already.

Note that `empty_anki_session_started` creates a temporary user too.
We are “overwriting“ it in `profile_created_and_loaded`
by calling `temporary_user`. It seems that doing this is safe.
2022-04-11 02:28:25 +01:00
oakkitten
c53aa86a0d Ignore option closeAfterAdding of guiAddCards
The functionality was broken, creating a dialog that was not,
in fact, closing after adding a card.

See the deleted comment in `test_graphical.py`
2022-04-11 02:28:25 +01:00
oakkitten
fb892d330a Add tests for the Edit dialog 2022-04-11 02:28:03 +01:00
oakkitten
8f1a2cc5fd Convert all tests to pytest
Previously, tests were run against Anki launched by user.

Now,
 * most tests run against isolated Anki in current process;
 * tests in `test_server.py` launch another Anki in a separate process
   and run a few commands to test the server;
 * nearly all tests were preserved in the sense that
   what was being tested is tested still.
   A few tests in `test_graphical.py` are skipped due to
   a problem with the method tests, see the comments;
 * tests can be run:
   * In a single profile, using --no-tear-down-profile-after-each-test;
   * In a single app instance, but with the profile being torn down
     after each test--default;
   * In separate processes, using --forked.
2022-04-11 02:26:44 +01:00
penginsan
064fbef413
Add guiSelectedNotes action (#292) 2021-12-06 08:59:10 -08:00
NSBum
8404bd782d
Added guiCheckDatabase action and fix #202 in saveDeckConfig (#271)
* Added guiCheckDatabase action

This action initiates a check database action in Anki but doesn’t wait for the action to complete before returning.

* Fixed #202 no dconf attribute in saveDeckConfig

Anki manages access to deck configuration differently now. This adapts saveDeckConfig to new style of access.
2021-07-13 17:55:22 -07:00
Jason Won
591ac06aa3
allow guiAddCards to add media (#266)
* add media to editing note

* update readme
2021-06-20 20:35:09 -07:00
abdo
f8ff7c0c38
storeMediaFile: Add option to keep file with the same name (#257) 2021-05-22 12:21:12 -07:00
Konstantin Sukovatij
929716c7b1
Added "getMediaFilesNames" action (#247) 2021-04-11 21:26:03 -07:00
Quentin Harscoët
27a8678f88
added getNumCardsReviewedByDay action (#239)
* added getNumCardsReviewedByDay action

* added sample in statistics.md

* fix bad quotes and add basic test
2021-03-06 09:58:40 -08:00
Kirill Salnikov
b8a7151ed0
Fix handling of errors in several methods (#238)
* Fix error message in updateNoteFields method

* Fix error handling in cardsInfo, notesInfo methods

* Add more tests for updateNoteFields, notesInfo

* Fix error handling in several methods

Also fixed obvious bugs in replaceTags and replaceTagsInAllNotes
methods.

* Add more tests for cards methods

* Add more tests for notes methods

* Update documentation on cards methods
2021-03-04 20:06:25 -08:00
Tsung-Po Sun(Munehiro)
a4d723de3e
Add "forgetCards" and "relearnCards" (#234)
* Add "forgetCards" and "relearnCards"

* Add unit tests

Co-authored-by: Tsung-Po Sun <tsungpo.sun@smartnews.com>
2021-03-04 20:02:57 -08:00
Venkata Ramana
131a1c7cfc
Added findAndReplaceInModels (#228)
* added findAndReplaceInModels api call

* added documentation for findAndReplaceInModels

* added findAndReplaceInModels api call

* updatd findAndReplaceInModels function

* added unit test for findAndReplaceInModels in models

* updated findAndReplaceInModels

* added unit test for findAndReplaceInModels

* removed 'all_models' in findAndReplaceInModels
2021-02-26 21:17:51 -08:00
a8273d0e38 Fix tests 2021-01-18 21:03:27 -08:00
Julian Müller
ce0cc7dce3
some additional actions (#185)
* implement needed actions

* add documentation and tests for cardInfo, updateCompleteDeck, reloadCollection, cardReviews, getLatestReviewID, insertReviews

Co-authored-by: Julian Müller <julian.mueller@stud-mail.uni-wuerzburg.de>
2020-07-12 12:53:31 -07:00
Spencer Sharp
84586cb352
Created getEaseFactors and setEaseFactors for Cards, along with documentation and tests for the functions (#181)
Co-authored-by: sherpa <spencersharp1999@gmail.com>
2020-06-10 16:21:58 -07:00
Scott Noyes
80d830caed
Do not strip() during dupe check (#171) 2020-05-08 17:16:05 -07:00
Scott Noyes
faba701251
Collection stats (#166)
* Add endpoint to retrieve collection stats report

* Create separate test for statistics

* Add test for collectionStats

* Fixed typo

* Change endpoint name to use a verb

* Change name to getCollectionStatsHTML
2020-05-03 12:06:43 -07:00
Alex Yatskov
a779fa673f
Merge pull request #159 from snoyes/getProfiles
Add getProfiles action
2020-05-01 12:44:25 -07:00
Scott Noyes
204268b031 Add unit test for importPackage 2020-05-01 13:55:30 -05:00
Scott Noyes
6723332224 Add unit test for getProfiles and loadProfile 2020-05-01 13:38:23 -05:00
0f8b402d73 Update move export to misc, fix return 2020-04-21 18:22:10 -07:00