コード例 #1
0
ファイル: GraphTests.py プロジェクト: sbel/bes3-jinr
  def testEdge( self ):
    """ c'tor connect attrs """
    edge = Edge( self.fromNode, self.toNode, self.rwAttrs, self.roAttrs )

    # # name
    self.assertEqual( edge.name, "%s-%s" % ( self.fromNode.name, self.toNode.name ) )
    try:
      edge.name = "can't do this"
    except AttributeError, error:
      self.assertEqual( str( error ), "can't set attribute" )
コード例 #2
0
  def testEdge( self ):
    """ c'tor connect attrs """
    edge = Edge( self.fromNode, self.toNode, self.rwAttrs, self.roAttrs )

    ## name 
    self.assertEqual( edge.name, "%s-%s" % ( self.fromNode.name, self.toNode.name ) )
    try:
      edge.name = "can't do this"
    except AttributeError, error:
      self.assertEqual( str(error), "can't set attribute" )
コード例 #3
0
ファイル: Test_Graph.py プロジェクト: pmusset/DIRAC
    def testEdge(self):
        """ c'tor connect attrs """
        edge = Edge(self.fromNode, self.toNode, self.rwAttrs, self.roAttrs)

        # # name
        self.assertEqual(edge.name,
                         "%s-%s" % (self.fromNode.name, self.toNode.name))
        try:
            edge.name = "can't do this"
        except AttributeError as error:
            self.assertEqual(str(error), "can't set attribute")
        try:
            edge.makeProperty("name", "impossible")
        except AttributeError as error:
            self.assertEqual(str(error),
                             "_name or name is already defined as a member")

        # # visited attr
        self.assertEqual(hasattr(edge, "visited"), True)
        self.assertEqual(edge.visited, False)  #pylint: disable=no-member

        # # ro attrs
        for k, v in self.roAttrs.items():
            self.assertEqual(hasattr(edge, k), True)
            self.assertEqual(getattr(edge, k), v)
            try:
                setattr(edge, k, "new value")
            except AttributeError as error:
                self.assertEqual(str(error), "can't set attribute")

        # # rw attrs
        for k, v in self.rwAttrs.items():
            self.assertEqual(hasattr(edge, k), True)
            self.assertEqual(getattr(edge, k), v)
            setattr(edge, k, "new value")
            self.assertEqual(getattr(edge, k), "new value")

        # # start and end
        self.assertEqual(edge.fromNode, self.fromNode)  #pylint: disable=no-member
        self.assertEqual(edge.toNode, self.toNode)  #pylint: disable=no-member
        # # in fromNode, not in toNode
        self.assertEqual(edge in self.fromNode, True)
        self.assertEqual(edge not in self.toNode, True)
コード例 #4
0
 def __init__( self, fromNode, toNode, rwAttrs = None, roAttrs = None ):
   """ c'tor """
   Edge.__init__( self, fromNode, toNode, rwAttrs, roAttrs )