def testCreationOfNamedNoteFieldWithinAnkiQuestion(): a = AnkiQuestion("question") a.addAnswer("answer") a.addNoteField("testField") a.addLineToNamedField("testField", "data") namedFields = a.getNamedFields() namedFields = a.getNamedFields() n = NamedNoteField("testField") n.addLine("data") assert (namedFields[0] == n)
def testBuildingMultiFieldNotes(): q = AnkiQuestion("Question") q.addAnswer("Answer") q.addLineToNamedField("field1", "Value 1") q.addLineToNamedField("field1", "Value 2") deck = AnkiDeck("Capitals") deck.addQuestion(q) a = AnkiNoteBuilder() noteData = a.buildNote(deck.getQuestions()[0]) expectedString = "<ul style='list-style-position: inside;'><li>Value 1</li><li>Value 2</li></ul>" assert (noteData.get("fields").get("field1", None) != None) assert (noteData.get("fields").get("field1") == expectedString)
def testMultipleNamedNoteField(): a = AnkiQuestion("question") a.addAnswer("answer") a.addLineToNamedField("testField", "data") a.addLineToNamedField("testField1", "data1") namedFields = a.getNamedFields() # No guarantee of ordering if namedFields[0].getFieldName() == "testField": a, b = 0, 1 else: a, b = 1, 0 assert (namedFields[a].getFieldName() == "testField") assert (namedFields[a].getLines() == ["data"]) assert (namedFields[b].getFieldName() == "testField1") assert (namedFields[b].getLines() == ["data1"])