(mocker, worker_retry, exception_thrown)
| 1070 | ], |
| 1071 | ) |
| 1072 | async def test_worker_retry(mocker, worker_retry, exception_thrown): |
| 1073 | # Testing redis exceptions, with retry settings specified |
| 1074 | worker = worker_retry(functions=[func(foobar)]) |
| 1075 | |
| 1076 | # patch db read_response to mimic connection exceptions |
| 1077 | p = patch.object(worker.pool.connection_pool.connection_class, 'read_response', side_effect=exception_thrown) |
| 1078 | |
| 1079 | # baseline |
| 1080 | await worker.main() |
| 1081 | await worker._poll_iteration() |
| 1082 | |
| 1083 | # spy method handling call_with_retry failure |
| 1084 | spy = mocker.spy(worker.pool, '_disconnect_raise') |
| 1085 | |
| 1086 | try: |
| 1087 | # start patch |
| 1088 | p.start() |
| 1089 | |
| 1090 | # assert exception thrown |
| 1091 | with pytest.raises(type(exception_thrown)): |
| 1092 | await worker._poll_iteration() |
| 1093 | |
| 1094 | # assert retry counts and no exception thrown during '_disconnect_raise' |
| 1095 | assert spy.call_count == 4 # retries setting + 1 |
| 1096 | assert spy.spy_exception is None |
| 1097 | |
| 1098 | finally: |
| 1099 | # stop patch to allow worker cleanup |
| 1100 | p.stop() |
| 1101 | |
| 1102 | |
| 1103 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected
searching dependent graphs…