Merge pull request #322 from ZhengPeiRu21/fixDeckStatsTest

Fix getDeckStats test
This commit is contained in:
Alexei Yatskov 2022-05-29 12:57:18 -07:00 committed by GitHub
commit 1d5b87b3f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -345,12 +345,15 @@ class AnkiConnect:
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}

View File

@ -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"