test_api.py 文件源码

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

项目:novajoin 作者: openstack 项目源码 文件源码
def test_invalid_instance_id(self, mock_get_image, mock_get_instance):
        """Mock the instance to not exist so there is nothing to enroll."""
        mock_get_image.return_value = FakeImageService()
        mock_get_instance.return_value = None

        body = {"metadata": {"ipa_enroll": "True"},
                "instance-id": "invalid",
                "project-id": fake.PROJECT_ID,
                "image-id": fake.IMAGE_ID,
                "hostname": "test"}
        req = fakes.HTTPRequest.blank('/v1')
        req.method = 'POST'
        req.content_type = "application/json"
        req.body = jsonutils.dump_as_bytes(body)

        # Not using assertRaises because the exception is wrapped as
        # a Fault
        try:
            self.join_controller.create(req, body)
        except Fault as fault:
            assert fault.status_int == 400
        else:
            assert(False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号