Example #1
0
 def test_update_examiners_delete(self):
     manager = GroupManager(self.a1id)
     manager.group.save()
     manager.group.examiners.create(user=self.testhelper.user1)
     manager.group.examiners.create(user=self.testhelper.user2)
     manager.update_examiners([])
     examiners = manager.get_group_from_db().examiners.all()
     self.assertEquals(len(examiners), 0)
Example #2
0
 def test_update_examiners_complex(self):
     manager = GroupManager(self.a1id)
     manager.group.save()
     manager.group.examiners.create(user=self.testhelper.user1)
     manager.group.examiners.create(user=self.testhelper.user2)
     manager.update_examiners([self.create_examinerdict(id=self.testhelper.user1.id), # keep user1
                               # ... delete user2
                               self.create_examinerdict(username='******')]) # create user3
     examiners = manager.get_group_from_db().examiners.all()
     self.assertEquals(len(examiners), 2)
     ids = [examiner.id for examiner in examiners]
     self.assertEquals(set(ids),
                       set([self.testhelper.user1.id, self.testhelper.user3.id]))
Example #3
0
    def test_update_examiners_create(self):
        manager = GroupManager(self.a1id)
        manager.group.save()
        manager.update_examiners([self.create_examinerdict(username='******')])
        examiners = manager.get_group_from_db().examiners.all()
        self.assertEquals(len(examiners), 1)
        created = examiners[0]
        self.assertEquals(created.user.id, self.testhelper.user1.id)

        manager.update_examiners([self.create_examinerdict(id=created.id),
                                  self.create_examinerdict(username='******')])
        examiners = manager.get_group_from_db().examiners.all()
        self.assertEquals(len(examiners), 2)
        ids = [examiner.id for examiner in examiners]
        self.assertEquals(set(ids),
                          set([self.testhelper.user1.id, self.testhelper.user2.id]))
Example #4
0
 def test_update_examiners_create_duplicate(self):
     manager = GroupManager(self.a1id)
     manager.group.save()
     manager.group.examiners.create(user=self.testhelper.user1)
     with self.assertRaises(ValidationError):
         manager.update_examiners([self.create_examinerdict(username='******')])