def testParseCssInfo(): testFile = "test/testData/formatting.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) # TODO this is clearly nonsense expectedText = [ '* Question with bold', '** one <span style="font-weight:700;"> Bold </span>one', '** <span style="font-weight:700;"> All bold </span>', '** One <span style="text-decoration:underline;"> Underlined </span>one', '** One <span style="font-weight:700;font-style:italic;"> Italics </span>one', '** One <span style="color:#ff0000;"> Red </span>one', '** One <span style="color:#0000ff;"> Blue </span>one', '** One <span style="color:#00ff00;"> Green </span>one', '** One <span style="color:#ff00ff;"> Pink </span>one', '** One <span style="vertical-align:super;"> superscript </span> one', '** One <span style="vertical-align:sub;"> subscript </span> one' ] # print(orgData.get("data")) data = orgData.get("data") dataLength = len(expectedText) i = 0 while True: if data[i] == expectedText[0]: break i += 1 # print((orgData.get("data")[i:dataLength+i])) assert (orgData.get("data")[i:dataLength + i] == expectedText)
def testUnicodeIsRespected(): testFile = "test/testData/imageInQuestionBug.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) assert (orgData.get("data")[1].strip() == "** Réponse 1")
def testCommentLineWithBulletPoint(): testFile = "test/testData/commentBulletPointLine.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) assert (orgData.get("data")[2] == "# type = Cloze")
def testParseNewGoogleDocToOrgFile(): testFile = "test/testData/testDeckNewFormat.html" with open(testFile, "r") as f: testFileData = f.read() expectedData = ['* Question', '** Reply'] orgPage = _generateOrgListFromHtmlPage(testFileData)["data"] assert (orgPage == expectedData)
def testParseImagesInGoogleDocs(): testFile = "test/testData/image_data.html" with open(testFile, "r") as f: testFileData = f.read() expectedData = ['* Picture example!', '** Before [image=https://lh6.googleusercontent.com/UqoTBxnML7twdpncSo8yjMSpD4hAHrxLy4qi0H8XUBUxzM22A48PmP3DhOlVgkJZ0e2tDGx6R_901NeRqQDry244HANqLAJl4dlFYihfTAdOmQ11Yd5tIszl5MtosTg7eMJPSLQI] after # height=95.70px, width=114.50px'] orgPage = _generateOrgListFromHtmlPage(testFileData)["data"] print(orgPage) assert(orgPage == expectedData)
def testParseGoogleDocToOrgFile(): testFile = "test/testData/remote_deck_test.html" with open(testFile, "r") as f: testFileData = f.read() expectedData = ['Test', '# Test', '* Level 1', '** Level 2', '*** Level 3', '**** Level 4', '* Level 1.1', '** Level 2.1'] orgPage = _generateOrgListFromHtmlPage(testFileData)["data"] assert(orgPage == expectedData)
def testImageParsing_multipleImagesPerAQuestion(): testFile = "test/testData/double.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) assert(orgData.get("data")[-2] == '** [image=image-2] # height=461.33px, width=624.00px') assert(orgData.get("data")[-1] == '** [image=image-3] # height=461.33px, width=624.00px')
def testImageParsing_bugWhereImageIsInsertedTwice(): testFile = "test/testData/double.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) # print(orgData.get("data")) assert(orgData.get("data") == ['* Question', '** <b> Text 1 </b>', '** [image=image-1] # height=215.04px, width=218.50px', '* Question 2', '** Text 2', '** [image=image-2] # height=461.33px, width=624.00px', '** [image=image-3] # height=461.33px, width=624.00px'])
def testEmptyBulletPoint(): #this will break the cloze otherwise testFile = "test/testData/formatting.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) # print(orgData.get("data")[-2:]) assert (orgData.get("data")[-2:] == ['* Empty Question', '** '])
def testMultiLineComment_noQuestionAfter(): testFile = "test/testData/multilineComments_noQuestionAfter.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) data = orgData.get("data") assert (len(data) == 2) for line in data: if "Question in multiline comments" in line: assert (False)
def testParseCssInfo(): testFile = "test/testData/formatting.html" with open(testFile, "r") as f: testFileData = f.read() orgData = _generateOrgListFromHtmlPage(testFileData) # TODO this is clearly nonsense expectedText = ['* Question with bold', '** one <span style="font-weight:700;"> Bold </span>one', '** <span style="font-weight:700;"> All bold </span>', '** One <span style="text-decoration:underline;"> Underlined </span>one', '** One <span style="font-weight:700;font-style:italic;"> Italics </span>one', '** One <span style="color:#ff0000;"> Red </span>one', '** One <span style="color:#0000ff;"> Blue </span>one', '** One <span style="color:#00ff00;"> Green </span>one', '** One <span style="color:#ff00ff;"> Pink </span>one'] # print(orgData.get("data")[-11:-2]) assert(orgData.get("data")[-11:-2] == expectedText)