test_context.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:charm-helpers 作者: juju 项目源码 文件源码
def setUp(self):
        def install(*args, **kw):
            p = patch.object(*args, **kw)
            p.start()
            self.addCleanup(p.stop)

        install(hookenv, 'relation_types', return_value=['rel', 'pear'])
        install(hookenv, 'peer_relation_id', return_value='pear:9')
        install(hookenv, 'relation_ids',
                side_effect=lambda x: ['{}:{}'.format(x, i)
                                       for i in range(9, 11)])
        install(hookenv, 'related_units',
                side_effect=lambda x: ['svc_' + x.replace(':', '/')])
        install(hookenv, 'local_unit', return_value='foo/1')
        install(hookenv, 'relation_get')
        install(hookenv, 'relation_set')
        # install(hookenv, 'is_leader', return_value=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号