예제 #1
0
 def test_deleteColumn(self):
     path = os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'docs/deleteColumn.odt' ) )
     outFile = os.path.join( os.path.dirname( __file__ ), 'docs/deleteColumn.out.odt' )
     pmm = pyMailMerge( path ) 
     
     xml = """<tokens>
         <token>
             <name>deletecolumn|wanted</name>
             <value>0</value>
         </token>
         <token>
             <name>deletecolumn|unwanted</name>
             <value>1</value>
         </token>
         <token>
             <name>deletecolumn|another</name>
             <value>0</value>
         </token>
     </tokens>"""
     
     x = pyMailMerge._readParamsFromXML( xml )
     pmm._process( x )
     pmm.document.refresh()
     pmm.document.saveAs( outFile )
     
     results = self._getFirstTableData( outFile )
     
     expected = [[ 'First', "Third" ],
                 [ 'A', 'C' ],
                 [ 'D', 'F' ] ]
     
     self.assertEqual( expected, results )
예제 #2
0
 def test_deleteRow(self):
     path = os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'docs/deleteRow.odt' ) )
     outFile = os.path.join( os.path.dirname( __file__ ), 'docs/deleteRow.out.odt' )
     pmm = pyMailMerge( path ) 
     
     xml = """<tokens>
         <token>
             <name>deleterow|wanted</name>
             <value>0</value>
         </token>
         <token>
             <name>deleterow|unwanted</name>
             <value>1</value>
         </token>
         <token>
             <name>deleterow|another</name>
             <value>0</value>
         </token>
     </tokens>"""
     
     x = pyMailMerge._readParamsFromXML( xml )
     pmm._process( x )
     pmm.document.refresh()
     pmm.document.saveAs( outFile )
     
     results = self._getFirstTableData( outFile )
     
     expected = [[ 'Wanted Row', '', "Send value '0' to keep" ],
                 [ 'Another Wanted', '', "Send value '0' to keep"] ]
     
     self.assertEqual( expected, results )
예제 #3
0
    def test_repeatrow_and_repeatcolumn(self):
        path = os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'docs/repeat_row_and_column.odt' ) )
        outFile = os.path.join( os.path.dirname( __file__ ), 'docs/repeat_row_and_column.out.odt' )
        pmm = pyMailMerge( path )
        
        f = open( os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'fixtures/repeatrow_and_repeatcolumn.xml' ) ) )

        x = pyMailMerge._readParamsFromXML( f.read() )
        pmm._process( x )
        pmm.document.refresh()
        pmm.document.saveAs( outFile )
        
        tableData = self._getFirstTableData( outFile )
        
        expectedOutcome = [ [ 'Name', 'name', 'life_benefit', 'life', 'add', 'dep_life', 
                            'crit_illness', 'eap', 'wi_benefit', 'wi', 'ltd_benefit', 'ltd',
                            'ehb', 'dental', 'total', "Total" ],
                           [u'Test User', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'Test User 2', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' '],
                           [u'Another User', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ', u' ']
                          ]
        
        self.assertEquals( expectedOutcome, tableData )
예제 #4
0
    def test_repeatrow_test_for_ted(self):
        path = os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'docs/repeatrow_test_for_ted.odt' ) )
        outFile = os.path.join( os.path.dirname( __file__ ), 'docs/repeatrow_test_for_ted.out.odt' )
        pmm = pyMailMerge( path )
        
        f = open( os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'fixtures/repeatrow_test_for_ted.xml' ) ) )

        x = pyMailMerge._readParamsFromXML( f.read() )
        pmm._process( x )
        pmm.document.refresh()
        pmm.document.saveAs( outFile )
        
        tableData = self._getFirstTableData( outFile )
        
        expectedOutcome = [ [ 'Benefit', 'Assurance', 'Financial'], 
                            [ 'Life Benefit', ' - ', ' - '],
                            [ 'Officers', '10000', '10000' ],
                            [ 'Owners/Officers/Managers', '10000', '10000' ],
                            [ 'Dental Benefit', ' - ', ' - ' ], 
                            [ 'Employees', '10000', '10000' ], 
                            [ 'Officers', '10000', '10000' ],
                            [ 'Health Benefit', ' - ', ' - ' ],
                            [ 'Officers', '10000', '10000' ],
                            [ 'LTD Benefit', ' - ', ' - ' ],
                            [ 'Officers', '10000', '10000' ],
                            [ 'Weekly Income Benefit', ' - ', ' - ' ],
                            [ 'Officers', '10000', '10000' ]
                          ]
        
        self.assertEquals( expectedOutcome, tableData )
        self.assertEquals( 13, len( tableData ) )
예제 #5
0
 def test_readParamsFromXML(self):
     x = pyMailMerge._readParamsFromXML( self.xml )
     self.assertEquals( 'fake::token', x[0]['token'] )
     self.assertEquals( 'value1', x[0]['value'] )
     self.assertEquals( 'fake::array', x[1]['token'] )
     self.assertEquals( 'first', x[1]['value'][0] )
     self.assertEquals( 'second', x[1]['value'][1] )
     self.assertEquals( 'token::fake', x[2]['token'] )
     self.assertEquals( 'value2', x[2]['value'] )
 def test_updateChart(self):
     path = os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'docs/charttest.odt' ) )
     outFile = os.path.join( os.path.dirname( __file__ ), 'docs/charttest.out.pdf' )
     pmm = pyMailMerge( path ) 
     
     xml = """<tokens>
         <token>
             <name>repeatrow|timeperiod</name>
             <value>Year - 2009</value>
             <value>Year - 2010</value>
             <value>Year - 2011</value>
             <value>Year - 2012</value>
         </token>
         <token>
             <name>premium</name>
             <value>$505</value>
             <value>$1500</value>
             <value>$1000</value>
             <value>$1000</value>
         </token>
         <token>
             <name>paidclaims</name>
             <value>$200</value>
             <value>$2000</value>
             <value>$50</value>
             <value>$3000</value>
         </token>
         <token>
             <name>lossratio</name>
             <value>34%</value>
             <value>33%</value>
             <value>35%</value>
             <value>35%</value>
         </token>
     </tokens>"""
     
     x = pyMailMerge._readParamsFromXML( xml )
     pmm._process( x )
     pmm.document.refresh()
     pmm.document.saveAs( outFile )
     
     self.assertTrue( True )
예제 #7
0
 def test_calculatorXML(self):
     fixture = f = open( os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'fixtures/calculator.xml' ) ) )
     params = pyMailMerge._readParamsFromXML( fixture.read() )
     
     self.assertEqual( [ { 'token':'title', 'value':'Calculator' } ], params )