test_pipeline_controller.py 文件源码

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

项目:triggear 作者: futuresimple 项目源码 文件源码
def test__when_github_entity_is_not_found__comment_should_return_404_response_with_github_explanation(self):
        parameters = {'repository': 'repo', 'sha': 'null', 'body': 'Comment body', 'jobName': 'job'}
        request = mock({'headers': {'Authorization': f'Token {self.API_TOKEN}'}}, spec=aiohttp.web_request.Request, strict=True)
        github_client = mock(spec=github.Github, strict=True)
        github_repository = mock(spec=github.Repository, strict=True)

        pipeline_controller = PipelineController(github_client, mock(), self.API_TOKEN)

        # given
        when(request).json().thenReturn(async_value(parameters))
        when(CommentRequestData).is_valid_comment_data(parameters).thenReturn(True)
        when(github_client).get_repo('repo').thenReturn(github_repository)
        github_exception_data = {'message': 'Not Found', 'documentation_url': 'https://developer.github.com/v3/'}
        when(github_repository).get_commit('null').thenRaise(github.GithubException(404, github_exception_data))

        # when
        response: aiohttp.web.Response = await pipeline_controller.handle_comment(request)

        # then
        assert response.status == 404
        assert response.reason == str(github_exception_data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号