def test__when_setting_pr_sync_label__if_github_raises_more_then_3_times__timeout_error_should_be_raised(self):
github_client: github.Github = mock(spec=github.Github, strict=True)
github_controller = GithubController(github_client, mock(), mock(), mock())
github_repository: github.Repository.Repository = mock(spec=github.Repository.Repository, strict=True)
mock(spec=asyncio)
# when
when(github_client).get_repo('repo')\
.thenRaise(github.GithubException(404, 'repo not found'))\
.thenRaise(github.GithubException(404, 'repo not found'))\
.thenReturn(github_repository)
when(github_repository).get_issue(43)\
.thenRaise(github.GithubException(404, 'repo not found'))
when(asyncio).sleep(1)\
.thenReturn(async_value(None))\
.thenReturn(async_value(None))\
.thenReturn(async_value(None))
# then
with pytest.raises(TriggearTimeoutError) as timeout_error:
await github_controller.set_pr_sync_label_with_retry('repo', 43)
assert str(timeout_error.value) == 'Failed to set label on PR #43 in repo repo after 3 retries'
评论列表
文章目录