From 2ad03ddbc0703026c863d10e14dacd8477c1f4de Mon Sep 17 00:00:00 2001 From: Austin Siew <17107540+Aquafina-water-bottle@users.noreply.github.com> Date: Fri, 30 Dec 2022 20:26:58 -0700 Subject: [PATCH] added anki 2.1.54 and 2.1.55 tests & fixed NotFoundError not working on 2.1.55 --- plugin/__init__.py | 9 +++++++-- tox.ini | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/__init__.py b/plugin/__init__.py index 38851c5..589e1d4 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -350,17 +350,22 @@ class AnkiConnect: # Not a duplicate return 0 + def raiseNotfoundError(self, errorMsg): + if anki_version < (2, 1, 55): + raise NotFoundError(errorMsg) + raise NotFoundError(errorMsg, None, None, None) + def getCard(self, card_id: int) -> Card: try: return self.collection().getCard(card_id) except NotFoundError: - raise NotFoundError('Card was not found: {}'.format(card_id)) + self.raiseNotfoundError('Card was not found: {}'.format(card_id)) def getNote(self, note_id: int) -> Note: try: return self.collection().getNote(note_id) except NotFoundError: - raise NotFoundError('Note was not found: {}'.format(note_id)) + self.raiseNotfoundError('Note was not found: {}'.format(note_id)) def deckStatsToJson(self, due_tree): deckStats = {'deck_id': due_tree.deck_id, diff --git a/tox.ini b/tox.ini index 699b662..ab14f7c 100644 --- a/tox.ini +++ b/tox.ini @@ -54,7 +54,7 @@ requires = pypi-timemachine envlist = py38-anki2.1.{45,46,47,48,49} - py39-anki2.1.{50,51,52,53}-qt{5,6} + py39-anki2.1.{50,51,52,53,54,55}-qt{5,6} [testenv:.tox] install_command =