def test_init( self ): act = ActionOptions() self.assertEqual( act.getPrefix(), os.path.abspath( ActionOptions.PREFIX_PATH ) ) self.assertEqual( act.getVersion(), "" ) act = ActionOptions( "/tmp" ) self.assertEqual( act.getPrefix(), "/tmp" ) self.assertEqual( act.getVersion(), "" )
def test_stringDevices( self ): options = ActionOptions() inText = "" outText = inText outDev = io.StringIO() act = FileAction( inputDevice = io.StringIO( inText ), outputDevice = outDev ) act.action( options ) self.assertEqual( outDev.getvalue(), outText ) inText = "mit navn" outText = inText outDev = io.StringIO() act = FileAction( inputDevice = io.StringIO( inText ), outputDevice = outDev ) act.action( options ) self.assertEqual( outDev.getvalue(), outText ) inText = "@PREFIX@" outText = inText.replace( "@PREFIX@", options.getPrefix() ) outDev = io.StringIO() act = FileAction( inputDevice = io.StringIO( inText ), outputDevice = outDev ) act.action( options ) self.assertEqual( outDev.getvalue(), outText )
def test_fileDevices( self ): options = ActionOptions() inText = "@PREFIX@" outText = inText.replace( "@PREFIX@", options.getPrefix() ) act = FileAction( inputDevice = io.StringIO( inText ), outputFile = "test_fileDevices.txt" ) act.action( options ) outFile = io.FileIO( "test_fileDevices.txt" ) self.assertEqual( outFile.read(), outText ) outFile.close()