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 testExtractListParmOfLengthThree(self): fuList = ["snafu", "spam", "fubar"] obj = RowFixture(fuList, {}) obj.setActualCollection() assert obj.paramCollection == fuList assert obj.actuals == fuList assert id(obj.actuals) != id(fuList) assert obj.paramTypeDict == {}
def testExtractDictParm(self): fuDict = {1: "snafu", 3: "fubar"} fuList = ["snafu", "fubar"] obj = RowFixture(fuDict, {}) obj.setActualCollection() assert obj.paramCollection == fuDict assert obj.actuals == fuList assert obj.paramTypeDict == {}
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 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 shouldPostExceptionInParameterCellIfSymbolMissing(self): fix = RowFixture() unused = CollSymbol( [AnObject(1), AnObject(2), AnObject(3)], AnObject._typeDict) FitGlobal.testLevelSymbols = {} table = Parse( "<table><tr><td>fit.RowFixture</td><td>aCollection</td></tr>" "<tr><td>output</td></tr>" "<tr><td>1</td></tr>" "<tr><td>2</td></tr>" "<tr><td>3</td></tr></table>") fix.doTables(table) parmCell = table.parts.parts.more assert parmCell.tagIsError() assert table.parts.more.more.more.more.more is None
def shouldPostExceptionInParameterCellIfSymbolMissing(self): fix = RowFixture() unused = CollSymbol([AnObject(1), AnObject(2), AnObject(3)], AnObject._typeDict) FitGlobal.testLevelSymbols = {} table = Parse( "<table><tr><td>fit.RowFixture</td><td>aCollection</td></tr>" "<tr><td>output</td></tr>" "<tr><td>1</td></tr>" "<tr><td>2</td></tr>" "<tr><td>3</td></tr></table>") fix.doTables(table) parmCell = table.parts.parts.more assert parmCell.tagIsError() assert table.parts.more.more.more.more.more is None
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 testMissingLabelRow(self): obj = RowFixture(["fuString"], {}) table = Parse("<table><tr><td>fit.RowFixture</td></tr></table>") self._doTable(obj, table) headCell = table.parts.parts assert headCell.tagIsError() assert headCell.body.find("Row containing column") > -1 assert self.exceptionWasPropagated
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 shouldHandleCollectionFromSymbol(self): fix = RowFixture() coll = CollSymbol([AnObject(1), AnObject(2), AnObject(3)], AnObject._typeDict) fix.setSymbol("aCollection", coll) table = Parse( "<table><tr><td>fit.RowFixture</td><td>aCollection</td></tr>" "<tr><td>output</td></tr>" "<tr><td>1</td></tr>" "<tr><td>2</td></tr>" "<tr><td>3</td></tr></table>") fix.doTables(table) row1 = table.parts.more.more.parts row2 = table.parts.more.more.more.parts row3 = table.parts.more.more.more.more.parts assert row1.tagIsRight() assert row2.tagIsRight() assert row3.tagIsRight() assert table.parts.more.more.more.more.more is None
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 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 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 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 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 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 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 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 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 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 shouldHandleCollectionFromSymbol(self): fix = RowFixture() coll = CollSymbol( [AnObject(1), AnObject(2), AnObject(3)], AnObject._typeDict) fix.setSymbol("aCollection", coll) table = Parse( "<table><tr><td>fit.RowFixture</td><td>aCollection</td></tr>" "<tr><td>output</td></tr>" "<tr><td>1</td></tr>" "<tr><td>2</td></tr>" "<tr><td>3</td></tr></table>") fix.doTables(table) row1 = table.parts.more.more.parts row2 = table.parts.more.more.more.parts row3 = table.parts.more.more.more.more.parts assert row1.tagIsRight() assert row2.tagIsRight() assert row3.tagIsRight() assert table.parts.more.more.more.more.more is None
def testErrorIfNotDictOrSequenceOrIterator(self): obj = RowFixture(3.14, {}) self.assertRaises(FitException, obj.setActualCollection)
def testExtractUnsupportedParm(self): fuString = "Snafu" obj = RowFixture(fuString, {}) self.assertRaises(FitException, obj.setActualCollection)