Skip to content

tivvit/aerospike-client-mock-python

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

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

About

Aerospike client mock for python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages