def test_dt_set_remove_updated_context(self): btype = self.client.bucket_type('sets') bucket = btype.bucket(self.bucket_name) set = datatypes.Set(bucket, self.key_name) set.add('X') set.add('Y') set.store() set_parallel = datatypes.Set(bucket, self.key_name) set_parallel.add('Z') set_parallel.store() set.reload() set.discard('Z') set.store() set2 = bucket.get(self.key_name) self.assertItemsEqual(['X', 'Y'], set2.value)
def test_dt_set_remove_without_context(self): btype = self.client.bucket_type('sets') bucket = btype.bucket(self.bucket_name) set = datatypes.Set(bucket, self.key_name) set.add("X") set.add("Y") set.add("Z") with self.assertRaises(datatypes.ContextRequired): set.discard("Y")
def test_dt_set_add_twice(self): btype = self.client.bucket_type('sets') bucket = btype.bucket(self.bucket_name) set = datatypes.Set(bucket, self.key_name) set.add('X') set.add('Y') set.store() set.reload() set.add('X') set.store() set2 = bucket.get(self.key_name) self.assertItemsEqual(['X', 'Y'], set2.value)
def test_dt_set_add_wins_in_same_op_reversed(self): btype = self.client.bucket_type('sets') bucket = btype.bucket(self.bucket_name) set = datatypes.Set(bucket, self.key_name) set.add('X') set.add('Y') set.store() set.reload() set.discard('X') set.add('X') set.store() set2 = bucket.get(self.key_name) self.assertItemsEqual(['X', 'Y'], set2.value)
def test_dt_set(self): btype = self.client.bucket_type('sets') bucket = btype.bucket(self.bucket_name) myset = datatypes.Set(bucket, self.key_name) myset.add('Sean') myset.add('Brett') myset.store() otherset = bucket.get(self.key_name) self.assertIn('Sean', otherset) self.assertIn('Brett', otherset) otherset.add('Russell') otherset.discard('Sean') otherset.store(return_body=True) myset.reload() self.assertIn('Russell', myset) self.assertIn('Brett', myset) self.assertNotIn('Sean', myset)