예제 #1
0
def test_delete_broken():
    engine = FaultyEngine()
    actor = ActorBase(engine, [], {})

    with pytest.raises(StorageError):
        actor.put('foo', True)
        actor.delete('foo')
예제 #2
0
def test_untag():
    tags = []
    engine = FaultyEngine()
    actor = ActorBase(engine, [], {})
    actor.on('untag', lambda t: tags.append(t))
    actor.untag('tag')
    assert tags == ['tag']
예제 #3
0
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}']
예제 #4
0
def test_get_broken():
    engine = FaultyEngine()
    actor = ActorBase(engine, [], {})

    with pytest.raises(StorageError):
        actor.get('foo')
예제 #5
0
def test_get():
    engine = LocalMemoryEngine()
    actor = ActorBase(engine, [], {})
    assert not actor.get('foo')
예제 #6
0
def test_fail():
    engine = LocalMemoryEngine()
    actor = ActorBase(engine, [], {})

    with pytest.raises(PerformanceError):
        actor.fail('Failure')
예제 #7
0
def test_bucket_error():
    with pytest.raises(StorageError) as ctx:
        engine = BrokenEngine()
        ActorBase(engine, [], {})

    assert ctx.value.args[0] == 'Error obtaining bucket.'
예제 #8
0
def test_delete():
    engine = LocalMemoryEngine()
    actor = ActorBase(engine, [], {})
    actor.put('foo', True)
    actor.delete('foo')
    assert actor.get('foo') is None
예제 #9
0
def test_push_broken():
    engine = FaultyEngine()
    actor = ActorBase(engine, [], {})

    with pytest.raises(StorageError):
        actor.push('foo', 1)
예제 #10
0
def test_push():
    engine = LocalMemoryEngine()
    actor = ActorBase(engine, [], {})
    actor.push('foo', 1)
    assert actor.get('foo') == [1]
예제 #11
0
def test_pull_broken():
    engine = FaultyEngine()
    actor = ActorBase(engine, [], {})

    with pytest.raises(StorageError):
        list(actor.pull('foo'))
예제 #12
0
def test_pull():
    engine = LocalMemoryEngine()
    actor = ActorBase(engine, [], {})
    actor.push('foo', 1)
    assert list(actor.pull('foo')) == [1]