Skip to main content

automatically setups a cassandra instance in a temporary directory, and destroys it after testing

Project description

testing.cassandra automatically setups a cassandra instance in a temporary directory, and destroys it after testing

Install

Use easy_install (or pip):

$ easy_install testing.cassandra

And testing.cassandra requires Cassandra server.

Usage

Create Cassandra instance using testing.cassandra.Cassandra:

import testing.cassandra
cassandra = testing.cassandra.Cassandra()  # Lanuch new Cassandra server

import pycassa
conn = pycassa.pool.ConnectionPool('test', cassandra.server_list())
#
# do any tests using Cassandra...
#

del cassandra                           # Terminate Cassandra server

testing.cassandra automatically searchs for cassandra files in /usr/local/. If you install cassandra to other directory, set cassandra_home keyword:

# uses a copy of specified data directory of Cassandra.
cassandra = testing.cassandra.Cassandra(copy_data_from='/path/to/your/database')

testing.cassandra.Cassandra executes cassandra on instantiation. On deleting Cassandra object, it terminates Cassandra instance and removes temporary directory.

If you want a database including column families and any fixtures for your apps, use copy_data_from keyword:

# uses a copy of specified data directory of Cassandra.
cassandra = testing.cassandra.Cassandra(copy_data_from='/path/to/your/database')

You can specify parameters for Cassandra with cassandra_yaml keyword:

# boot Cassandra server listens on 12345 port
cassandra = testing.cassandra.Cassandra(cassandra_yaml={'rpc_port': 12345})

For example, you can setup new Cassandra server for each testcases on setUp() method:

import unittest
import testing.cassandra

class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.cassandra = testing.cassandra.Cassandra()

Requirements

  • Python 2.7

  • pycassa

  • PyYAML

License

Apache License 2.0

History

1.0.0 (2013-10-17)

  • First release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

testing.cassandra-1.0.0.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file testing.cassandra-1.0.0.tar.gz.

File metadata

File hashes

Hashes for testing.cassandra-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f09f5d9fd969df059b13d97a7abe1e64720b480bda0cc4af28471efc66b12043
MD5 4bf7be9e4e8762905b76e0b486aeff75
BLAKE2b-256 b95c71aca2398cf9c3cb5dff66f0ca95182ca448fcb87f7bdd2e28bd6e7ae485

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page