Exemplo n.º 1
0
def testCardWithImageUrl_CommandLineMode():

    data = ["* Question", "** Image below", "** [image=https://lh3.googleusercontent.com/gdEMfGtrSRTvbTiXwysYJ_5XxqieWt0Z9vtFw0jQxOlbjo43_PJYa4kCusZjmkbe_euwGa4KAWEo2xJvEzHkwIpVN3H-XvCxVXCpQNOcH9_tERcVodYf75t18hYlargfKgYtHYvM]"]
    actualDeck = parseData._buildDeck(data, "test.org")

    # print(len(actualDeck.getQuestions()[0].getMedia()[0].data))
    assert(len(actualDeck.getQuestions()[0].getMedia()[0].data) == 68035)
Exemplo n.º 2
0
def testSectionLevelClozeCardsAreIgnored():

    data = ['# cardType=Cloze', '#type=Cloze', '* Question 1', '** Answer 1']
    actualDeck = parseData._buildDeck(data, "test.org")

    assert (actualDeck.getQuestions()[0].getParameter("cardType") == None)
    assert (actualDeck.getQuestions()[0].getParameter("type") == None)
Exemplo n.º 3
0
def testParsingExtraFieldLinesWithMultipleFields():

    data = [
        "* Question", "** Answer", "#fieldName=Front hint, x=y",
        "** front hint", "#fieldName=Back hint", "** back hint"
    ]

    deck = parseData._buildDeck(data, "test.org")

    assert (len(deck.getQuestions()) == 1)

    assert (deck.getQuestions()[0].getQuestions() == ["Question"])
    assert (deck.getQuestions()[0].getAnswers() == ["Answer"])

    namedFields = deck.getQuestions()[0].getNamedFields()

    assert (len(namedFields))
    # No guarantee of ordering
    if namedFields[0].getFieldName() == "Front hint":
        a, b = 0, 1
    else:
        a, b = 1, 0

    assert (namedFields[a].getFieldName() == "Front hint")
    assert (namedFields[a].getLines() == ["front hint"])
    assert (namedFields[b].getFieldName() == "Back hint")
    assert (namedFields[b].getLines() == ["back hint"])
Exemplo n.º 4
0
def testSectionAreConvertedIntoDecksIndependnatlyForOrganisedFile():

    data = ['# fileType=organisedFile ', '* Planning', '  # type = notes', '** Time planner', '* L1 Intro', '** What are the 3 main motivations for malware?', '*** money', '*** hacktivism', '*** nation state', '** What is an APT?', '*** Advanced persistent threat']
    actualDeck = parseData._buildDeck(data, "test.org")

    assert(len(actualDeck.getQuestions()[0].getQuestions()) == 1)
    assert(actualDeck.getQuestions()[0].getQuestions()[0] == "What are the 3 main motivations for malware?")
    assert(actualDeck.getQuestions()[0]._parameters == {'fileType': 'organisedFile'})
Exemplo n.º 5
0
def testParsingExtraFieldLinesForMultipleQuestions():

    data = ["* Qusetion 1", "** Answer 1", "#fieldName=Front", "** front hint","* Question 2", "** Answer 2"]

    deck = parseData._buildDeck(data, "test.org")

    assert(len(deck.getQuestions()) == 2)
    assert(len(deck.getQuestions()[1].getNamedFields()) == 0)
Exemplo n.º 6
0
def testEmptyLinesAreIgnored():

    data = ["* ", "** ", "* order list", "** Answer"]

    deck = parseData._buildDeck(data, "test.org")

    assert (len(deck.getQuestions()) == 1)
    assert (deck.getQuestions()[0].getQuestions() == ["order list"])
    assert (deck.getQuestions()[0].getAnswers() == ["Answer"])
Exemplo n.º 7
0
def testCardWithImageUrl_CommandLineMode_imageInQuestion_bug():

    data = ["* Question [image=https://lh3.googleusercontent.com/gdEMfGtrSRTvbTiXwysYJ_5XxqieWt0Z9vtFw0jQxOlbjo43_PJYa4kCusZjmkbe_euwGa4KAWEo2xJvEzHkwIpVN3H-XvCxVXCpQNOcH9_tERcVodYf75t18hYlargfKgYtHYvM]", "** Answer"]
    actualDeck = parseData._buildDeck(data, "test.org")

    # Assert that the url is not used
    # hash of url is used instead
    assert(actualDeck.getQuestions()[0].getQuestions()[0] == 'Question <img src="downloaded_image_8c9773be01c71c9b07bcad50cd83dd1b" />')
    assert(len(actualDeck.getQuestions()[0].getMedia()[0].data) == 68035)
Exemplo n.º 8
0
def testStrangeOrgData():

    data = ["* Planner [0/0]", "** Planner [/]", "#type=notes","** Something",":LOGBOOK:","CLOCK: [2019-04-19 Fri 14:27]--[2019-04-19 Fri 14:27] =>  0:00", ":END:","* order list","** Answer"]

    deck = parseData._buildDeck(data, "test.org")

    assert(len(deck.getQuestions()) == 1)
    assert(deck.getQuestions()[0].getQuestions() == ["order list"])
    assert(deck.getQuestions()[0].getAnswers() == ["Answer"])
Exemplo n.º 9
0
def testOrgFormattingIsParsedWithoutError():

    data = [
        '* Planning', '  # type = notes', '** Time planner', '   :LOGBOOK:',
        '   CLOCK: [2019-04-15 Mon 12:52]--[2019-04-15 Mon 13:17] =>  0:25',
        '   :END:', '**  Sections', '     1. [X] l1', '     13. [ ] l10?'
    ]
    deck = parseData._buildDeck(data, "test.org")

    assert (deck)
Exemplo n.º 10
0
def testUrlIsNotUsedForName():

    data = [
        "* Question [image=https://lh3.googleusercontent.com/gdEMfGtrSRTvbTiXwysYJ_5XxqieWt0Z9vtFw0jQxOlbjo43_PJYa4kCusZjmkbe_euwGa4KAWEo2xJvEzHkwIpVN3H-XvCxVXCpQNOcH9_tERcVodYf75t18hYlargfKgYtHYvM]",
        "** Answer"
    ]
    actualDeck = parseData._buildDeck(data, "test.org")

    assert (
        actualDeck.getQuestions()[0].getMedia()[0].fileName !=
        "https://lh3.googleusercontent.com/gdEMfGtrSRTvbTiXwysYJ_5XxqieWt0Z9vtFw0jQxOlbjo43_PJYa4kCusZjmkbe_euwGa4KAWEo2xJvEzHkwIpVN3H-XvCxVXCpQNOcH9_tERcVodYf75t18hYlargfKgYtHYvM"
    )
Exemplo n.º 11
0
def testCardsWithTagsData():

    data = ['* Question 1', '# tags=a,b,c', '** Answer 1']
    actualDeck = parseData._buildDeck(data, "test.org")

    assert (actualDeck.getQuestions()[0].getTags() == ['a', 'b', 'c'])