test_handlers_clusters.py 文件源码

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

项目:commissaire-mvp 作者: projectatomic 项目源码 文件源码
def test_cluster_create(self):
        """
        Verify creating a cluster.
        """
        with mock.patch('cherrypy.engine.publish') as _publish:
            manager = mock.MagicMock(StoreHandlerManager)
            _publish.return_value = [manager]

            test_cluster = make_new(CLUSTER_WITH_HOST)
            # Verify with creation
            manager.get.side_effect = (
                Exception,
                test_cluster,
                test_cluster,
                test_cluster
            )

            test_body = '{"network": "default"}'

            body = self.simulate_request(
                '/api/v0/cluster/development', method='PUT', body=test_body)
            self.assertEquals(falcon.HTTP_201, self.srmock.status)
            self.assertEquals('{}', body[0])

            # Verify with existing cluster
            manager.get.return_value = CLUSTER
            body = self.simulate_request(
                '/api/v0/cluster/development', method='PUT', body=test_body)
            self.assertEquals(falcon.HTTP_201, self.srmock.status)
            self.assertEquals('{}', body[0])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号