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" )
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" )
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)
def __init__( self, fromNode, toNode, rwAttrs = None, roAttrs = None ): """ c'tor """ Edge.__init__( self, fromNode, toNode, rwAttrs, roAttrs )