def setUp(self): ch = categoryHinter( os.path.join('config', 'test-categories.conf') ) bl = [type1Line( ' x 2007', ch )] bl.append( type1Line('', ch) ) bl.append( type1Line('', ch) ) bl.append( type1Line('', ch) ) bl.append( type1Line('x 1. dues 10000', ch) ) self.assumption = assumptionsList( bl )[0] self.assumption_spec = assumptionSpec() self.engine = penaltyEngine( self.assumption, self.assumption_spec )
def testGetAllAssumptions(self): bl = [type1Line( '1 2 3', ch )] ga = testGA( bl ) ga.combination_limit = 100 ga.ambig_config_sets = ga.get_ambig_config( bl ) ga.generate_assumptions( bl ) self.assertEqual(ga, [[12, 3], [1, 23], [123]] )
def testSequenceNumber(self): bl = [type1Line( '1 2 3', ch )] ga = testGA( bl ) ga.biglist = bl ga.combination_limit = 100 aconf = ga.get_ambig_config( bl ) assumption = ga.get_assumption( bl, aconf[0] ) self.assertEqual(assumption[1].sequence(), 1 )
def testCondense(self): bl = [type1Line( '1 blah 2 blah 3 blah 4 blah 5', ch )] assumptions = assumptionsList( bl ) spec = assumptionSpec() spec.mark_cruft(1) spec.mark_total(2) spec.mark_grand_total(3) self.assertEqual( assumptions[0].condense( spec ), [1, 3, 4] )
def testGetAssumption(self): bl = [type1Line( '1 2 3', ch )] ga = testGA( bl ) ga.biglist = bl ga.combination_limit = 100 aconf = ga.get_ambig_config( bl ) assumption = ga.get_assumption( bl, aconf[0] ) self.assertEqual(assumption, [12, 3] )
def testComplexAmbigConfig(self): bl = [type1Line( '1 2 3 blash 1 2 3', ch )] ga = testGA( bl ) ga.combination_limit = 100 aconf = ga.get_ambig_config( bl ) # # This is a modest illustration of how the volume of possibilities # can quickly explode out of control when commas are dropped from # a document. self.assertEqual(aconf, [[1, 1], [2, 1], [3, 1], [3, 2], [2, 2], [1, 2], [1, 3], [2, 3], [3, 3]] )
def testType1ThreeItemsToTwo(self): t = type1Line('911 9 999', self.chint) self.assertEqual( t.ints(), [[9999, 911]])
def testType1ThreeItemsBrokenButMergeable(self): # # Would probably be a bad scan, but no point in aborting t = type1Line('999 8 11', self.chint) self.assertEqual( t.ints(), [[11, 8, 999]])
def testType(self): t = type1Line('911 9 99', self.chint) u = t[0:2] self.assertTrue( isinstance(u, type1Line) )
def testUnmergeableBreakPoint(self): t = type1Line('666 000 1 999 999 999 999 999', self.chint) self.assertEqual( t.ints(), [[1999999999999999, 666000]])
def testSimpleSum(self): bl = [type1Line( 'project 100 blah 100 blah 200', self.ch )] self.pt = testPT( bl ) self.assertEqual( None, None)
def testComplexLine(self): l = type1Line('Ordinary members 1,000 x 50 members 40,000 50,000 △10,000'.decode('utf8'), self.chint) self.assertEqual( l.ints(), [[1000], [50], [-10000, 50000, 40000]])
def testSimplePair(self): t = type1Line('111 88', self.chint) self.assertEqual( t.ints(), [[88, 111]])
def testType1TwoItems(self): t = type1Line('999 888', self.chint) self.assertEqual( t.ints(), [[999888]])
def testType1SimpleOne(self): t = type1Line('999', self.chint) self.assertEqual( t.ints(), [[999]])
def setUp(self): self.bl = [type1Line( '1 2 3', ch )] self.ga = testGA( self.bl ) self.ga.combination_limit = 100
def testAssumptionLength(self): bl = [type1Line( '1 blah 2 blah 3', ch )] assumptions = assumptionsList( bl ) spec = assumptionSpec() spec.mark_cruft(1) self.assertEqual( assumptions[0].length( spec ), 2)
def testEmpty1(self): t = type1Line('', self.chint) self.assertEqual( t, [])
def testAmbigInfo(self): bl = [type1Line( '1 2 3', ch )] ga = testGA( bl ) ainfo = ga.get_ambig_info( bl ) self.assertEqual(ainfo, [4] )
def testAmbiguityFixWithSimplePair(self): t = type1Line('111 88', self.chint) self.assertFalse( t[0][1].is_ambiguous)
def testMergeFailure(self): t = type1Line('111 111 2 222 9 999', self.chint) self.assertEqual( t.ints(), [[9999, 222, 2, 111, 111]])
def testEmbeddedNegative(self): t = type1Line('999△888'.decode('utf8'), self.chint) self.assertEqual( t.ints(), [[-888, 999]])
def setUp(self): self.ch = testCH() self.ch.read( os.path.join('config', 'test-categories.conf') ) bl = [type1Line( 'project 100 blah 100 blah 200', self.ch )] self.assumptions = assumptionsList( bl, 'type1' ) self.assumption = self.assumptions[0]