Commits

Anonymous committed 5310056

Add unit tests for Node methods that have been recently added.

  • Participants
  • Parent commits b51cc59

Comments (0)

Files changed (2)

File src/engine/SCons/Node/FSTests.py

 built_it = None
 
 class Builder:
-    def execute(self, target = None, source = None):
+    def execute(self, **kw):
         global built_it
         built_it = 1
 
+class Environment:
+    def Dictionary(self, *args):
+	pass
+
 class FSTestCase(unittest.TestCase):
     def runTest(self):
         """Test FS (file system) Node operations
         d1.path = "d"           # XXX FAKE SUBCLASS ATTRIBUTE
         d1.add_source(["d"])    # XXX FAKE SUBCLASS ATTRIBUTE
         d1.builder_set(Builder())
+        d1.env_set(Environment())
         d1.build()
         assert built_it
 
         f1.path = "f"           # XXX FAKE SUBCLASS ATTRIBUTE
         f1.add_source(["f"])    # XXX FAKE SUBCLASS ATTRIBUTE
         f1.builder_set(Builder())
+        f1.env_set(Environment())
         f1.build()
         assert built_it
 

File src/engine/SCons/Node/NodeTests.py

 built_it = None
 
 class Builder:
-    def execute(self, target = None, source = None):
+    def execute(self, **kw):
 	global built_it
 	built_it = 1
 
+class Environment:
+    def Dictionary(self, *args):
+	pass
+
 
 
 class NodeTestCase(unittest.TestCase):
 	"""
 	node = SCons.Node.Node()
 	node.builder_set(Builder())
+	node.env_set(Environment())
 	node.path = "xxx"	# XXX FAKE SUBCLASS ATTRIBUTE
 	node.sources = "yyy"	# XXX FAKE SUBCLASS ATTRIBUTE
 	node.build()
 	node.builder_set(b)
 	assert node.builder == b
 
+    def test_env_set(self):
+	"""Test setting a Node's Environment
+	"""
+	node = SCons.Node.Node()
+	e = Environment()
+	node.env_set(e)
+	assert node.env == e
+
+    def test_has_signature(self):
+	"""Test whether or not a node has a signature
+	"""
+	node = SCons.Node.Node()
+	assert not node.has_signature()
+	node.set_signature('xxx')
+	assert node.has_signature()
+
+    def test_set_signature(self):
+	"""Test setting a Node's signature
+	"""
+	node = SCons.Node.Node()
+	node.set_signature('yyy')
+        assert node.signature == 'yyy'
+
+    def test_get_signature(self):
+	"""Test fetching a Node's signature
+	"""
+	node = SCons.Node.Node()
+	node.set_signature('zzz')
+        assert node.get_signature() == 'zzz'
+
+    def test_add_dependency(self):
+	"""Test adding dependencies to a Node's list.
+	"""
+	node = SCons.Node.Node()
+	assert node.depends == []
+	try:
+	    node.add_dependency('zero')
+	except TypeError:
+	    pass
+	node.add_dependency(['one'])
+	assert node.depends == ['one']
+	node.add_dependency(['two', 'three'])
+	assert node.depends == ['one', 'two', 'three']
+
+    def test_add_source(self):
+	"""Test adding sources to a Node's list.
+	"""
+	node = SCons.Node.Node()
+	assert node.sources == []
+	try:
+	    node.add_source('zero')
+	except TypeError:
+	    pass
+	node.add_source(['one'])
+	assert node.sources == ['one']
+	node.add_source(['two', 'three'])
+	assert node.sources == ['one', 'two', 'three']
+
 
 
 if __name__ == "__main__":