Ejemplo n.º 1
0
def test_expired():
    engine = LocalMemoryEngine()
    bucket = engine.bucket('loda.actors.builtin.hold')
    bucket.put('foo', 1577836800)
    helper = HoldingHelper(engine)
    assert not helper['foo']
    assert not helper['foo']
Ejemplo n.º 2
0
def test():
    engine = LocalMemoryEngine()
    bucket = engine.bucket('foo')
    bucket.put('foo', 'bar')

    bucket = engine.bucket('foo')
    assert bucket.has('foo')
    assert bucket.get('foo') == 'bar'

    bucket.push('items', 'one')
    assert list(bucket.pull('items')) == ['one']
    assert bucket.has('items', 'one')
    bucket.pop('items', 'one')
    assert not bucket.has('items', 'one')

    bucket.delete('items')
    assert not bucket.has('items')
Ejemplo n.º 3
0
def test_release():
    engine = LocalMemoryEngine()
    bucket = engine.bucket('loda.actors.builtin.hold')
    bucket.put('foo', 0)
    actor = Actor(engine, [], {})

    args, func = actor.match('release foo')
    func(*args)
    assert not bucket.has('foo')
Ejemplo n.º 4
0
def test_hold_value_until():
    engine = LocalMemoryEngine()
    actor = Actor(engine, [], {})

    args, func = actor.match('hold foo for until tomorrow')
    func(*args)

    bucket = engine.bucket('loda.actors.builtin.hold')
    assert bucket.get('foo') == 1577923200
Ejemplo n.º 5
0
def test_hold_value_for():
    engine = LocalMemoryEngine()
    actor = Actor(engine, [], {})

    args, func = actor.match('hold foo for 1 minute')
    func(*args)

    bucket = engine.bucket('loda.actors.builtin.hold')
    assert bucket.get('foo') == 1577836860
Ejemplo n.º 6
0
def test_future():
    engine = LocalMemoryEngine()
    bucket = engine.bucket('loda.actors.builtin.hold')
    bucket.put('foo', 1577923200)
    helper = HoldingHelper(engine)
    assert helper['foo']