Beispiel #1
0
 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 )
Beispiel #2
0
 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]] )
Beispiel #3
0
 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 )
Beispiel #4
0
 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] )
Beispiel #5
0
 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] )
Beispiel #6
0
 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]] )
Beispiel #7
0
 def testType1ThreeItemsToTwo(self):
     t = type1Line('911 9 999', self.chint)
     self.assertEqual( t.ints(), [[9999, 911]])
Beispiel #8
0
 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]])
Beispiel #9
0
 def testType(self):
     t = type1Line('911 9 99', self.chint)
     u = t[0:2]
     self.assertTrue( isinstance(u, type1Line) )
Beispiel #10
0
 def testUnmergeableBreakPoint(self):
     t = type1Line('666 000 1 999 999 999 999 999', self.chint)
     self.assertEqual( t.ints(), [[1999999999999999, 666000]])
Beispiel #11
0
 def testSimpleSum(self):
     bl = [type1Line( 'project 100 blah 100 blah 200', self.ch )]
     self.pt = testPT( bl )
     self.assertEqual( None, None)
Beispiel #12
0
 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]])
Beispiel #13
0
 def testSimplePair(self):
     t = type1Line('111 88', self.chint)
     self.assertEqual( t.ints(), [[88, 111]])
Beispiel #14
0
 def testType1TwoItems(self):
     t = type1Line('999 888', self.chint)
     self.assertEqual( t.ints(), [[999888]])
Beispiel #15
0
 def testType1SimpleOne(self):
     t = type1Line('999', self.chint)
     self.assertEqual( t.ints(), [[999]])
Beispiel #16
0
 def setUp(self):
     self.bl = [type1Line( '1 2 3', ch )]
     self.ga = testGA( self.bl )
     self.ga.combination_limit = 100
Beispiel #17
0
 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)
Beispiel #18
0
 def testEmpty1(self):
     t = type1Line('', self.chint)
     self.assertEqual( t, [])
Beispiel #19
0
 def testAmbigInfo(self):
     bl = [type1Line( '1 2 3', ch )]
     ga = testGA( bl )
     ainfo = ga.get_ambig_info( bl )
     self.assertEqual(ainfo, [4] )
Beispiel #20
0
 def testAmbiguityFixWithSimplePair(self):
     t = type1Line('111 88', self.chint)
     self.assertFalse( t[0][1].is_ambiguous)
Beispiel #21
0
 def testMergeFailure(self):
     t = type1Line('111 111 2 222 9 999', self.chint)
     self.assertEqual( t.ints(), [[9999, 222, 2, 111, 111]])
Beispiel #22
0
 def testEmbeddedNegative(self):
     t = type1Line('999△888'.decode('utf8'), self.chint)
     self.assertEqual( t.ints(), [[-888, 999]])
Beispiel #23
0
 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]