3672b0fe73
* Only collect card stats on the backend ... ... instead of rendering an HTML string using askama. * Add ts page Card Info * Update test for new `col.card_stats()` * Remove obsolete CardStats code * Use new ts page in `CardInfoDialog` * Align start and end instead of left and right Curiously, `text-align: start` does not work for `th` tags if assigned via classes. * Adopt ts refactorings after rebase #1405 and #1409 * Clean up `ts/card-info/BUILD.bazel` * Port card info logic from Rust to TS * Move repeated field to the top https://github.com/ankitects/anki/pull/1414#discussion_r725402730 * Convert pseudo classes to interfaces * CardInfoPage -> CardInfo * Make revlog in card info optional * Add legacy support for old card stats * Check for undefined instead of falsy * Make Revlog separate component * drop askama dependency (dae) * Fix nightmode for legacy card stats
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
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 = CardStats()
|
|
card_stats.ParseFromString(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.ParseFromString(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
|