PysandraUnit

Python wrapper around cassandra-unit that helps you write isolated unittests in Django and other python applications.

class pysandraunit.PysandraUnit(dataset_path=None, tmp_dir=None, rpc_port=None, native_transport_port=None, cassandra_yaml_options=None)

Construct a PysandraUnit object. Java server won’t be started yet

Parameters:
  • dataset_path – path to the dataset file. Check cassandra-unit docs for details
  • tmp_dir – path to the directory where PysandraUnit and Cassandra should create temporary files
  • rpc_port – Cassandra rpc port
  • native_transport_port – Cassandra native transport port
  • cassandra_yaml_options – dict of additional options passed to Cassandra in cassandra.yaml file
clean()

Cleans all Cassandra Keyspaces and reloads data if dataset is provided in constructor If server is not running, ‘PysandraUnitServerError’ exception will be raised

get_cassandra_host()

Returns Cassandra server host and rpc port in format: ‘localhost:9710’

load_data(dataset_path=None)

Load schema into Cassandra from dataset file If file isn’t provided the one from constructior will be used

Parameters:dataset_path – path to the dataset file. Check cassandra-unit docs for details
start()

Start Pysandra and Cassandra server, loads dataset file if provided in the constructor If server is already running, ‘PysandraUnitServerError’ exception will be raised

stop()

Stop Pysandra and Cassandra server if running

exception pysandraunit.PysandraUnitServerError

Previous topic

Welcome to pysandra-unit 0.4 documentation!

Next topic

Python unittest CassandraTestCase

This Page