@Suppress
public void testCsv() throws IOException {
Collection deck = Shared.getEmptyCol(getContext());
String file = Shared.getTestFilePath(getContext(), "text-2fields.txt");
TextImporter i = new TextImporter(deck, file);
i.initMapping();
i.run();
// four problems - too many & too few fields, a missing front, and a
// duplicate entry
assertTrue(i.getLog().size() == 5);
assertTrue(i.getTotal() == 5);
// if we run the import again, it should update instead
i.run();
assertTrue(i.getLog().size() == 10);
assertTrue(i.getTotal() == 5);
// but importing should not clobber tags if they're unmapped
Note n = deck.getNote(deck.getDb().queryLongScalar("select id from notes"));
n.addTag("test");
n.flush();
i.run();
n.load();
assertTrue((n.getTags().size() == 1) && (n.getTags().get(0) == "test"));
// if add-only mode, count will be 0
i.setImportMode(1);
i.run();
assertTrue(i.getTotal() == 0);
// and if dupes mode, will reimport everything
assertTrue(deck.cardCount() == 5);
i.setImportMode(2);
i.run();
// includes repeated field
assertTrue(i.getTotal() == 6);
assertTrue(deck.cardCount() == 11);
deck.close();
}
ImportTest.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:Anki-Android
作者:
评论列表
文章目录