def test__when_status_data_is_ok__should_call_github_client_to_create_status(self):
proper_data = {'repository': 'repo', 'sha': '123abc', 'state': 'State', 'description': 'Description', 'context': 'Context', 'url': 'pr_url'}
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)
github_commit = mock(spec=github.Commit, strict=True)
pipeline_controller = PipelineController(github_client, mock(), self.API_TOKEN)
# given
when(request).json().thenReturn(async_value(proper_data))
when(StatusRequestData).is_valid_status_data(proper_data).thenReturn(True)
when(github_client).get_repo('repo').thenReturn(github_repository)
when(github_repository).get_commit('123abc').thenReturn(github_commit)
when(github_commit).create_status(state='State', description='Description', target_url='pr_url', context='Context')
# when
response: aiohttp.web.Response = await pipeline_controller.handle_status(request)
# then
assert response.status == 200
assert response.text == 'Status ACK'
评论列表
文章目录