Couple of bugs squashed.

1) It's incr not inc on the redis client, so renamed the calls everywhere
2) Redis returns bytes/string rather than an int if the value stored is an int. Cast the result to an int before use. Not you can set up the GET to do this transparently but I've not done this as we *may * use GETS for non-int and  the callback sets up the cast for the connection not the call.
This commit is contained in:
Martyn Inglis
2016-11-12 15:37:57 +00:00
parent 4c0c30bb2e
commit ac6609e653
7 changed files with 17 additions and 17 deletions

View File

@@ -32,10 +32,10 @@ def test_should_not_raise_exception_if_raise_set_to_false(notify_api):
redis_client.init_app(notify_api)
redis_client.redis_store.get = Mock(side_effect=Exception())
redis_client.redis_store.set = Mock(side_effect=Exception())
redis_client.redis_store.inc = Mock(side_effect=Exception())
redis_client.redis_store.incr = Mock(side_effect=Exception())
assert redis_client.get('test') is None
assert redis_client.set('test', 'test') is None
assert redis_client.inc('test')is None
assert redis_client.incr('test') is None
def test_should_raise_exception_if_raise_set_to_true(notify_api):
@@ -44,7 +44,7 @@ def test_should_raise_exception_if_raise_set_to_true(notify_api):
redis_client.init_app(notify_api)
redis_client.redis_store.get = Mock(side_effect=Exception('get failed'))
redis_client.redis_store.set = Mock(side_effect=Exception('set failed'))
redis_client.redis_store.inc = Mock(side_effect=Exception('inc failed'))
redis_client.redis_store.incr = Mock(side_effect=Exception('inc failed'))
with pytest.raises(Exception) as e:
redis_client.get('test', raise_exception=True)
assert str(e.value) == 'get failed'
@@ -52,7 +52,7 @@ def test_should_raise_exception_if_raise_set_to_true(notify_api):
redis_client.set('test', 'test', raise_exception=True)
assert str(e.value) == 'set failed'
with pytest.raises(Exception) as e:
redis_client.inc('test', raise_exception=True)
redis_client.incr('test', raise_exception=True)
assert str(e.value) == 'inc failed'