コード例 #1
0
ファイル: test_groups.py プロジェクト: yonglehou/commcare-hq
    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)
コード例 #2
0
    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)
コード例 #3
0
 def save_all(self):
     Group.bulk_save(self.groups)
コード例 #4
0
 def save_all(self):
     Group.bulk_save(self.groups)
コード例 #5
0
ファイル: importer.py プロジェクト: soitun/commcare-hq
 def save_updated(self):
     updated = [self.groups_by_id[_id] for _id in self.updated_groups]
     Group.bulk_save(updated)
     self.updated_groups.clear()
コード例 #6
0
 def save_all(self):
     Group.bulk_save(self.groups, all_or_nothing=True)