def test_anki2_diffmodels(): # create a new empty deck dst = getEmptyCol() # import the 1 card version of the model tmp = getUpgradeDeckPath("diffmodels2-1.apkg") imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() before = dst.noteCount() # repeating the process should do nothing imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() assert before == dst.noteCount() # then the 2 card version tmp = getUpgradeDeckPath("diffmodels2-2.apkg") imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() after = dst.noteCount() # as the model schemas differ, should have been imported as new model assert after == before + 1 # and the new model should have both cards assert dst.cardCount() == 3 # repeating the process should do nothing imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() after = dst.noteCount() assert after == before + 1 assert dst.cardCount() == 3
def test_anki2_diffmodel_templates(): # different from the above as this one tests only the template text being # changed, not the number of cards/fields dst = getEmptyCol() # import the first version of the model tmp = getUpgradeDeckPath("diffmodeltemplates-1.apkg") imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() # then the version with updated template tmp = getUpgradeDeckPath("diffmodeltemplates-2.apkg") imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() # collection should contain the note we imported assert dst.noteCount() == 1 # the front template should contain the text added in the 2nd package tcid = dst.findCards("")[0] # only 1 note in collection tnote = dst.getCard(tcid).note() assert "Changed Front Template" in tnote.cards()[0].template()["qfmt"]
def test_anki2_diffmodel_templates(): # different from the above as this one tests only the template text being # changed, not the number of cards/fields dst = getEmptyCol() # import the first version of the model tmp = getUpgradeDeckPath("diffmodeltemplates-1.apkg") imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() # then the version with updated template tmp = getUpgradeDeckPath("diffmodeltemplates-2.apkg") imp = AnkiPackageImporter(dst, tmp) imp.dupeOnSchemaChange = True imp.run() # collection should contain the note we imported assert(dst.noteCount() == 1) # the front template should contain the text added in the 2nd package tcid = dst.findCards("")[0] # only 1 note in collection tnote = dst.getCard(tcid).note() assert("Changed Front Template" in dst.findTemplates(tnote)[0]['qfmt'])