def testConstructor(self): flexmock(file_io) \ .should_receive('read') \ .and_return('127.0.0.1') flexmock(Cluster).should_receive('connect').\ and_return(flexmock(execute=lambda x: None)) db = cassandra_interface.DatastoreProxy()
def testConstructor(self): flexmock(helper_functions) \ .should_receive('read_file') \ .and_return('127.0.0.1') flexmock(pycassa).should_receive("ConnectionPool") \ .and_return(FakePool()) db = cassandra_interface.DatastoreProxy()
def primed(): """ Check if the required keyspace and tables are present. Returns: A boolean indicating that Cassandra has been primed. """ try: db_access = cassandra_interface.DatastoreProxy() except cassandra.InvalidRequest: return False return db_access.get_metadata(cassandra_interface.PRIMED_KEY) == 'true'
def testGet(self): flexmock(helper_functions) \ .should_receive('read_file') \ .and_return('127.0.0.1') flexmock(pycassa).should_receive("ConnectionPool") \ .and_return(FakePool()) db = cassandra_interface.DatastoreProxy() # Make sure no exception is thrown assert {} == db.batch_get_entity('table', [], [])
def testRangeQuery(self): flexmock(helper_functions) \ .should_receive('read_file') \ .and_return('127.0.0.1') flexmock(pycassa) \ .should_receive("ColumnFamily") \ .and_return(FakeColumnFamily()) db = cassandra_interface.DatastoreProxy() assert [] == db.range_query("table", [], "start", "end", 0)
def testRangeQuery(self): flexmock(file_io) \ .should_receive('read') \ .and_return('127.0.0.1') flexmock(Cluster).should_receive('connect').\ and_return(flexmock(execute=lambda x, **y: [])) db = cassandra_interface.DatastoreProxy() self.assertListEqual([], db.range_query("table", [], "start", "end", 0))
def testDeleteTable(self): flexmock(file_io) \ .should_receive('read') \ .and_return('127.0.0.1') flexmock(Cluster).should_receive('connect').\ and_return(flexmock(execute=lambda x: None)) db = cassandra_interface.DatastoreProxy() # Make sure no exception is thrown db.delete_table('table')
def testGet(self): flexmock(file_io) \ .should_receive('read') \ .and_return('127.0.0.1') flexmock(Cluster).should_receive('connect').\ and_return(flexmock(execute=lambda x, **y: [])) db = cassandra_interface.DatastoreProxy() # Make sure no exception is thrown assert {} == db.batch_get_entity('table', [], [])
def testDeleteTable(self): flexmock(helper_functions) \ .should_receive('read_file') \ .and_return('127.0.0.1') flexmock(pycassa.system_manager) \ .should_receive("SystemManager") \ .and_return(FakeSystemManager()) db = cassandra_interface.DatastoreProxy() # Make sure no exception is thrown db.delete_table('table')
def testPut(self): flexmock(helper_functions) \ .should_receive('read_file') \ .and_return('127.0.0.1') flexmock(pycassa) \ .should_receive("ColumnFamily") \ .and_return(FakeColumnFamily()) db = cassandra_interface.DatastoreProxy() # Make sure no exception is thrown assert None == db.batch_put_entity('table', [], [], {})
def testPut(self): flexmock(file_io) \ .should_receive('read') \ .and_return('127.0.0.1') session = flexmock(prepare=lambda x: '', execute=lambda x: None) flexmock(BatchStatement).should_receive('add') flexmock(Cluster).should_receive('connect').\ and_return(session) db = cassandra_interface.DatastoreProxy() # Make sure no exception is thrown assert None == db.batch_put_entity('table', [], [], {})
def primed(): """ Check if the required keyspace and tables are present. Returns: A boolean indicating that Cassandra has been primed. """ try: db_access = cassandra_interface.DatastoreProxy() except cassandra.InvalidRequest: return False try: primed_version = db_access.get_metadata(cassandra_interface.PRIMED_KEY) return primed_version == str(CURRENT_VERSION) finally: db_access.close()
def setUp(self): self.cass = cassandra_interface.DatastoreProxy() self.cass.create_table(TEST3_TABLE, TEST3_TABLE_SCHEMA)