예제 #1
0
    def test_increment(self):
        try:
            self.coll.remove("counter",quiet=True)
        except:
            pass
        self.coll.increment("counter", DeltaValue(0), initial=SignedInt64(43))
        self.assertEqual(43,self.coll.get("counter").content_as[int])
        self.coll.increment("counter", DeltaValue(1))
        self.assertEqual(44,self.coll.get("counter").content_as[int])

        self.coll.remove("counter")
        self.coll.upsert("counter", 43)
        self.coll.increment("counter", DeltaValue(1))
        self.assertEqual(44,self.coll.get("counter").content_as[int])

        self.assertRaises(couchbase.exceptions.ArgumentError, self.coll.increment, "counter", DeltaValue(5), initial=10)
        self.assertRaises(couchbase.exceptions.ArgumentError, self.coll.increment, "counter", 5)
        self.assertRaises(couchbase.exceptions.ArgumentError, self.coll.increment, "counter", -3)
예제 #2
0
 def test_unsigned_int(self):
     self.assertRaises(couchbase.exceptions.ArgumentError, DeltaValue, -1)
     self.assertRaises(couchbase.exceptions.ArgumentError, DeltaValue,
                       0x7FFFFFFFFFFFFFFF + 1)
     x = DeltaValue(5)
     self.assertEqual(5, x.value)