Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #322 from ZhengPeiRu21/fixDeckStatsTest
Browse files Browse the repository at this point in the history
Fix getDeckStats test
  • Loading branch information
FooSoft authored May 29, 2022
2 parents 23c25dd + 1d7bf69 commit 1d5b87b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,15 @@ def getNote(self, note_id: int) -> Note:
raise NotFoundError('Note was not found: {}'.format(note_id))

def deckStatsToJson(self, due_tree):
return {'deck_id': due_tree.deck_id,
'name': due_tree.name,
'new_count': due_tree.new_count,
'learn_count': due_tree.learn_count,
'review_count': due_tree.review_count,
'total_in_deck': due_tree.total_in_deck}
deckStats = {'deck_id': due_tree.deck_id,
'name': due_tree.name,
'new_count': due_tree.new_count,
'learn_count': due_tree.learn_count,
'review_count': due_tree.review_count}
if anki_version > (2, 1, 46):
# total_in_deck is not supported on lower Anki versions
deckStats['total_in_deck'] = due_tree.total_in_deck
return deckStats

def collectDeckTreeChildren(self, parent_node):
allNodes = {parent_node.deck_id: parent_node}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_decks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def test_removedDeckConfigId_fails_with_invalid_id(session_with_profile_loaded):

def test_getDeckStats(session_with_profile_loaded):
result = ac.getDeckStats(decks=["Default"])
assert result["name"] == "Default"
assert list(result.values())[0]["name"] == "Default"

0 comments on commit 1d5b87b

Please sign in to comment.