diff options
author | Ashish Bansal (mrphantom) <bansal.ashish096@gmail.com> | 2019-12-02 03:42:13 +0530 |
---|---|---|
committer | Asif Saif Uddin <auvipy@gmail.com> | 2019-12-02 04:12:13 +0600 |
commit | ccc9e01f32eb874c69c2e07fbd48c1e07e3df358 (patch) | |
tree | 3c6fef50f124ef4c43debe8a0d18eaba623c0ff0 /t | |
parent | de8d8cf8c1f6cd6da8b5d0b4cd66130b1f129e21 (diff) | |
download | kombu-ccc9e01f32eb874c69c2e07fbd48c1e07e3df358.tar.gz |
Fix redis health checks (#1122)
* Fix redis transport health checks functionality
* Add tests for accepts_argument util function
* Reduce default health check interval to 25s
Diffstat (limited to 't')
-rw-r--r-- | t/unit/transport/test_redis.py | 2 | ||||
-rw-r--r-- | t/unit/utils/test_functional.py | 28 |
2 files changed, 28 insertions, 2 deletions
diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py index 58e22413..6c0a5229 100644 --- a/t/unit/transport/test_redis.py +++ b/t/unit/transport/test_redis.py @@ -738,7 +738,7 @@ class test_Channel: transport.cycle.on_poll_init.assert_called_with(loop.poller) loop.call_repeatedly.assert_has_calls([ call(10, transport.cycle.maybe_restore_messages), - call(30, transport.cycle.maybe_check_subclient_health), + call(25, transport.cycle.maybe_check_subclient_health), ]) loop.on_tick.add.assert_called() on_poll_start = loop.on_tick.add.call_args[0][0] diff --git a/t/unit/utils/test_functional.py b/t/unit/utils/test_functional.py index 2ed64761..b5ec03af 100644 --- a/t/unit/utils/test_functional.py +++ b/t/unit/utils/test_functional.py @@ -8,11 +8,14 @@ from itertools import count from case import Mock, mock, skip -from kombu.five import items +from kombu.five import ( + items, PY3, +) from kombu.utils import functional as utils from kombu.utils.functional import ( ChannelPromise, LRUCache, fxrange, fxrangemax, memoize, lazy, maybe_evaluate, maybe_list, reprcall, reprkwargs, retry_over_time, + accepts_argument, ) @@ -310,3 +313,26 @@ def test_reprkwargs(): def test_reprcall(): assert reprcall('add', (2, 2), {'copy': True}) + + +class test_accepts_arg: + def function(self, foo, bar, baz="baz"): + pass + + def test_valid_argument(self): + assert accepts_argument(self.function, 'self') + assert accepts_argument(self.function, 'foo') + assert accepts_argument(self.function, 'baz') + + def test_invalid_argument(self): + assert not accepts_argument(self.function, 'random_argument') + if PY3: + assert not accepts_argument(test_accepts_arg, 'foo') + + def test_raise_exception(self): + with pytest.raises(Exception): + accepts_argument(None, 'foo') + + if not PY3: + with pytest.raises(Exception): + accepts_argument(test_accepts_arg, 'foo') |