Пример #1
0
    def test_params( self ):
        act = FileAction()
        self.assertEqual( len( act.getParams() ), 0 )

        act.setParams( dict( {"k1": "v1", "k2": "v2" } ) )
        self.assertEqual( len( act.getParams() ), 2 )
        self.assertTrue( "k1" in act.getParams() )
        self.assertTrue( "k2" in act.getParams() )
        self.assertTrue( "forkert" not in act.getParams() )
Пример #2
0
    def test_exchangeParams( self ):
        act = FileAction()
        self.assertEqual( act.exchangeParams( "" ), "" )
        self.assertEqual( act.exchangeParams( "mit navn" ), "mit navn" )
        self.assertEqual( act.exchangeParams( "PREFIX = @PREFIX@" ), "PREFIX = @PREFIX@" )

        act.setParams( dict( { "PREFIX": "/usr" } ) )
        self.assertEqual( len( act.getParams() ), 1 )
        self.assertTrue( "PREFIX" in act.getParams() )
        self.assertEqual( act.getParams()[ "PREFIX" ], "/usr" )

        self.assertEqual( act.exchangeParams( "" ), "" )
        self.assertEqual( act.exchangeParams( "mit navn" ), "mit navn" )
        self.assertEqual( act.exchangeParams( "PREFIX = @PREFIX@" ), "PREFIX = /usr" )
        self.assertEqual( act.exchangeParams( "PREFIX = @PREFIX@@@" ), "PREFIX = /usr@" )
        self.assertEqual( act.exchangeParams( "PREFIX = @PREFIX" ), "PREFIX = @PREFIX" )
        self.assertEqual( act.exchangeParams( "PREFIX = PREFIX@" ), "PREFIX = PREFIX@" )
        self.assertEqual( act.exchangeParams( "PREFIX = @PREFIX PREFIX = @PREFIX@ PREFIX = PREFIX@" ), 
                          "PREFIX = @PREFIX PREFIX = /usr PREFIX = PREFIX@" )
Пример #3
0
    def newFileAction( self, inFile, outFile, params = None ):
        act = FileAction( inputFile = inFile, outputFile = outFile )
        if params is not None:
            act.setParams( params )

        return act