Beispiel #1
0
 def setUp(self):
     #Teacher
     self.adviser_teacher = test_adviser.create_adviser_from_scratch(
         username='******',
         email='*****@*****.**',
         password='******',
         type='PRF')
     #Manager
     self.adviser_manager = test_adviser.create_adviser_from_scratch(
         username='******',
         email='*****@*****.**',
         password='******',
         type='MGR')
     #Proposition Offer
     offer = test_offer.create_offer(title="TEST_OFFER")
     self.offer_proposition = test_offer_proposition.create_offer_proposition(
         acronym="TEST_OFFER_NOW", offer=offer)
     # Create multiple propositions dissertations
     self.teacher_propositon_dissertations = []
     self.manager_proposition_dissertations = []
     for x in range(0, 5):
         # Teacher proposition dissertation creation
         teacher_prop = test_proposition_dissertation.create_proposition_dissertation(
             title="Teacher proposition " + str(x),
             adviser=self.adviser_teacher,
             person=self.adviser_teacher.person,
             offer_proposition=self.offer_proposition)
         self.teacher_propositon_dissertations.append(teacher_prop)
         # Manager proposition dissertation creation
         manager_prop = test_proposition_dissertation.create_proposition_dissertation(
             title="Manager propostion " + str(x),
             adviser=self.adviser_manager,
             person=self.adviser_manager.person,
             offer_proposition=self.offer_proposition)
         self.manager_proposition_dissertations.append(manager_prop)
 def setUpTestData(cls):
     # Teacher
     cls.adviser_teacher = test_adviser.create_adviser_from_scratch(
         username='******', email='*****@*****.**',
         password='******', type='PRF')
     # Manager
     cls.adviser_manager = test_adviser.create_adviser_from_scratch(
         username='******', email='*****@*****.**',
         password='******', type='MGR')
     cls.teacher = AdviserTeacherFactory()
     cls.manager = AdviserManagerFactory()
     cls.education_group = EducationGroupFactory()
     cls.faculty_manager = FacultyAdviserFactory(adviser=cls.manager,
                                                 education_group=cls.education_group)
     cls.offer_proposition = test_offer_proposition.create_offer_proposition(acronym="TEST_OFFER_NOW",
                                                                             education_group=cls.education_group)
     cls.prop_diss = PropositionDissertationFactory(
         title="Teacher proposition ",
         author=cls.teacher,
         creator=cls.teacher.person)
     cls.prop_offer = PropositionOfferFactory(
         proposition_dissertation=cls.prop_diss,
         offer_proposition=cls.offer_proposition
     )
     cls.prop_role1 = PropositionRoleFactory(
         status="PROMOTEUR",
         adviser=cls.teacher,
         proposition_dissertation=cls.prop_diss
     )
     # Create multiple propositions dissertations
     cls.teacher_propositon_dissertations = []
     cls.manager_proposition_dissertations = []
     for x in range(0, 5):
         # Teacher proposition dissertation creation
         teacher_prop = test_proposition_dissertation.create_proposition_dissertation(
             title="Teacher proposition " + str(x),
             adviser=cls.adviser_teacher,
             person=cls.adviser_teacher.person,
             offer_proposition=cls.offer_proposition)
         cls.teacher_propositon_dissertations.append(teacher_prop)
         # Manager proposition dissertation creation
         manager_prop = test_proposition_dissertation.create_proposition_dissertation(
             title="Manager propostion " + str(x),
             adviser=cls.adviser_manager,
             person=cls.adviser_manager.person,
             offer_proposition=cls.offer_proposition)
         cls.manager_proposition_dissertations.append(manager_prop)
     cls.proposition_dissertation_deactivated = PropositionDissertationFactory(
         title="It's deactivated",
         active=False
     )
Beispiel #3
0
    def test_delete_jury_proposition_dissertations(self):
        self.client.login(username='******', password='******')
        proposition = self.teacher_propositon_dissertations[1]
        adviser = test_adviser.create_adviser_from_scratch(
            username='******',
            email='*****@*****.**',
            password='******',
            type='PRF')
        status = "CO_PROMOTEUR"
        proposition_role = test_proposition_role.create_proposition_role(
            proposition=proposition, adviser=adviser, status=status)
        nb_occurence = PropositionRole.objects.filter(
            proposition_dissertation=proposition).count()
        self.assertEqual(
            nb_occurence,
            2)  #teacher as "PROMOTEUR" AND thomas as "CO_PROMOTEUR"

        url = reverse('proposition_dissertations_role_delete',
                      args=[proposition_role.id])
        response = self.client.post(url)
        self.assertRedirects(
            response,
            reverse('proposition_dissertation_detail', args=[proposition.id]))
        nb_occurence_after_delete = PropositionRole.objects.filter(
            proposition_dissertation=proposition).count()
        self.assertEqual(nb_occurence_after_delete,
                         1)  # teacher as "PROMOTEUR"
