本文整理汇总了Python中models.Branch.children方法的典型用法代码示例。如果您正苦于以下问题:Python Branch.children方法的具体用法?Python Branch.children怎么用?Python Branch.children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Branch
的用法示例。
在下文中一共展示了Branch.children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BranchTestCase
# 需要导入模块: from models import Branch [as 别名]
# 或者: from models.Branch import children [as 别名]
class BranchTestCase(unittest.TestCase):
def setUp(self):
#the memcache will contain values that will break the tests
#dont run this on production!
memcache.flush_all()
# First, create an instance of the Testbed class.
self.testbed = testbed.Testbed()
# Then activate the testbed, which prepares the service stubs for use.
self.testbed.activate()
# Create a consistency policy that will simulate the High Replication consistency model.
self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0)
# Initialize the datastore stub with this policy.
self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)
millis = int(round(time.time() * 1000))
tree_name = 'test_tree' + str(millis)
username = 'test_user' + str(millis)
self.parent_branch = Branch(id=tree_name)
self.parent_branch.author_name = username
self.parent_branch.link = ''
self.parent_branch.content = ''
self.parent_branch.put()
self.child_branchs = []
def tearDown(self):
for branch in self.child_branchs:
branch.key.delete()
self.parent_branch.key.delete()
self.testbed.deactivate()
def testUpdateNoDuplicate(self):
branch = Branch()
branch.link = 'testIdenticalLink.some_link'
branch.content = 'some_content'
branch.revision = 0
branch.parent_branch = self.parent_branch.key
branch.parent_branch_authorname = self.parent_branch.authorname
branch.put()
self.parent_branch.append_child(branch)
self.assertTrue(len(self.parent_branch.children()) == 1)
self.child_branchs.append(branch)