Beispiel #1
0
    def test2SetToolProperties(self):
        """Test setting of tool properties"""

        from AthExHelloWorld.AthExHelloWorldConf import HelloAlg
        from AthExHelloWorld.AthExHelloWorldConf import HelloTool

        HelloWorld = HelloAlg('HelloWorld')

        msg1 = "A Private Message!"

        HelloWorld.MyPrivateHelloTool = HelloTool("HelloTool")
        HelloWorld.MyPrivateHelloTool.MyMessage = msg1

        HelloWorld.setup()

        global ToolSvc

        msg2 = "A Public Message!"

        ToolSvc += HelloTool("PublicHello")
        ToolSvc.PublicHello.MyMessage = msg2

        ToolSvc.setup()

        self.assertEqual(HelloWorld.MyPrivateHelloTool.MyMessage, msg1)
        client = HelloWorld.getName(
        ) + '.' + HelloWorld.MyPrivateHelloTool.getName()
        self.assert_(JobOptionsSvc.verify(client, 'MyMessage', msg1))

        self.assertEqual(ToolSvc.PublicHello.MyMessage, msg2)
        self.assert_(
            JobOptionsSvc.verify('ToolSvc.PublicHello', 'MyMessage', msg2))
   def test2SetToolProperties( self ):
      """Test setting of tool properties"""

      from AthExHelloWorld.AthExHelloWorldConf import HelloAlg
      from AthExHelloWorld.AthExHelloWorldConf import HelloTool

      HelloWorld = HelloAlg( 'HelloWorld' )

      msg1 = "A Private Message!"

      HelloWorld.MyPrivateHelloTool = HelloTool( "HelloTool" )
      HelloWorld.MyPrivateHelloTool.MyMessage = msg1

      HelloWorld.setup()

      global ToolSvc

      msg2 = "A Public Message!"

      ToolSvc += HelloTool( "PublicHello" )
      ToolSvc.PublicHello.MyMessage = msg2

      ToolSvc.setup()

      self.assertEqual( HelloWorld.MyPrivateHelloTool.MyMessage, msg1 )
      client = HelloWorld.getName() + '.' + HelloWorld.MyPrivateHelloTool.getName()
      self.assert_( JobOptionsSvc.verify( client, 'MyMessage', msg1 ) )

      self.assertEqual( ToolSvc.PublicHello.MyMessage, msg2 )
      self.assert_( JobOptionsSvc.verify( 'ToolSvc.PublicHello', 'MyMessage', msg2 ) )
   def test1SetBuiltinTypes( self ):
      """Test setting of builtin types"""

      from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

      HelloWorld = HelloAlg( 'HelloWorld' )

      HelloWorld.MyInt = 42
      HelloWorld.MyBool = True
      HelloWorld.MyDouble = 3.14159
      HelloWorld.MyStringVec = [ "Welcome", "to", "Athena", "Framework", "Tutorial" ]
      HelloWorld.MyStringVec += [ "!" ]
      HelloWorld.MyDict = { 'Bonjour'      : 'Guten Tag',
                            'Good Morning' : 'Bonjour' , 'one' : 'uno' }
      HelloWorld.MyDict[ "Goeiedag" ] = "Ni Hao"
      HelloWorld.MyTable = [ ( 1 , 1 ) , ( 2 , 4 ) , ( 3 , 9 ) ]
      HelloWorld.MyTable += [ ( 4, 16 ) ]
      HelloWorld.MyMatrix = [ [ 1, 2, 3 ],
                              [ 4, 5, 6 ] ]
      HelloWorld.MyMatrix += [ [ 7, 8, 9 ] ]

      HelloWorld.setup()

      self.assertEqual( HelloWorld.MyInt, 42 )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyInt', '42' ) )

      self.assertEqual( HelloWorld.MyBool, True )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyBool', 'True' ) )

      self.assertEqual( round( HelloWorld.MyDouble - 3.14159, 8 ), 0. )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyDouble', '3.14159' ) )

    # the following may be too sensitive to non-consequential changes in formatting
      self.assertEqual( HelloWorld.MyStringVec,
         [ "Welcome", "to", "Athena", "Framework", "Tutorial", "!" ] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyStringVec',
         "['Welcome', 'to', 'Athena', 'Framework', 'Tutorial', '!']" ) )

      self.assertEqual( HelloWorld.MyDict,
         {'Bonjour': 'Guten Tag', 'one': 'uno', 'Goeiedag': 'Ni Hao', 'Good Morning': 'Bonjour'} )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyDict',
         "{'Bonjour': 'Guten Tag', 'one': 'uno', 'Goeiedag': 'Ni Hao', 'Good Morning': 'Bonjour'}" ) )
      self.assertEqual( HelloWorld.MyTable, [(1, 1), (2, 4), (3, 9), (4, 16)] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyTable',
         "[(1, 1), (2, 4), (3, 9), (4, 16)]" ) )

      self.assertEqual( HelloWorld.MyMatrix, [[1, 2, 3], [4, 5, 6], [7, 8, 9]] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyMatrix',
         "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]" ) )
   def test1SetBuiltinTypes( self ):
      """Test setting of builtin types"""

      from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

      HelloWorld = HelloAlg( 'HelloWorld' )

      HelloWorld.MyInt = 42
      HelloWorld.MyBool = True
      HelloWorld.MyDouble = 3.14159
      HelloWorld.MyStringVec = [ "Welcome", "to", "Athena", "Framework", "Tutorial" ]
      HelloWorld.MyStringVec += [ "!" ]
      HelloWorld.MyDict = { 'Bonjour'      : 'Guten Tag',
                            'Good Morning' : 'Bonjour' , 'one' : 'uno' }
      HelloWorld.MyDict[ "Goeiedag" ] = "Ni Hao"
      HelloWorld.MyTable = [ ( 1 , 1 ) , ( 2 , 4 ) , ( 3 , 9 ) ]
      HelloWorld.MyTable += [ ( 4, 16 ) ]
      HelloWorld.MyMatrix = [ [ 1, 2, 3 ],
                              [ 4, 5, 6 ] ]
      HelloWorld.MyMatrix += [ [ 7, 8, 9 ] ]

      HelloWorld.setup()

      self.assertEqual( HelloWorld.MyInt, 42 )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyInt', '42' ) )

      self.assertEqual( HelloWorld.MyBool, True )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyBool', 'True' ) )

      self.assertEqual( round( HelloWorld.MyDouble - 3.14159, 8 ), 0. )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyDouble', '3.14159' ) )

    # the following may be too sensitive to non-consequential changes in formatting
      self.assertEqual( HelloWorld.MyStringVec,
         [ "Welcome", "to", "Athena", "Framework", "Tutorial", "!" ] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyStringVec',
         "['Welcome', 'to', 'Athena', 'Framework', 'Tutorial', '!']" ) )

      self.assertEqual( HelloWorld.MyDict,
         {'Bonjour': 'Guten Tag', 'one': 'uno', 'Goeiedag': 'Ni Hao', 'Good Morning': 'Bonjour'} )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyDict',
         "{'Bonjour': 'Guten Tag', 'one': 'uno', 'Goeiedag': 'Ni Hao', 'Good Morning': 'Bonjour'}" ) )
      self.assertEqual( HelloWorld.MyTable, [(1, 1), (2, 4), (3, 9), (4, 16)] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyTable',
         "[(1, 1), (2, 4), (3, 9), (4, 16)]" ) )

      self.assertEqual( HelloWorld.MyMatrix, [[1, 2, 3], [4, 5, 6], [7, 8, 9]] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyMatrix',
         "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]" ) )