def setUp(self): abstract_node_class = mocksignature(AbstractNode, AbstractNode) selector_class = mocksignature(StaticSelector, StaticSelector) self.abstract_node = abstract_node_class(self) self.abstract_node.selector = selector_class(self) self.root_node = Node(pattern='', parent=None, abstract_node=self.abstract_node)
class TestNode(unittest.TestCase): def setUp(self): abstract_node_class = mocksignature(AbstractNode, AbstractNode) selector_class = mocksignature(StaticSelector, StaticSelector) self.abstract_node = abstract_node_class(self) self.abstract_node.selector = selector_class(self) self.root_node = Node(pattern='', parent=None, abstract_node=self.abstract_node) def test_instance(self): self.assertIsInstance(self.root_node, Node) def test_id(self): node = Node(pattern='folder', parent=self.root_node, abstract_node=self.abstract_node) self.assertIsInstance(node.id, long) self.assertEqual(node.id, 4710211110810010111447L) def test_path(self): node = Node(pattern='folder', parent=self.root_node, abstract_node=self.abstract_node) self.assertIsInstance(node.path, unicode) def test_build_child(self): Node(pattern='folder', parent=self.root_node, abstract_node=self.abstract_node) self.abstract_node.match_child = lambda node, pattern: self.abstract_node self.assertIsInstance(self.root_node.build_child('folder'), Node) def test_children(self): node = Node(pattern='', parent=self.root_node, abstract_node=self.abstract_node) self.assertIsInstance(node.children, list) def test_read_contents(self): node = Node(pattern='', parent=self.root_node, abstract_node=self.abstract_node) self.abstract_node.read_node_contents = lambda node, size, offset: open('/etc/passwd').read() contents = node.read_contents() self.assertIsInstance(contents, str)
def test_read_contents(self): node = Node(pattern='', parent=self.root_node, abstract_node=self.abstract_node) self.abstract_node.read_node_contents = lambda node, size, offset: open('/etc/passwd').read() contents = node.read_contents() self.assertIsInstance(contents, str)