|
1 | 1 | import os
|
2 | 2 | from unittest import mock
|
3 | 3 |
|
4 |
| -import redis |
5 | 4 | from gidgethub import sansio
|
6 | 5 |
|
| 6 | +import redis |
| 7 | +import kombu |
| 8 | + |
7 | 9 | os.environ["REDIS_URL"] = "someurl"
|
8 | 10 | os.environ["RETRY_SLEEP_TIME"] = "1"
|
9 | 11 |
|
@@ -248,3 +250,36 @@ async def test_backport_pr_redis_connection_error():
|
248 | 250 | backport_delay_mock.side_effect = redis.exceptions.ConnectionError
|
249 | 251 | await backport_pr.router.dispatch(event, gh)
|
250 | 252 | assert "trouble backporting after 5 attempts" in gh.post_data["body"]
|
| 253 | + |
| 254 | + |
| 255 | +async def test_backport_pr_kombu_operational_error(): |
| 256 | + data = { |
| 257 | + "action": "closed", |
| 258 | + "pull_request": { |
| 259 | + "merged": True, |
| 260 | + "number": 1, |
| 261 | + "merged_by": {"login": "Mariatta"}, |
| 262 | + "user": {"login": "gvanrossum"}, |
| 263 | + "merge_commit_sha": "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9", |
| 264 | + }, |
| 265 | + "repository": { |
| 266 | + "issues_url": "https://api.github.com/repos/python/cpython/issues/1" |
| 267 | + }, |
| 268 | + } |
| 269 | + event = sansio.Event(data, event="pull_request", delivery_id="1") |
| 270 | + |
| 271 | + getitem = { |
| 272 | + "https://api.github.com/repos/python/cpython/issues/1": { |
| 273 | + "labels_url": "https://api.github.com/repos/python/cpython/issues/1/labels{/name}" |
| 274 | + }, |
| 275 | + "https://api.github.com/repos/python/cpython/issues/1/labels": [ |
| 276 | + {"name": "CLA signed"}, |
| 277 | + {"name": "needs backport to 3.7"}, |
| 278 | + ], |
| 279 | + } |
| 280 | + |
| 281 | + gh = FakeGH(getitem=getitem) |
| 282 | + with mock.patch("miss_islington.tasks.backport_task.delay") as backport_delay_mock: |
| 283 | + backport_delay_mock.side_effect = kombu.exceptions.OperationalError |
| 284 | + await backport_pr.router.dispatch(event, gh) |
| 285 | + assert "trouble backporting after 5 attempts" in gh.post_data["body"] |
0 commit comments