コード例 #1
0
    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()
コード例 #2
0
    def test_batch_mutate(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()

        db.batch_mutate([])
コード例 #3
0
  def test_batch_mutate(self):
    app_id = 'guestbook'
    transaction = 1
    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()

    db.batch_mutate(app_id, [], [], transaction)
コード例 #4
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))
コード例 #5
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')
コード例 #6
0
    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', [], [])
コード例 #7
0
    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', [], [], {})