From 4f8053b1654c3202ccc3c86a99304c38bbaa530b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 12 Apr 2012 00:34:40 +0900 Subject: [PATCH] make sure to export deck creation date on apkg export --- anki/exporting.py | 1 + tests/test_exporting.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/anki/exporting.py b/anki/exporting.py index 99346b5c6..3f43fc5e8 100644 --- a/anki/exporting.py +++ b/anki/exporting.py @@ -193,6 +193,7 @@ class AnkiExporter(Exporter): for file in self.src.media.filesInStr(mid, flds): media[file] = True self.mediaFiles = media.keys() + self.dst.crt = self.src.crt # todo: tags? self.count = self.dst.cardCount() self.dst.setMod() diff --git a/tests/test_exporting.py b/tests/test_exporting.py index 9bc0c6dce..0c5062d64 100644 --- a/tests/test_exporting.py +++ b/tests/test_exporting.py @@ -4,6 +4,7 @@ import nose, os, tempfile import anki from anki import Collection as aopen from anki.exporting import * +from anki.importing import Anki2Importer from anki.stdmodels import * from shared import getEmptyDeck @@ -54,6 +55,36 @@ def test_export_ankipkg(): os.unlink(newname) e.exportInto(newname) +@nose.with_setup(setup1) +def test_export_anki_due(): + deck = getEmptyDeck() + f = deck.newNote() + f['Front'] = u"foo" + deck.addNote(f) + deck.crt -= 86400*10 + deck.sched.reset() + c = deck.sched.getCard() + deck.sched.answerCard(c, 2) + deck.sched.answerCard(c, 2) + # should have ivl of 1, due on day 11 + assert c.ivl == 1 + assert c.due == 11 + assert deck.sched.today == 10 + assert c.due - deck.sched.today == 1 + # export + e = AnkiExporter(deck) + e.includeSched = True + newname = unicode(tempfile.mkstemp(prefix="ankitest", suffix=".anki2")[1]) + os.unlink(newname) + e.exportInto(newname) + # importing into a new deck, the due date should be equivalent + deck2 = getEmptyDeck() + imp = Anki2Importer(deck2, newname) + imp.run() + c = deck2.getCard(c.id) + deck2.sched.reset() + assert c.due - deck2.sched.today == 1 + # @nose.with_setup(setup1) # def test_export_textcard(): # e = TextCardExporter(deck)