test_session.py 文件源码

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

项目:python-zhmcclient 作者: zhmcclient 项目源码 文件源码
def test_check_complete_error1(self):
        """Test check_for_completion() with complete job in error (1)."""
        with requests_mock.mock() as m:
            self.mock_server_1(m)
            session = Session('fake-host', 'fake-user', 'fake-pw')
            op_method = 'POST'
            op_uri = '/api/foo'
            job = Job(session, self.job_uri, op_method, op_uri)
            query_job_status_result = {
                'status': 'complete',
                'job-status-code': 500,
                'job-reason-code': 42,
                # no 'job-results' field (it is not guaranteed to be there)
            }

            m.get(self.job_uri, json=query_job_status_result)
            m.delete(self.job_uri, status_code=204)

            with pytest.raises(HTTPError) as exc_info:
                job_status, op_result = job.check_for_completion()
            exc = exc_info.value

            assert exc.http_status == 500
            assert exc.reason == 42
            assert exc.message is None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号