def __init__(self, connection_class=Cluster, construct_primary_key=None, edge_model=None):
        super(CassandraRepository, self).__init__()

        self.settings = dict(host='localhost', port=9042, protocol_version=2)
        self.settings.update(Settings.get('db'))

        assert self.settings.get('name', None), 'Missing required setting db.name'

        if edge_model:
            self._edge_model = edge_model

        if not isinstance(self.settings.get('port'), int):
            self.settings['port'] = int(self.settings.get('port'))
        if not isinstance(self.settings.get('protocol_version'), int):
            self.settings['protocol_version'] = int(self.settings.get('protocol_version'))

        cluster = connection_class(
            contact_points=self.settings['host'],
            port=self.settings['port'],
            protocol_version=self.settings['protocol_version']
        )
        cluster.set_core_connections_per_host(HostDistance.LOCAL, 10)
        self.session = cluster.connect(keyspace=self.settings['name'])
        self.session.row_factory = ordered_dict_factory

        if construct_primary_key:
            self.construct_primary_key = construct_primary_key
Beispiel #2
0
__author__ = 'broken'


class PYSANDRASettings:
    PYSANDRA_SCHEMA_FILE_PATH = '/Users/broken/ef/development/furryninja-cassandra/test_config/cassandra.schema.cql'
    PYSANDRA_TMP_DIR = '/tmp/cassandratmp'
    PYSANDRA_CASSANDRA_YAML_OPTIONS = {}


CassandraTestCaseBase.set_global_settings(PYSANDRASettings)

Settings.set(
    'db', {
        'name': 'test_keyspace',
        'port': '9142',
        'host': ['localhost'],
        'protocol_version': 2,
        'consistency_level': ConsistencyLevel.SERIAL
    })

IMAGE_ASSET = {
    'name': 'Written speech',
    'description': 'Lorem ipsum dolor sit amet, consectetur adipisici elit',
    'title': 'Lorem Ipsum',
    'version': '42',
    'skills': ['flying', 'superpowers'],
    'publicationDate': {
        'year': 2000
    },
    'topics': ['G9dCxjCen-oJMYWaN2vjn18'],
    'attributes': {
 def _get_table_metadata(self, table_name):
     return self.session.cluster.metadata.keyspaces[Settings.get('db.name')].tables[table_name]
__author__ = 'broken'


class PYSANDRASettings:
    PYSANDRA_SCHEMA_FILE_PATH = '/Users/broken/ef/development/furryninja-cassandra/test_config/cassandra.schema.cql'
    PYSANDRA_TMP_DIR = '/tmp/cassandratmp'
    PYSANDRA_CASSANDRA_YAML_OPTIONS = {}

CassandraTestCaseBase.set_global_settings(PYSANDRASettings)


Settings.set('db', {
    'name': 'test_keyspace',
    'port': '9142',
    'host': ['localhost'],
    'protocol_version': 2,
    'consistency_level': ConsistencyLevel.SERIAL
})


IMAGE_ASSET = {
    'name': 'Written speech',
    'description': 'Lorem ipsum dolor sit amet, consectetur adipisici elit',
    'title': 'Lorem Ipsum',
    'version': '42',
    'skills': [
        'flying',
        'superpowers'
    ],
    'publicationDate': {