def shouldPutMessageInCellForUnprintableAttributeInSurplusRow(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>Huh</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "c1": "Larry", "Huh": "Moe", "c3": "Curly" }, { "c1": "Larry", "Huh": u"\u00a1", "c3": "Curly" } ] coll[0].Huh = "Blind" coll[1].Huh = "says to" metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) ## em("\n%s" % table.toNodeList()) cell = table.parts.more.more.more.more.more.parts.more ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert cell.body.find("[error extracting value]") > -1 assert fix.counts == Counts(8, 2, 0, 1)
def shouldMarkIncorrectSymbolReferenceAsWrong(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3=</td></tr>" "<tr><td>Three</td><td>Blind</td><td>a</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>b</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>c</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "c1": "Larry", "c2": "Moe", "c3": "Curly" } ] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("a", "Mice") fix.setSymbol("b", "Duck") fix.setSymbol("c", "Laurel") fix.doTable(table) ## label1 = table.parts.more.parts ## em("\n%s" % table.toNodeList()) ## cell = table.parts.more.more.more.more.parts.more.more ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert fix.counts == Counts(8, 1)
def shouldUnmatchedRow(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), {"c1": "Larry", "c2": "Moe", "c3": "Curly"}] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) assert fix.counts.right == 6
def shouldHandleUndefinedAttributeInCollectionElement(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"missing": "Larry", "c2": "Moe", "c3": "Curly"}] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) assert fix.counts == Counts(6, 3)
def shouldHandleMissingSymbolInPartitionStep(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1=</td><td>c2</td><td>c3</td></tr>" "<tr><td>a</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>b</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>c</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"c1": "Larry", "c2": "Moe", "c3": "Curly"}] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("b", "Lord") fix.setSymbol("c", "Larry") fix.doTable(table) assert fix.counts == Counts(6, 1, 2, 1)
def shouldHandleSymbolicReferencesInFirstColumn(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1=</td><td>c2</td><td>c3</td></tr>" "<tr><td>a</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>b</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>c</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"c1": "Larry", "c2": "Moe", "c3": "Curly"}] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("a", "Three") fix.setSymbol("b", "Lord") fix.setSymbol("c", "Larry") fix.doTable(table) assert fix.counts.right == 9
def shouldHandleSymbolicReferencesInLastColumn(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3=</td></tr>" "<tr><td>Three</td><td>Blind</td><td>a</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>b</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>c</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"c1": "Larry", "c2": "Moe", "c3": "Curly"}] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("a", "Mice") fix.setSymbol("b", "Duck") fix.setSymbol("c", "Curly") fix.doTable(table) # label1 = table.parts.more.parts assert fix.counts == Counts(9)
def shouldUnmatchedRow(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), { "c1": "Larry", "c2": "Moe", "c3": "Curly" } ] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) assert fix.counts.right == 6
def shouldHandleUndefinedColumnWithStringMismatch(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>Huh</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"c1": "Larry", "Huh": "Moe", "c3": "Curly"}] coll[0].Huh = "Blind" coll[1].Huh = "says to" metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) ## em("\n%s" % table.toNodeList()) ## cell = table.parts.more.parts.more ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert fix.counts == Counts(8, 1, 0, 1)
def shouldMarkShortRowAsMissingWithException(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"c1": "Larry", "c2": "Moe", "c3": "Curly"}] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) ## em("\n%s" % table.toNodeList()) ## label1 = table.parts.more.parts ## em("tag: %s body: %s" % (label1.tag, label1.body)) ## cell = table.parts.more.more.more.parts ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert fix.counts == Counts(6, 1, 0, 1)
def shouldHandleUndefinedAttributeInCollectionElement(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "missing": "Larry", "c2": "Moe", "c3": "Curly" } ] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) assert fix.counts == Counts(6, 3)
def shouldHandleMissingSymbolInPartitionStep(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1=</td><td>c2</td><td>c3</td></tr>" "<tr><td>a</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>b</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>c</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "c1": "Larry", "c2": "Moe", "c3": "Curly" } ] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("b", "Lord") fix.setSymbol("c", "Larry") fix.doTable(table) assert fix.counts == Counts(6, 1, 2, 1)
def shouldPutMessageInCellForUnprintableAttributeInSurplusRow(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>Huh</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"c1": "Larry", "Huh": "Moe", "c3": "Curly"}, {"c1": "Larry", "Huh": u"\u00a1", "c3": "Curly"}] coll[0].Huh = "Blind" coll[1].Huh = "says to" metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) ## em("\n%s" % table.toNodeList()) cell = table.parts.more.more.more.more.more.parts.more ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert cell.body.find("[error extracting value]") > -1 assert fix.counts == Counts(8, 2, 0, 1)
def shouldMarkIncorrectSymbolReferenceAsWrong(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3=</td></tr>" "<tr><td>Three</td><td>Blind</td><td>a</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>b</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>c</td></tr>" "</table>") coll = [ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), {"c1": "Larry", "c2": "Moe", "c3": "Curly"}] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("a", "Mice") fix.setSymbol("b", "Duck") fix.setSymbol("c", "Laurel") fix.doTable(table) ## label1 = table.parts.more.parts ## em("\n%s" % table.toNodeList()) ## cell = table.parts.more.more.more.more.parts.more.more ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert fix.counts == Counts(8, 1)
def shouldHandleSymbolicReferencesInFirstColumn(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1=</td><td>c2</td><td>c3</td></tr>" "<tr><td>a</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>b</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>c</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "c1": "Larry", "c2": "Moe", "c3": "Curly" } ] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("a", "Three") fix.setSymbol("b", "Lord") fix.setSymbol("c", "Larry") fix.doTable(table) assert fix.counts.right == 9
def shouldHandleSymbolicReferencesInLastColumn(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3=</td></tr>" "<tr><td>Three</td><td>Blind</td><td>a</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>b</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>c</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "c1": "Larry", "c2": "Moe", "c3": "Curly" } ] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.setSymbol("a", "Mice") fix.setSymbol("b", "Duck") fix.setSymbol("c", "Curly") fix.doTable(table) # label1 = table.parts.more.parts assert fix.counts == Counts(9)
def shouldMarkShortRowAsMissingWithException(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>c2</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "c1": "Larry", "c2": "Moe", "c3": "Curly" } ] metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) ## em("\n%s" % table.toNodeList()) ## label1 = table.parts.more.parts ## em("tag: %s body: %s" % (label1.tag, label1.body)) ## cell = table.parts.more.more.more.parts ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert fix.counts == Counts(6, 1, 0, 1)
def shouldHandleUndefinedColumnWithStringMismatch(self): table = Parse("<table><tr><td>fit.RowFixture</td></tr>" "<tr><td>c1</td><td>Huh</td><td>c3</td></tr>" "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>" "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>" "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>" "</table>") coll = [ ProcObj("Three", "Blind", "Mice"), ProcObj("Lord", "Lova", "Duck"), { "c1": "Larry", "Huh": "Moe", "c3": "Curly" } ] coll[0].Huh = "Blind" coll[1].Huh = "says to" metaData = {"c1": "String", "c2": "String", "c3": "String"} fix = RowFixture(coll, metaData) fix.doTable(table) ## em("\n%s" % table.toNodeList()) ## cell = table.parts.more.parts.more ## em("tag: %s body: %s" % (cell.tag, cell.body)) assert fix.counts == Counts(8, 1, 0, 1)