anki/pylib/tests/test_stats.py
Henrik Giesel a8d4774cdb
Add _raw methods for all methods in the backend (#1594)
* Add _bytes methods for all methods in the backend

Expose get_note in qt/aqt/mediasrv.py

* Satisfy formatter

* Rename _bytes function to _raw and have them bytes as input

* Fix backend generation

* Use lib/proto/deckOptions in deck-options

* Add exposed_backend to qt/aqt/mediasrv.py

* Move some more backend methods to exposed_backend_list

* Use protobufjs for congrats and i18n

* Use protobufjs for completeTag

* Use protobufjs services in change-notetype

* Reorder post handlers in alphabetical manner

* Satisfy tests

* Remove unused collection methods

* Rename access_backend to raw_backend_request

* Use _vendor.stringcase instead of creating a new function

* Remove SKIP_UNROLL_OUTPUT

* Directly call _run_command in non _raw methods

* Remove TranslateString, ChangeNotetype and CompleteTag from SKIP_UNROLL_INPUT

* Remove UpdateDeckConfigs from SKIP_UNROLL_INPUT

* Remove ChangeNotetype from SKIP_UNROLL_INPUT

* Remove SKIP_UNROLL_INPUT

* Fix typing issue with translate_string

- Adds typing support for Protobuf maps in genbackend.py

* Do not emit convenience method for protobuf TranslateString
2022-01-21 21:32:39 +10:00

41 lines
974 B
Python

# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import tempfile
from anki.collection import CardStats
from tests.shared import getEmptyCol
def test_stats():
col = getEmptyCol()
note = col.newNote()
note["Front"] = "foo"
col.addNote(note)
c = note.cards()[0]
# card stats
card_stats = col.card_stats_data(c.id)
assert card_stats.note_id == note.id
col.reset()
c = col.sched.getCard()
col.sched.answerCard(c, 3)
col.sched.answerCard(c, 2)
card_stats = col.card_stats_data(c.id)
assert len(card_stats.revlog) == 2
def test_graphs_empty():
col = getEmptyCol()
assert col.stats().report()
def test_graphs():
dir = tempfile.gettempdir()
col = getEmptyCol()
g = col.stats()
rep = g.report()
with open(os.path.join(dir, "test.html"), "w", encoding="UTF-8") as note:
note.write(rep)
return