make sure to export deck creation date on apkg export

This commit is contained in:
Damien Elmes 2012-04-12 00:34:40 +09:00
parent 875a417346
commit 4f8053b165
2 changed files with 32 additions and 0 deletions

View file

@ -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()

View file

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