Пример #1
0
 def test_life_cycle(self):
     kv_store = KeyValueClient('squirly.ca:9090')
     assert kv_store.put('my_value', 'test_data') is None
     assert kv_store.get('my_value').rstrip('\x00') == 'test_data'
     assert kv_store.put('my_value', 'another_test') is None
     assert kv_store.get('my_value').rstrip('\x00') == 'another_test'
     assert kv_store.delete('my_value') is None
     with pytest.raises(InvalidKeyError):
         kv_store.get('my_value')
     with pytest.raises(InvalidKeyError):
         kv_store.delete('my_value')
Пример #2
0
    def test_delete(self):
        kv_store = KeyValueClient('192.168.1.100:5665')
        socket = MockSocket(['\x00'])
        with patch('kvclient.base.create_connection', socket):
            response = kv_store.delete('test_key')

        assert socket.connection_info == ('192.168.1.100', 5665)
        assert socket.sent_value == '\x03' + 'test_key' + '\x00'*24
        assert response is None
        assert socket.closed
Пример #3
0
from kvclient import KeyValueClient, InvalidKeyError

SERVER = 'planetlab1.cs.unc.edu:5000'
KEY = '11'
VALUE = '1'

client = KeyValueClient(SERVER)
client.put(KEY, VALUE)
print(client.get(KEY))
client.delete(KEY)
try:
    print(client.get(KEY))
except InvalidKeyError, error:
    print(str(error))