本文整理汇总了Python中exe.engine.package.Package.findNode方法的典型用法代码示例。如果您正苦于以下问题:Python Package.findNode方法的具体用法?Python Package.findNode怎么用?Python Package.findNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.package.Package
的用法示例。
在下文中一共展示了Package.findNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestOutline
# 需要导入模块: from exe.engine.package import Package [as 别名]
# 或者: from exe.engine.package.Package import findNode [as 别名]
class TestOutline(unittest.TestCase):
def setUp(self):
class MyConfig:
def __init__(self):
self.port = 8081
self.dataDir = Path(".")
self.webDir = Path(".")
self.exeDir = Path(".")
self.configDir = Path(".")
self.styles = ["default"]
app = Application()
app.config = MyConfig()
app.preLaunch()
self.client = FakeClient()
self.package = Package('temp')
app.webServer.root.bindNewPackage(self.package)
self.outline = app.webServer.root.children['temp'].outlinePane
def testAddAndDel(self):
"""Should be able to add a node to the package"""
def checkAdd(id_, title):
assert ('call', ('XHAddChildTreeItem', id_, title), {}) in self.client.calls, self.client.calls
assert str(self.package.currentNode.title) == title, title
assert self.package.currentNode.id == id_, id_
self.outline.handleAddChild(self.client, '0') # Home/root node
checkAdd('1', 'Topic') # 1.0
self.outline.handleAddChild(self.client, '1')
checkAdd('2', 'Section') # 1.0.0
self.outline.handleAddChild(self.client, '2')
checkAdd('3', 'Unit') # 1.0.0.0
self.outline.handleAddChild(self.client, '3')
checkAdd('4', '?????') # 1.0.0.0.0
self.outline.handleAddChild(self.client, '0')
checkAdd('5', 'Topic') # 1.1
self.outline.handleAddChild(self.client, '0')
checkAdd('6', 'Topic') # 1.2
self.outline.handleAddChild(self.client, '1')
checkAdd('7', 'Section') # 1.0.1
self.outline.handleAddChild(self.client, '1')
checkAdd('8', 'Section') # 1.0.2
self.outline.handleAddChild(self.client, '2')
checkAdd('9', 'Unit') # 1.0.0.1
self.outline.handleAddChild(self.client, '2')
checkAdd('10', 'Unit') # 1.0.0.2
n12 = self.package.findNode('10')
n4 = self.package.findNode('2')
assert n12.parent is n4, n12.parent
assert n12 in n4.children
assert n4.parent.id == '1'
assert n4.parent.parent.id == '0'
assert n4.parent.parent.parent is None
self.client.calls = []
self.outline.handleDelNode(self.client, 'false', '2') # Del
assert not self.client.calls
assert self.package.findNode('2')
self.outline.handleDelNode(self.client, 'true', '0')
assert not self.client.calls
assert self.package.findNode('0')
oldNode = self.package.currentNode
self.package.currentNode = self.package.findNode('3')
self.outline.handleDelNode(self.client, 'true', '3')
assert ('call', ('XHDelNode', '3'), {}) in self.client.calls, self.client.calls
assert self.package.currentNode.id == '2', self.package.currentNode.id
assert self.package.findNode('3') is None
assert self.package.findNode('4') is None
assert self.package.findNode('1')
assert self.package.findNode('2')
assert self.package.findNode('9')
assert self.package.findNode('10')
assert self.package.findNode('7')
assert self.package.findNode('8')
oldNode = self.package.currentNode
self.outline.handleDelNode(self.client, 'true', '1')
assert ('call', ('XHDelNode', '1'), {}) in self.client.calls, self.client.calls
assert self.package.findNode('1') is None
assert self.package.findNode('2') is None
assert self.package.findNode('9') is None
assert self.package.findNode('10') is None
assert self.package.findNode('7') is None
assert self.package.findNode('8') is None
assert self.package.currentNode == oldNode, "Current node shouldn't have changed"
def testRenNode(self):
"""Should be able to rename nodes"""
self.outline.handleRenNode(self.client, '0', 'Genesis')
assert str(self.package.findNode('0').title) == 'Genesis'
assert ('sendScript', ('XHRenNode("Genesis")',), {}) in self.client.calls, self.client.calls
示例2: TestOutline
# 需要导入模块: from exe.engine.package import Package [as 别名]
# 或者: from exe.engine.package.Package import findNode [as 别名]
class TestOutline(unittest.TestCase):
def setUp(self):
class MyConfig:
def __init__(self):
self.port = 8081
self.dataDir = Path(".")
self.webDir = Path(".")
self.exeDir = Path(".")
self.configDir = Path(".")
self.styles = ["default"]
app = Application()
app.config = MyConfig()
app.preLaunch()
self.client = FakeClient()
self.package = Package('temp')
app.webServer.root.bindNewPackage(self.package)
self.outline = app.webServer.root.children['temp'].outlinePane
#self.outline = OutlinePane(None, None, None, server)
def testAddAndDel(self):
"""Should be able to add a node to the package"""
def checkAdd(id_, title):
assert ('call', ('XHAddChildTreeItem', id_, title), {}) in self.client.calls, self.client.calls
assert str(self.package.currentNode.title) == title, title
assert self.package.currentNode.id == id_, id_
self.outline.handleAddChild(self.client, '0') # Home/root node
checkAdd('1', 'Topic') # 1.0
self.outline.handleAddChild(self.client, '1')
checkAdd('2', 'Section') # 1.0.0
self.outline.handleAddChild(self.client, '2')
checkAdd('3', 'Unit') # 1.0.0.0
self.outline.handleAddChild(self.client, '3')
checkAdd('4', '?????') # 1.0.0.0.0
self.outline.handleAddChild(self.client, '0')
checkAdd('5', 'Topic') # 1.1
self.outline.handleAddChild(self.client, '0')
checkAdd('6', 'Topic') # 1.2
self.outline.handleAddChild(self.client, '1')
checkAdd('7', 'Section') # 1.0.1
self.outline.handleAddChild(self.client, '1')
checkAdd('8', 'Section') # 1.0.2
self.outline.handleAddChild(self.client, '2')
checkAdd('9', 'Unit') # 1.0.0.1
self.outline.handleAddChild(self.client, '2')
checkAdd('10', 'Unit') # 1.0.0.2
# Check that we are parent and children attributes are bieng created properly
n12 = self.package.findNode('10')
n4 = self.package.findNode('2')
assert n12.parent is n4, n12.parent
assert n12 in n4.children
assert n4.parent.id == '1'
assert n4.parent.parent.id == '0'
assert n4.parent.parent.parent is None
# Tree now looks like this
# 01
# |_02
# | |_03
# | | |_04
# | | | |_05
# | | |_09
# | | |_10
# | |_07
# | |_08
# |_05
# |_06
# Now do some deletion
self.client.calls = []
# Do nothing because confirm is false
self.outline.handleDelNode(self.client, 'false', '2') # Del
assert not self.client.calls
assert self.package.findNode('2')
# Do nothing because its the home node
self.outline.handleDelNode(self.client, 'true', '0')
assert not self.client.calls
assert self.package.findNode('0')
# Now delete the selected node, should select its parent
oldNode = self.package.currentNode
self.package.currentNode = self.package.findNode('3')
self.outline.handleDelNode(self.client, 'true', '3')
assert ('call', ('XHDelNode', '3'), {}) in self.client.calls, self.client.calls
assert self.package.currentNode.id == '2', self.package.currentNode.id
assert self.package.findNode('3') is None
assert self.package.findNode('4') is None
# Now wipe out a whole tree!
assert self.package.findNode('1')
assert self.package.findNode('2')
assert self.package.findNode('9')
assert self.package.findNode('10')
assert self.package.findNode('7')
assert self.package.findNode('8')
oldNode = self.package.currentNode
self.outline.handleDelNode(self.client, 'true', '1')
assert ('call', ('XHDelNode', '1'), {}) in self.client.calls, self.client.calls
# Check that all its children are gone
assert self.package.findNode('1') is None
assert self.package.findNode('2') is None
assert self.package.findNode('9') is None
assert self.package.findNode('10') is None
assert self.package.findNode('7') is None
#.........这里部分代码省略.........