Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Jan 31, 2013

Conversation

Projects
None yet
3 participants
Contributor

eyalr commented Jan 18, 2013

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
True
>>> 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)]))]
Owner

hannosch commented Jan 20, 2013

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.

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 added a commit that referenced this pull request Jan 31, 2013

Merge pull request #185 from eventbrite/stubs
Adding stub objects for ColumnFamily, ConnectionPool, and SystemManager

@thobbs thobbs merged commit 957feee into pycassa:master Jan 31, 2013

1 check passed

default The Travis build passed
Details
Owner

thobbs commented Jan 31, 2013

Great, thanks again for the contribution!

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