def test_dt_map(self): btype = self.client.bucket_type('maps') bucket = btype.bucket(self.bucket_name) mymap = datatypes.Map(bucket, self.key_name) mymap.counters['a'].increment(2) mymap.registers['b'].assign('testing') mymap.flags['c'].enable() mymap.maps['d'][('e', 'set')].add('deep value') mymap.store() othermap = bucket.get(self.key_name) self.assertIn('a', othermap.counters) self.assertIn('b', othermap.registers) self.assertIn('c', othermap.flags) self.assertIn('d', othermap.maps) self.assertEqual(2, othermap.counters['a'].value) self.assertEqual('testing', othermap.registers['b'].value) self.assertTrue(othermap.flags['c'].value) self.assertEqual({('e', 'set'): frozenset(['deep value'])}, othermap.maps['d'].value) self.assertEqual(frozenset([]), othermap.sets['f'].value) othermap.sets['f'].add('thing1') othermap.sets['f'].add('thing2') del othermap.counters['a'] othermap.store(return_body=True) mymap.reload() self.assertNotIn('a', mymap.counters) self.assertIn('f', mymap.sets) self.assertItemsEqual(['thing1', 'thing2'], mymap.sets['f'].value)
def test_dt_map_remove_map_update_same_op(self): btype = self.client.bucket_type('maps') bucket = btype.bucket(self.bucket_name) map = datatypes.Map(bucket, self.key_name) map.maps['map'].sets['set'].add("X") map.maps['map'].sets['set'].add("Y") map.store() map.reload() del map.maps['map'] map.maps['map'].sets['set'].add("Z") map.store() map2 = bucket.get(self.key_name) self.assertItemsEqual(["Z"], map2.maps['map'].sets['set'])
def test_dt_map_remove_counter_increment_same_op(self): btype = self.client.bucket_type('maps') bucket = btype.bucket(self.bucket_name) map = datatypes.Map(bucket, self.key_name) map.counters['counter'].increment(5) map.store() map.reload() self.assertEqual(5, map.counters['counter'].value) map.counters['counter'].increment(2) del map.counters['counter'] map.store() map2 = bucket.get(self.key_name) self.assertEqual(2, map2.counters['counter'].value)