예제 #1
0
	def testListAttributes(self):
		"""
		This method tests :meth:`foundations.dag.AbstractNode.listAttributes` method.
		"""

		nodeA = AbstractNode("MyNodeA")
		self.assertListEqual(nodeA.listAttributes(), [])
		nodeB = AbstractNode("MyNodeB", attributeA=Attribute(), attributeB=Attribute())
		self.assertListEqual(sorted(nodeB.listAttributes()), ["attributeA", "attributeB"])
예제 #2
0
	def testHash(self):
		"""
		This method tests :class:`foundations.dag.AbstractNode` class hash consistency.
		"""

		nodeA = AbstractNode("MyNodeA")
		self.assertEqual(nodeA.identity, nodeA.__hash__())
		nodeB = AbstractNode("MyNodeB")
		self.assertEqual(nodeB.identity, nodeB.__hash__())
예제 #3
0
	def testGetAttributes(self):
		"""
		This method tests :meth:`foundations.dag.AbstractNode.getAttributes` method.
		"""

		attributes = {"attributeA" : Attribute(), "attributeB" : Attribute()}

		nodeA = AbstractNode("MyNodeA", **attributes)
		for attribute in attributes.itervalues():
			self.assertIn(attribute, nodeA.getAttributes())
예제 #4
0
	def testGetNodeByIdentity(self):
		"""
		This method tests :meth:`foundations.dag.AbstractNode.getNodeByIdentity` method.
		"""

		nodeA = AbstractNode()
		self.assertIsInstance(AbstractNode.getNodeByIdentity(nodeA.identity), AbstractNode)
		nodeB = AbstractNode()
		self.assertIsInstance(AbstractNode.getNodeByIdentity(nodeB.identity), AbstractNode)
		self.assertEqual(AbstractNode.getNodeByIdentity(nodeB.identity), nodeB)
예제 #5
0
	def testAddAttribute(self):
		"""
		This method tests :meth:`foundations.dag.AbstractNode.addAttribute` method.
		"""

		attributes = {"attributeA" : Attribute(), "attributeB" : Attribute()}

		nodeA = AbstractNode("MyNodeA")
		for attribute, value in attributes.iteritems():
			self.assertTrue(nodeA.addAttribute(attribute, value))
			self.assertTrue(nodeA.attributeExists(attribute))
예제 #6
0
	def testHasAttribute(self):
		"""
		This method tests :meth:`foundations.dag.AbstractNode.attributeExists` method.
		"""

		attributes = {"attributeA" : Attribute(), "attributeB" : Attribute()}

		nodeA = AbstractNode("MyNodeA", **attributes)
		for attribute in attributes:
			self.assertTrue(nodeA.attributeExists(attribute))
		nodeB = AbstractNode("MyNodeB", nonAttribute="Non Attribute")
		self.assertFalse(nodeB.attributeExists("nonAttribute"))