|
1 | 1 | import unittest |
2 | 2 | import asyncio |
3 | 3 |
|
4 | | -from canopy import request_with_retry |
| 4 | +import canopy |
5 | 5 |
|
6 | 6 |
|
7 | 7 | class RequestWithRetryTest(unittest.TestCase): |
8 | 8 |
|
9 | 9 | def test_it_should_return_result_if_no_error(self): |
10 | 10 | request = DummyRequest(0) |
11 | | - result = asyncio.run(request_with_retry(lambda: request.execute('abc'), 'request', True)) |
| 11 | + result = canopy.run(canopy.request_with_retry(lambda: request.execute('abc'), 'request', True)) |
12 | 12 | self.assertEqual(result, 'abc') |
13 | 13 |
|
14 | 14 | def test_it_should_return_result_if_one_error(self): |
15 | 15 | request = DummyRequest(1) |
16 | | - result = asyncio.run(request_with_retry(lambda: request.execute('abc'), 'request', True)) |
| 16 | + result = canopy.run(canopy.request_with_retry(lambda: request.execute('abc'), 'request', True)) |
17 | 17 | self.assertEqual(result, 'abc') |
18 | 18 |
|
19 | 19 | def test_it_should_raise_error_if_two_errors(self): |
20 | 20 | request = DummyRequest(2) |
21 | 21 | try: |
22 | | - asyncio.run(request_with_retry(lambda: request.execute('abc'), 'request', True)) |
| 22 | + canopy.run(canopy.request_with_retry(lambda: request.execute('abc'), 'request', True)) |
23 | 23 | self.fail() |
24 | 24 | except asyncio.TimeoutError: |
25 | 25 | pass |
26 | 26 |
|
27 | 27 | def test_it_should_return_none_if_two_errors_and_suppressed(self): |
28 | 28 | request = DummyRequest(2) |
29 | | - result = asyncio.run(request_with_retry(lambda: request.execute('abc'), 'request', False)) |
| 29 | + result = canopy.run(canopy.request_with_retry(lambda: request.execute('abc'), 'request', False)) |
30 | 30 | self.assertIsNone(result) |
31 | 31 |
|
32 | 32 |
|
|
0 commit comments