def test_bulk_save(self): group1 = Group(domain=DOMAIN, name='group1', users=[ self.active_user._id, self.inactive_user._id, self.deleted_user._id ]) group1.save() group2 = Group(domain=DOMAIN, name='group2', users=[ self.active_user._id, self.inactive_user._id, self.deleted_user._id ]) group2.save() group1.remove_user(self.active_user._id, save=False) group2.remove_user(self.deleted_user._id, save=False) g1_old_modified = group1.last_modified g2_old_modified = group2.last_modified Group.bulk_save([group1, group2]) group1_updated = Group.get(group1.get_id) group2_updated = Group.get(group2.get_id) self.assertNotEqual(g1_old_modified, group1_updated.last_modified) self.assertNotEqual(g2_old_modified, group2_updated.last_modified)
def test_bulk_save(self): group1 = Group(domain=DOMAIN, name='group1', users=[self.active_user._id, self.inactive_user._id, self.deleted_user._id]) group1.save() group2 = Group(domain=DOMAIN, name='group2', users=[self.active_user._id, self.inactive_user._id, self.deleted_user._id]) group2.save() group1.remove_user(self.active_user._id, save=False) group2.remove_user(self.deleted_user._id, save=False) g1_old_modified = group1.last_modified g2_old_modified = group2.last_modified Group.bulk_save([group1, group2]) group1_updated = Group.get(group1.get_id) group2_updated = Group.get(group2.get_id) self.assertNotEqual(g1_old_modified, group1_updated.last_modified) self.assertNotEqual(g2_old_modified, group2_updated.last_modified)
def save_all(self): Group.bulk_save(self.groups)
def save_updated(self): updated = [self.groups_by_id[_id] for _id in self.updated_groups] Group.bulk_save(updated) self.updated_groups.clear()
def save_all(self): Group.bulk_save(self.groups, all_or_nothing=True)