Exemple #1
0
    def test_update_tags(self):
        manager = GroupManager(self.a1id)
        manager.group.save()
        manager.update_tags([self.create_tagdict('mytag')])
        tags = manager.get_group_from_db().tags.all()
        self.assertEquals(len(tags), 1)
        created = tags[0]
        self.assertEquals(created.tag, 'mytag')

        manager.update_tags([self.create_tagdict('tag1'),
                             self.create_tagdict('tag2')])
        tagsObjs = manager.get_group_from_db().tags.all()
        self.assertEquals(len(tagsObjs), 2)
        tags = [tagObj.tag for tagObj in tagsObjs]
        self.assertEquals(set(tags), set(['tag1', 'tag2']))
Exemple #2
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]))
Exemple #3
0
 def test_update_candidates_delete(self):
     manager = GroupManager(self.a1id)
     manager.group.save()
     manager.group.candidates.create(student=self.testhelper.user1)
     manager.group.candidates.create(student=self.testhelper.user2)
     manager.update_candidates([])
     candidates = manager.get_group_from_db().candidates.all()
     self.assertEquals(len(candidates), 0)
Exemple #4
0
 def test_update_candidates_create_candidate_id(self):
     manager = GroupManager(self.a1id)
     manager.group.save()
     manager.update_candidates([self.create_candidatedict(username='******',
                                                          candidate_id='secret')])
     candidates = manager.get_group_from_db().candidates.all()
     created = candidates[0]
     self.assertEquals(created.candidate_id, 'secret')
Exemple #5
0
    def test_update_candidates_create(self):
        manager = GroupManager(self.a1id)
        manager.group.save()
        manager.update_candidates([self.create_candidatedict(username='******')])
        candidates = manager.get_group_from_db().candidates.all()
        self.assertEquals(len(candidates), 1)
        created = candidates[0]
        self.assertEquals(created.student.id, self.testhelper.user1.id)
        self.assertEquals(created.candidate_id, None)

        manager.update_candidates([self.create_candidatedict(id=created.id),
                                   self.create_candidatedict(username='******')])
        candidates = manager.get_group_from_db().candidates.all()
        self.assertEquals(len(candidates), 2)
        ids = [candidate.id for candidate in candidates]
        self.assertEquals(set(ids),
                          set([self.testhelper.user1.id, self.testhelper.user2.id]))
Exemple #6
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)
Exemple #7
0
 def test_update_candidates_complex(self):
     manager = GroupManager(self.a1id)
     manager.group.save()
     manager.group.candidates.create(student=self.testhelper.user1)
     manager.group.candidates.create(student=self.testhelper.user2)
     manager.update_candidates([self.create_candidatedict(id=self.testhelper.user1.id), # keep user1
                               # ... delete user2
                               self.create_candidatedict(username='******')]) # create user3
     candidates = manager.get_group_from_db().candidates.all()
     self.assertEquals(len(candidates), 2)
     ids = [candidate.id for candidate in candidates]
     self.assertEquals(set(ids),
                       set([self.testhelper.user1.id, self.testhelper.user3.id]))
Exemple #8
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]))