Skip to content

Latest commit

 

History

History
89 lines (67 loc) · 2.44 KB

README.rst

File metadata and controls

89 lines (67 loc) · 2.44 KB

Aerospike client mock for python

Join the chat at https://gitter.im/tivvit/aerospike-client-mock-python

https://api.travis-ci.org/tivvit/aerospike-client-mock-python.svg?branch=master

  • This mock supports all standard Aerospike python client operations except operations listed in todo section
  • Scan and query with where predicates also supported
  • Support for dumping cluster state to string or to dict
  • Follows http://pythonhosted.org/aerospike/

Install

pip install AerospikeClientMock

Example

from AerospikeClientMock import AerospikeClientMock

asm = AerospikeClientMock()
key = ("a", "b", "c")
asm.put(key, {"a": 1})
print asm.get(key)
asm.increment(key, "a", 2)
print asm.get(key)

# use string conversion for testing cluster state
print str(asm)
# or use to dict dump
print asm.dump()

With TTL

from AerospikeClientMock import AerospikeClientMock
import time

asm = AerospikeClientMock(default_ttl=2)
key = ("a", "b", "c")
asm.put(key, {"a": 1})
print asm.get(key)
time.sleep(4)
print asm.exists(key)

Query example

from AerospikeClientMock import AerospikeClientMock
from AerospikeClientMock import AerospikePredicatesMock

asm = AerospikeClientMock()
asm.put(("a", "b", 1), {"a": 1, "b": 1})
asm.put(("a", "b", 2), {"a": 2, "b": 2})
asm.put(("a", "b", 3), {"a": 3, "b": 3})
asm.put(("a", "c", 4), {"a": 4, "b": 4})
query = asm.query('a', 'b')
query.select('a', 'c')
query.where(AerospikePredicatesMock().equals("a", 1))
print query.results()

Todo

  • support for UDF scripts
  • llist

Development

Feel free to contribute.

Copyright and License

2015 Vít Listík

Released under MIT licence