test_handlers_clusters.py 文件源码

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

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

            test_cluster_restart = make_new(CLUSTER_RESTART)

            # Verify if the cluster restart exists the data is returned
            manager.get.return_value = test_cluster_restart
            body = self.simulate_request('/api/v0/cluster/development/restart')
            self.assertEqual(falcon.HTTP_200, self.srmock.status)
            self.assertEqual(json.loads(test_cluster_restart.to_json()), json.loads(body[0]))

            # Verify no cluster restart returns the proper result
            manager.get.side_effect = (
                test_cluster_restart,
                Exception)
            body = self.simulate_request('/api/v0/cluster/development/restart')
            self.assertEqual(falcon.HTTP_204, self.srmock.status)
            self.assertEqual([], body)  # Empty data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号