Adding stub objects for ColumnFamily, ConnectionPool, and SystemManager #185

merged 2 commits into from Jan 31, 2013

3 participants


A functional set of stubs to be used for unit testing.

Projects that use pycassa and need to run an automated unit test suite on a
system like Jenkins can use these stubs to emulate interactions with Cassandra
without spinning up a cluster locally.

Example usage:

>>> from pycassa.contrib.stubs import ColumnFamilyStub, ConnectionPoolStub
>>> p = ConnectionPoolStub('localhost')
>>> cf = ColumnFamilyStub(p, 'TestCF')
>>> 'TestCF' in p.column_families
>>> cf.insert(1234, {'test_column': 5})
>>> cf.insert(5678, {'test_column': 10}, timestamp=5678)
>>> cf.get(1234)
OrderedDict([('test_column', 5)])
>>> cf.get(5678)
OrderedDict([('test_column', 10)])
>>> cf.get(1234, include_timestamp=True)
OrderedDict([('test_column', (5, 1358375073016192))])
>>> cf.get(5678, include_timestamp=True)
OrderedDict([('test_column', (10, 5678))])
>>> from pycassa import index
>>> index_clause = index.create_index_clause([index.create_index_expression('test_column', 6, index.GT)])
>>> cf.get_indexed_slices(index_clause)
[(5678, OrderedDict([('test_column', 10)]))]
pycassa member

It would be really nice, if there would be tests for these stubs. Otherwise the stubs and real implementation/API might drift without anyone noticing.

@eyalr eyalr Adding unit tests for stubs that ensure the APIs and functionality li…
…ne up. Added some missing functionality to the stub objects as well, to make it more closely line up to the API.
@thobbs thobbs merged commit 957feee into pycassa:master Jan 31, 2013

1 check passed

Details default The Travis build passed
pycassa member

Great, thanks again for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment