def test_delete_broken(): engine = FaultyEngine() actor = ActorBase(engine, [], {}) with pytest.raises(StorageError): actor.put('foo', True) actor.delete('foo')
def test_untag(): tags = [] engine = FaultyEngine() actor = ActorBase(engine, [], {}) actor.on('untag', lambda t: tags.append(t)) actor.untag('tag') assert tags == ['tag']
def _log(logger_method, actor_method=None): if not actor_method: actor_method = logger_method logs = [] engine = LocalMemoryEngine() actor = ActorBase(engine, [], {}) func = getattr(actor, actor_method) with patch('logging.Logger.%s' % logger_method, logs.append): func({'foo': 'bar'}) assert logs == ['{\n "foo": "bar"\n}']
def test_get_broken(): engine = FaultyEngine() actor = ActorBase(engine, [], {}) with pytest.raises(StorageError): actor.get('foo')
def test_get(): engine = LocalMemoryEngine() actor = ActorBase(engine, [], {}) assert not actor.get('foo')
def test_fail(): engine = LocalMemoryEngine() actor = ActorBase(engine, [], {}) with pytest.raises(PerformanceError): actor.fail('Failure')
def test_bucket_error(): with pytest.raises(StorageError) as ctx: engine = BrokenEngine() ActorBase(engine, [], {}) assert ctx.value.args[0] == 'Error obtaining bucket.'
def test_delete(): engine = LocalMemoryEngine() actor = ActorBase(engine, [], {}) actor.put('foo', True) actor.delete('foo') assert actor.get('foo') is None
def test_push_broken(): engine = FaultyEngine() actor = ActorBase(engine, [], {}) with pytest.raises(StorageError): actor.push('foo', 1)
def test_push(): engine = LocalMemoryEngine() actor = ActorBase(engine, [], {}) actor.push('foo', 1) assert actor.get('foo') == [1]
def test_pull_broken(): engine = FaultyEngine() actor = ActorBase(engine, [], {}) with pytest.raises(StorageError): list(actor.pull('foo'))
def test_pull(): engine = LocalMemoryEngine() actor = ActorBase(engine, [], {}) actor.push('foo', 1) assert list(actor.pull('foo')) == [1]