当前位置: 首页>>代码示例>>Python>>正文


Python Branch.append_child方法代码示例

本文整理汇总了Python中models.Branch.append_child方法的典型用法代码示例。如果您正苦于以下问题:Python Branch.append_child方法的具体用法?Python Branch.append_child怎么用?Python Branch.append_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Branch的用法示例。


在下文中一共展示了Branch.append_child方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BranchTestCase

# 需要导入模块: from models import Branch [as 别名]
# 或者: from models.Branch import append_child [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)
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:60,代码来源:data_tests.py


注:本文中的models.Branch.append_child方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。