Ejemplo n.º 1
0
def gets_test(host, port):
    client = Client((host, port))
    client.flush_all()

    result = client.gets('key')
    tools.assert_equal(result, (None, None))

    result = client.set('key', 'value', noreply=False)
    tools.assert_equal(result, 'STORED')
    result = client.gets('key')
    tools.assert_equal(result[0], 'value')
Ejemplo n.º 2
0
def test_gets(host, port, socket_module):
    client = Client((host, port), socket_module=socket_module)
    client.flush_all()

    result = client.gets(b'key')
    assert result == (None, None)

    result = client.set(b'key', b'value', noreply=False)
    assert result is True
    result = client.gets(b'key')
    assert result[0] == b'value'
def gets_test(host, port, socket_module):
    client = Client((host, port), socket_module=socket_module)
    client.flush_all()

    result = client.gets(b'key')
    tools.assert_equal(result, (None, None))

    result = client.set(b'key', b'value', noreply=False)
    tools.assert_equal(result, True)
    result = client.gets(b'key')
    tools.assert_equal(result[0], b'value')
Ejemplo n.º 4
0
def gets_test(host, port, socket_module):
    client = Client((host, port), socket_module=socket_module)
    client.flush_all()

    result = client.gets(b'key')
    tools.assert_equal(result, (None, None))

    result = client.set(b'key', b'value', noreply=False)
    tools.assert_equal(result, True)
    result = client.gets(b'key')
    tools.assert_equal(result[0], b'value')
Ejemplo n.º 5
0
def gets_test(host, port):
    client = Client((host, port))
    client.flush_all()

    result = client.gets('key')
    tools.assert_equal(result, (None, None))

    result = client.set('key', 'value', noreply=False)
    tools.assert_equal(result, True)
    result = client.gets('key')
    tools.assert_equal(result[0], 'value')
Ejemplo n.º 6
0
def test_cas(host, port, socket_module):
    client = Client((host, port), socket_module=socket_module)
    client.flush_all()

    result = client.cas(b'key', b'value', b'1', noreply=False)
    assert result is None

    result = client.set(b'key', b'value', noreply=False)
    assert result is True

    result = client.cas(b'key', b'value', b'1', noreply=False)
    assert result is False

    result, cas = client.gets(b'key')
    assert result == b'value'

    result = client.cas(b'key', b'value1', cas, noreply=False)
    assert result is True

    result = client.cas(b'key', b'value2', cas, noreply=False)
    assert result is False
Ejemplo n.º 7
0
def cas_test(host, port):
    client = Client((host, port))
    client.flush_all()

    result = client.cas('key', 'value', '1', noreply=False)
    tools.assert_equal(result, 'NOT_FOUND')

    result = client.set('key', 'value', noreply=False)
    tools.assert_equal(result, 'STORED')

    result = client.cas('key', 'value', '1', noreply=False)
    tools.assert_equal(result, 'EXISTS')

    result, cas = client.gets('key')
    tools.assert_equal(result, 'value')

    result = client.cas('key', 'value1', cas, noreply=False)
    tools.assert_equal(result, 'STORED')

    result = client.cas('key', 'value2', cas, noreply=False)
    tools.assert_equal(result, 'EXISTS')
Ejemplo n.º 8
0
def cas_test(host, port, socket_module):
    client = Client((host, port), socket_module=socket_module)
    client.flush_all()

    result = client.cas(b'key', b'value', b'1', noreply=False)
    tools.assert_equal(result, None)

    result = client.set(b'key', b'value', noreply=False)
    tools.assert_equal(result, True)

    result = client.cas(b'key', b'value', b'1', noreply=False)
    tools.assert_equal(result, False)

    result, cas = client.gets(b'key')
    tools.assert_equal(result, b'value')

    result = client.cas(b'key', b'value1', cas, noreply=False)
    tools.assert_equal(result, True)

    result = client.cas(b'key', b'value2', cas, noreply=False)
    tools.assert_equal(result, False)
Ejemplo n.º 9
0
def cas_test(host, port):
    client = Client((host, port))
    client.flush_all()

    result = client.cas('key', 'value', '1', noreply=False)
    tools.assert_equal(result, None)

    result = client.set('key', 'value', noreply=False)
    tools.assert_equal(result, True)

    result = client.cas('key', 'value', '1', noreply=False)
    tools.assert_equal(result, False)

    result, cas = client.gets('key')
    tools.assert_equal(result, 'value')

    result = client.cas('key', 'value1', cas, noreply=False)
    tools.assert_equal(result, True)

    result = client.cas('key', 'value2', cas, noreply=False)
    tools.assert_equal(result, False)
def cas_test(host, port, socket_module):
    client = Client((host, port), socket_module=socket_module)
    client.flush_all()

    result = client.cas(b'key', b'value', b'1', noreply=False)
    tools.assert_equal(result, None)

    result = client.set(b'key', b'value', noreply=False)
    tools.assert_equal(result, True)

    result = client.cas(b'key', b'value', b'1', noreply=False)
    tools.assert_equal(result, False)

    result, cas = client.gets(b'key')
    tools.assert_equal(result, b'value')

    result = client.cas(b'key', b'value1', cas, noreply=False)
    tools.assert_equal(result, True)

    result = client.cas(b'key', b'value2', cas, noreply=False)
    tools.assert_equal(result, False)
Ejemplo n.º 11
0
def cas_test(host, port):
    client = Client((host, port))
    client.flush_all()

    result = client.cas('key', 'value', '1', noreply=False)
    tools.assert_equal(result, None)

    result = client.set('key', 'value', noreply=False)
    tools.assert_equal(result, True)

    result = client.cas('key', 'value', '1', noreply=False)
    tools.assert_equal(result, False)

    result, cas = client.gets('key')
    tools.assert_equal(result, 'value')

    result = client.cas('key', 'value1', cas, noreply=False)
    tools.assert_equal(result, True)

    result = client.cas('key', 'value2', cas, noreply=False)
    tools.assert_equal(result, False)
Ejemplo n.º 12
0
def test_gets_found():
    client = Client(None)
    client.sock = MockSocket(['VALUE key 0 5 10\r\nvalue\r\nEND\r\n'])
    result = client.gets('key')
    tools.assert_equal(result, ('value', '10'))
Ejemplo n.º 13
0
def test_gets_not_found():
    client = Client(None)
    client.sock = MockSocket(['END\r\n'])
    result = client.gets('key')
    tools.assert_equal(result, (None, None))
Ejemplo n.º 14
0
def test_gets_found():
    client = Client(None)
    client.sock = MockSocket(['VALUE key 0 5 10\r\nvalue\r\nEND\r\n'])
    result = client.gets('key')
    tools.assert_equal(result, ('value', '10'))
Ejemplo n.º 15
0
def test_gets_not_found():
    client = Client(None)
    client.sock = MockSocket(['END\r\n'])
    result = client.gets('key')
    tools.assert_equal(result, (None, None))