def test_set_with_cas(self):
        key = self.gen_key('cas')
        rv1 = self.cb.upsert(key, 'value1')
        self.assertTrue(rv1.cas > 0)

        self.assertRaises(KeyExistsError, self.cb.upsert,
                          key, 'value2', cas=rv1.cas+1)

        rv2 = self.cb.upsert(key, 'value3', cas=rv1.cas)
        self.assertTrue(rv2.cas > 0)
        self.assertNotEqual(rv1.cas, rv2.cas)

        rv3 = self.cb.upsert(key, 'value4')
        self.assertTrue(rv3.cas > 0)
        self.assertNotEqual(rv3.cas, rv2.cas)
        self.assertNotEqual(rv3.cas, rv1.cas)
dataset/ETHPy150Open couchbase/couchbase-python-client/couchbase/tests/cases/set_t.py/UpsertTest.test_set_with_cas/original