Beispiel #4
0
    def test_post_new_jury_proposition_dissertations(self):
        self.client.login(username='******', password='******')
        proposition = self.teacher_propositon_dissertations[1]
        new_adviser = test_adviser.create_adviser_from_scratch(
            username='******',
            email='*****@*****.**',
            password='******',
            type='PRF')

        url = reverse('proposition_dissertations_jury_new',
                      args=[proposition.id])
        response = self.client.post(url,
                                    data={
                                        "status": 'PROMOTEUR',
                                        "adviser": new_adviser.id,
                                        "proposition_dissertation":
                                        proposition.id
                                    })
        self.assertRedirects(
            response,
            reverse('proposition_dissertation_detail', args=[proposition.id]))

        nb_occurence = PropositionRole.objects.filter(
            status="PROMOTEUR",
            adviser=new_adviser,
            proposition_dissertation=proposition).count()
        self.assertEqual(nb_occurence, 1)
Beispiel #5
0
    def test_post_max_new_jury_proposition_dissertations(self):
        self.client.login(username='******', password='******')
        proposition = self.teacher_propositon_dissertations[1]
        url = reverse('proposition_dissertations_jury_new',
                      args=[proposition.id])

        #PROMOTEUR
        new_adviser_1 = test_adviser.create_adviser_from_scratch(
            username='******',
            email='*****@*****.**',
            password='******',
            type='PRF')
        response = self.client.post(url,
                                    data={
                                        "status": 'PROMOTEUR',
                                        "adviser": new_adviser_1.id,
                                        "proposition_dissertation":
                                        proposition.id
                                    })
        self.assertRedirects(
            response,
            reverse('proposition_dissertation_detail', args=[proposition.id]))

        #CO_PROMOTEUR
        new_adviser_2 = test_adviser.create_adviser_from_scratch(
            username='******',
            email='*****@*****.**',
            password='******',
            type='PRF')
        response = self.client.post(url,
                                    data={
                                        "status": 'CO_PROMOTEUR',
                                        "adviser": new_adviser_2.id,
                                        "proposition_dissertation":
                                        proposition.id
                                    })
        self.assertRedirects(
            response,
            reverse('proposition_dissertation_detail', args=[proposition.id]))

        #READER
        new_adviser_3 = test_adviser.create_adviser_from_scratch(
            username='******',
            email='*****@*****.**',
            password='******',
            type='PRF')
        response = self.client.post(url,
                                    data={
                                        "status": 'READER',
                                        "adviser": new_adviser_3.id,
                                        "proposition_dissertation":
                                        proposition.id
                                    })
        self.assertRedirects(
            response,
            reverse('proposition_dissertation_detail', args=[proposition.id]))

        #ACCOMPANIST
        new_adviser_4 = test_adviser.create_adviser_from_scratch(
            username='******',
            email='*****@*****.**',
            password='******',
            type='PRF')
        response = self.client.post(url,
                                    data={
                                        "status": 'ACCOMPANIST',
                                        "adviser": new_adviser_4.id,
                                        "proposition_dissertation":
                                        proposition.id
                                    })
        self.assertRedirects(
            response,
            reverse('proposition_dissertation_detail', args=[proposition.id]))
        nb_occurence = PropositionRole.objects.filter(
            proposition_dissertation=proposition).count()
        self.assertEqual(nb_occurence, 4)

        #Try another add but must not pass
        new_adviser_5 = test_adviser.create_adviser_from_scratch(
            username='******',
            email='*****@*****.**',
            password='******',
            type='PRF')
        response = self.client.post(url,
                                    data={
                                        "status": 'PRESIDENT',
                                        "adviser": new_adviser_5.id,
                                        "proposition_dissertation":
                                        proposition.id
                                    })
        self.assertRedirects(
            response,
            reverse('proposition_dissertation_detail', args=[proposition.id]))
        nb_occurence = PropositionRole.objects.filter(
            proposition_dissertation=proposition).count()
        self.assertEqual(nb_occurence, 4)  #4 elem and not 5 (Max: 4) !