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

drone.io CI build status Latest PyPI version Number of PyPI downloads

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 pycassa
import testing.cassandra

# Launch new Cassandra server
with testing.cassandra.Cassandra as cassandra:
    conn = pycassa.pool.ConnectionPool('test', cassandra.server_list())
    #
    # do any tests using Cassandra...
    #

# Cassandra server is terminated here

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()

    def tearDown(self):
        self.cassandra.stop()

Requirements

  • Cassandra 1.1, 1.2, 2.0

  • Python 2.6, 2.7

  • pycassa

  • PyYAML

License

Apache License 2.0

History

1.1.2 (2014-06-11)

  • Fix ImportError if caught SIGINT on py3

1.1.1 (2013-12-06)

  • Suport Cassandra 2.0.x

  • Fix Cassandra#stop() causes OSError (at destructing object)

1.1.0 (2013-12-06)

  • Support Cassandra 1.2.x

  • Support python 2.6

  • Add cassandra.skipIfNotInstalled decorator

  • Change behavior: Cassandra#stop() cleans workdir

  • Fix workdir does not removed if cassandra does not started

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.1.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

testing.cassandra-1.1.2-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for testing.cassandra-1.1.2.tar.gz
Algorithm Hash digest
SHA256 50ff80a21de29e5e8f8abfe6b7b0d436ba7401781337090d8b9b397cbce0be08
MD5 d8b4f39e8b5e14a4e932e4f053797670
BLAKE2b-256 a381b6501e37f42ed0cd6372ca99e85cbf13f83a19812d3614fc87296344fe20

See more details on using hashes here.

File details

Details for the file testing.cassandra-1.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for testing.cassandra-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 390cc195df0375b492f986a940f1fb7edd6bb6fbab4ed5d52feba2eb2cc8bddc
MD5 64d4d8ab1cf550a13c71411f4f1ef2c7
BLAKE2b-256 6549ce9619cf9215123ce7336998fa3feefd3fb10de0e1e3edfa758ec17d6be8

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