Ejemplo n.º 1
0
class PhdSupervisorReviewViewTestCase(TestCase):
    def setUp(self):
        self.factory = RequestFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.phd_supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(
            supervisor=self.phd_supervisor)
        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year, assistant=self.assistant)
        self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
        self.assistant_mandate.save()
        self.review = ReviewFactory(reviewer=None,
                                    mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)

    def test_generate_phd_supervisor_menu_tabs(self):
        self.client.force_login(self.phd_supervisor)
        # Review has not been completed -> supervisor can edit
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(self.assistant_mandate, None),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': '',
                'action': 'edit'
            }])
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(
                self.assistant_mandate,
                assistant_mandate_state.PHD_SUPERVISOR),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': 'active',
                'action': 'edit'
            }])
        # Review has been completed -> supervisor can only view his review
        self.review.status = review_status.DONE
        self.review.save()
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(self.assistant_mandate, None),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': '',
                'action': 'view'
            }])
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(
                self.assistant_mandate,
                assistant_mandate_state.PHD_SUPERVISOR),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': 'active',
                'action': 'view'
            }])
Ejemplo n.º 2
0
    def setUp(self):

        self.factory = RequestFactory()
        self.client = Client()
        self.settings = SettingsFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.current_academic_year.save()
        self.phd_supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(
            supervisor=self.phd_supervisor)

        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH)
        self.assistant_mandate2 = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH)
        self.phd_supervisor_review = ReviewFactory(
            reviewer=None,
            mandate=self.assistant_mandate,
            status=review_status.DONE)
        self.entity_version = EntityVersionFactory(
            entity_type=entity_type.INSTITUTE)
        self.entity_mandate = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version.entity)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate2,
            entity=self.entity_version.entity)
        self.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=self.entity_version.entity)
        self.review = ReviewFactory(reviewer=self.reviewer,
                                    mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)
        self.entity_version2 = EntityVersionFactory(
            entity_type=entity_type.FACULTY)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version2.entity)
        self.reviewer2 = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                         entity=self.entity_version2.entity)
        self.entity_version3 = EntityVersionFactory(
            entity_type=entity_type.SECTOR)
        self.entity_mandate3 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version3.entity)
        self.reviewer3 = ReviewerFactory(role=reviewer_role.VICE_RECTOR,
                                         entity=self.entity_version3.entity)
 def test_mandate_can_go_backward(self):
     self.assertTrue(mandate_can_go_backward(self.assistant_mandate))
     self.assistant_mandate.state = assistant_mandate_state.RESEARCH
     self.assistant_mandate.save()
     self.review1 = ReviewFactory(reviewer=self.reviewer1,
                                  mandate=self.assistant_mandate,
                                  status=review_status.IN_PROGRESS)
     self.assertFalse(mandate_can_go_backward(self.assistant_mandate))
     self.review1.delete()
     self.assistant_mandate.state = assistant_mandate_state.TO_DO
     self.assistant_mandate.save()
     self.assertFalse(mandate_can_go_backward(self.assistant_mandate))
Ejemplo n.º 4
0
 def test_validate_review_and_update_mandate(self):
     validate_review_and_update_mandate(self.review, self.assistant_mandate)
     self.assertEqual(self.review.status, review_status.DONE)
     self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.SUPERVISION)
     self.review2 = ReviewFactory(reviewer=self.reviewer2, mandate=self.assistant_mandate,
                                 status=review_status.IN_PROGRESS)
     validate_review_and_update_mandate(self.review2, self.assistant_mandate)
     self.assertEqual(self.review2.status, review_status.DONE)
     self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.VICE_RECTOR)
     self.review3 = ReviewFactory(reviewer=self.reviewer3, mandate=self.assistant_mandate,
                                  status=review_status.IN_PROGRESS)
     validate_review_and_update_mandate(self.review3, self.assistant_mandate)
     self.assertEqual(self.review3.status, review_status.DONE)
     self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.DONE)
 def test_assistant_mandate_step_back_from_done_to_vice_rector(self):
     self.review4 = ReviewFactory(reviewer=self.reviewer3,
                                  mandate=self.assistant_mandate2,
                                  status=review_status.DONE)
     self.review5 = ReviewFactory(reviewer=self.reviewer2,
                                  mandate=self.assistant_mandate2,
                                  status=review_status.DONE)
     self.assistant_mandate2.state = assistant_mandate_state.DONE
     self.assistant_mandate2.save()
     self.client.post(reverse('assistant_mandate_step_back'),
                      {'mandate_id': self.assistant_mandate2.id})
     self.assistant_mandate2.refresh_from_db()
     self.assertEqual(self.assistant_mandate2.state,
                      assistant_mandate_state.VICE_RECTOR)
    def setUpTestData(cls):
        cls.settings = SettingsFactory()

        cls.current_academic_year = AcademicYearFactory(current=True)
        cls.assistant_mandate = AssistantMandateFactory(
            academic_year=cls.current_academic_year,
            state=assistant_mandate_state.PHD_SUPERVISOR)
        cls.review = ReviewFactory(reviewer=None,
                                   mandate=cls.assistant_mandate,
                                   status=review_status.IN_PROGRESS)

        cls.institute = EntityVersionFactory(entity_type=entity_type.INSTITUTE,
                                             end_date=None)
        cls.institute_child = EntityVersionFactory(parent=cls.institute.entity,
                                                   end_date=None)
        cls.school = EntityVersionFactory(entity_type=entity_type.SCHOOL,
                                          end_date=None)
        cls.sector = EntityVersionFactory(entity_type=entity_type.SECTOR)
        cls.faculty = EntityVersionFactory(entity_type=entity_type.FACULTY)

        cls.mandate_entity = MandateEntityFactory(
            assistant_mandate=cls.assistant_mandate,
            entity=cls.institute.entity)
        cls.research_reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                                entity=cls.institute.entity)
        cls.research_assistant_reviewer = ReviewerFactory(
            role=reviewer_role.RESEARCH_ASSISTANT,
            entity=cls.institute_child.entity)
        cls.vice_sector_reviewer = ReviewerFactory(
            role=reviewer_role.VICE_RECTOR, entity=cls.school.entity)
        cls.supervision_reviewer = ReviewerFactory(
            role=reviewer_role.SUPERVISION, entity=cls.faculty.entity)

        cls.delegate = PersonFactory()
        cls.delegate2 = PersonFactory()
    def setUpTestData(cls):
        cls.settings = SettingsFactory()

        cls.previous_academic_year, cls.current_academic_year, _ = AcademicYearFactory.produce(
        )
        cls.phd_supervisor = PersonFactory()
        cls.assistant = AcademicAssistantFactory(supervisor=cls.phd_supervisor)
        cls.assistant_mandate = AssistantMandateFactory(
            academic_year=cls.current_academic_year,
            assistant=cls.assistant,
            state=assistant_mandate_state.PHD_SUPERVISOR)
        cls.assistant2 = AcademicAssistantFactory(supervisor=None)
        cls.assistant_mandate2 = AssistantMandateFactory(
            academic_year=cls.current_academic_year,
            assistant=cls.assistant2,
            state=assistant_mandate_state.RESEARCH,
        )
        cls.review = ReviewFactory(reviewer=None,
                                   mandate=cls.assistant_mandate,
                                   status=review_status.IN_PROGRESS)
        cls.entity_version = EntityVersionFactory(
            entity_type=entity_type.INSTITUTE, end_date=None)
        cls.mandate_entity = MandateEntityFactory(
            assistant_mandate=cls.assistant_mandate,
            entity=cls.entity_version.entity)
        cls.mandate_entity2 = MandateEntityFactory(
            assistant_mandate=cls.assistant_mandate2,
            entity=cls.entity_version.entity)

        cls.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                       entity=cls.entity_version.entity,
                                       person=cls.phd_supervisor)
    def setUp(self):
        self.factory = RequestFactory()
        self.client = Client()
        self.settings = SettingsFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.phd_supervisor = PersonFactory()

        self.assistant = AcademicAssistantFactory(
            supervisor=self.phd_supervisor)
        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year, assistant=self.assistant)
        self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
        self.assistant_mandate.save()
        self.review = ReviewFactory(reviewer=None,
                                    mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)
        self.entity_version = EntityVersionFactory(
            entity_type=entity_type.INSTITUTE)
        self.mandate_entity = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version.entity)
Ejemplo n.º 9
0
    def setUpTestData(cls):
        cls.person2 = PersonFactory()
        cls.manager = ManagerFactory()
        cls.person = cls.manager.person
        cls.entity_factory = EntityFactory()
        cls.entity_factory2 = EntityFactory()
        cls.entity_version = EntityVersionFactory(entity_type=entity_type.INSTITUTE,
                                                  end_date=None,
                                                  entity=cls.entity_factory)
        cls.entity_version2 = EntityVersionFactory(entity_type=entity_type.INSTITUTE,
                                                   end_date=None,
                                                   entity=cls.entity_factory2)
        cls.phd_supervisor = PersonFactory()

        cls.assistant = AcademicAssistantFactory(supervisor=cls.phd_supervisor)
        today = datetime.date.today()
        cls.current_academic_year = AcademicYearFactory(start_date=today,
                                                        end_date=today.replace(year=today.year + 1),
                                                        year=today.year)
        cls.assistant_mandate = AssistantMandateFactory(academic_year=cls.current_academic_year,
                                                        assistant=cls.assistant)
        cls.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH_ASSISTANT,
                                       entity=cls.entity_version.entity)
        cls.reviewer2 = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=cls.entity_version.entity)
        cls.reviewer3 = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=cls.entity_version.entity)
        cls.review = ReviewFactory(reviewer=cls.reviewer2)
        cls.formset = formset_factory(ReviewersFormset)
        cls.current_academic_year = AcademicYearFactory(start_date=today,
                                                        end_date=today.replace(year=today.year + 1),
                                                        year=today.year)
Ejemplo n.º 10
0
 def setUp(self):
     self.maxDiff = None
     self.factory = RequestFactory()
     self.assistant = AcademicAssistantFactory(
         phd_inscription_date=datetime.date(2015, 10, 2),
         thesis_title='Data fitting on manifolds',
         confirmation_test_date=datetime.date(2017, 9, 25),
         remark=
         "Deux co-promoteurs (l'application ne m'autorise à n'en renseigner qu'un)"
     )
     self.mandate = AssistantMandateFactory(
         assistant=self.assistant,
         assistant_type=assistant_type.ASSISTANT,
         sap_id='1120019',
         entry_date=datetime.date(2012, 9, 15),
         end_date=datetime.date(2018, 9, 14),
         contract_duration='6 ans',
         contract_duration_fte='6 ans',
         fulltime_equivalent=1,
         other_status=None,
         renewal_type=assistant_mandate_renewal.NORMAL,
         justification=None,
         external_contract='',
         external_functions='',
     )
     self.entity_version = EntityVersionFactory()
     self.mandate_entity = MandateEntityFactory(
         assistant_mandate=self.mandate, entity=self.entity_version.entity)
     self.reviewer = ReviewerFactory(entity=self.mandate_entity.entity)
     self.styles = getSampleStyleSheet()
     self.review1 = ReviewFactory(mandate=self.mandate,
                                  reviewer=self.reviewer)
Ejemplo n.º 11
0
 def setUp(self):
     self.factory = RequestFactory()
     today = datetime.date.today()
     self.current_academic_year = AcademicYearFactory(
         start_date=today,
         end_date=today.replace(year=today.year + 1),
         year=today.year)
     self.phd_supervisor = PersonFactory()
     self.assistant = AcademicAssistantFactory(
         supervisor=self.phd_supervisor)
     self.assistant_mandate = AssistantMandateFactory(
         academic_year=self.current_academic_year, assistant=self.assistant)
     self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
     self.assistant_mandate.save()
     self.review = ReviewFactory(reviewer=None,
                                 mandate=self.assistant_mandate,
                                 status=review_status.IN_PROGRESS)
 def test_assistant_mandate_step_back_from_institute_president_to_php_supervisor(
         self):
     self.assistant.supervisor = PersonFactory()
     self.assistant.save()
     self.review1 = ReviewFactory(reviewer=self.reviewer1,
                                  mandate=self.assistant_mandate,
                                  status=review_status.DONE)
     self.review2 = ReviewFactory(reviewer=None,
                                  mandate=self.assistant_mandate,
                                  status=review_status.DONE)
     self.assistant_mandate.state = assistant_mandate_state.RESEARCH
     self.assistant_mandate.save()
     self.client.post(reverse('assistant_mandate_step_back'),
                      {'mandate_id': self.assistant_mandate.id})
     self.assistant_mandate.refresh_from_db()
     self.assertEqual(self.assistant_mandate.state,
                      assistant_mandate_state.PHD_SUPERVISOR)
    def setUp(self):

        self.factory = RequestFactory()
        self.client = Client()
        self.settings = SettingsFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(start_date=today,
                                                         end_date=today.replace(year=today.year + 1),
                                                         year=today.year)
        self.current_academic_year.save()
        self.phd_supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(supervisor=self.phd_supervisor)

        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH
        )
        self.assistant_mandate2 = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH
        )
        self.phd_supervisor_review = ReviewFactory(
            reviewer=None,
            mandate=self.assistant_mandate,
            status=review_status.DONE
        )
        self.entity_version = EntityVersionFactory(entity_type=entity_type.INSTITUTE)
        self.entity_mandate = MandateEntityFactory(assistant_mandate=self.assistant_mandate,
                                                   entity=self.entity_version.entity)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate2,
            entity=self.entity_version.entity
        )
        self.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=self.entity_version.entity)
        self.review = ReviewFactory(reviewer=self.reviewer, mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)
        self.entity_version2 = EntityVersionFactory(entity_type=entity_type.FACULTY)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version2.entity
        )
        self.reviewer2 = ReviewerFactory(
            role=reviewer_role.SUPERVISION,
            entity=self.entity_version2.entity
        )
        self.entity_version3 = EntityVersionFactory(entity_type=entity_type.SECTOR)
        self.entity_mandate3 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version3.entity
        )
        self.reviewer3 = ReviewerFactory(
            role=reviewer_role.VICE_RECTOR,
            entity=self.entity_version3.entity
        )
    def setUp(self):
        self.mandate = AssistantMandateFactory(
            assistant=self.assistant,
            assistant_type=assistant_type.ASSISTANT,
            sap_id='1120019',
            entry_date=datetime.date(self.current_academic_year.year - 6, 9,
                                     15),
            end_date=datetime.date(self.current_academic_year.year, 9, 24),
            contract_duration='6 ans',
            contract_duration_fte='6 ans',
            fulltime_equivalent=1,
            other_status=None,
            renewal_type=assistant_mandate_renewal.NORMAL,
            justification=None,
            external_contract='',
            external_functions='',
            state=assistant_mandate_state.TO_DO)

        self.mandate2 = AssistantMandateFactory(
            state=assistant_mandate_state.DECLINED,
            academic_year=self.current_academic_year)
        self.mandate3 = AssistantMandateFactory(
            state=assistant_mandate_state.DECLINED,
            academic_year=self.current_academic_year)
        self.tutoring_learning_unit_year = TutoringLearningUnitYearFactory(
            mandate=self.mandate)
        self.review3 = ReviewFactory(mandate=self.mandate, reviewer=None)
        self.entity_version = EntityVersionFactory()
        self.mandate_entity = MandateEntityFactory(
            assistant_mandate=self.mandate, entity=self.entity_version.entity)
        self.entity_version2 = EntityVersionFactory(
            entity_type=entity_type.FACULTY, end_date=None)
        self.mandate_entity2 = MandateEntityFactory(
            assistant_mandate=self.mandate, entity=self.entity_version2.entity)
        self.reviewer = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                        entity=self.mandate_entity.entity)

        self.reviewer2 = ReviewerFactory(entity=self.mandate_entity2.entity)
        self.review1 = ReviewFactory(mandate=self.mandate,
                                     reviewer=self.reviewer)
        self.review2 = ReviewFactory(mandate=self.mandate,
                                     reviewer=self.reviewer2,
                                     status=review_status.IN_PROGRESS)
        self.review3 = ReviewFactory(mandate=self.mandate, reviewer=None)
 def test_assistant_mandate_step_back_from_dean_of_faculty_to_institute_president(
         self):
     self.research_review = ReviewFactory(mandate=self.assistant_mandate,
                                          reviewer=self.reviewer1)
     self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
     self.assistant_mandate.save()
     self.client.post(reverse('assistant_mandate_step_back'),
                      {'mandate_id': self.assistant_mandate.id})
     self.assistant_mandate.refresh_from_db()
     self.assertEqual(self.assistant_mandate.state,
                      assistant_mandate_state.RESEARCH)
 def test_assistant_mandate_step_back_from_vice_rector_to_dean_of_faculty(
         self):
     self.supervision_review = ReviewFactory(mandate=self.assistant_mandate,
                                             reviewer=self.reviewer2)
     self.assistant_mandate.state = assistant_mandate_state.VICE_RECTOR
     self.assistant_mandate.save()
     self.client.post(reverse('assistant_mandate_step_back'),
                      {'mandate_id': self.assistant_mandate.id})
     self.assistant_mandate.refresh_from_db()
     self.assertEqual(self.assistant_mandate.state,
                      assistant_mandate_state.SUPERVISION)
 def test_assistant_mandate_step_back_from_dean_of_faculty_to_assistant(
         self):
     # Test if assistant is teaching assistant
     self.research_review = ReviewFactory(mandate=self.assistant_mandate,
                                          reviewer=self.reviewer1)
     self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
     self.assistant_mandate.save()
     self.client.post(reverse('assistant_mandate_step_back'),
                      {'mandate_id': self.assistant_mandate2.id})
     self.assistant_mandate2.refresh_from_db()
     self.assertEqual(self.assistant_mandate2.state,
                      assistant_mandate_state.TRTS)
 def setUp(self):
     self.assistant_mandate = AssistantMandateFactory(
         academic_year=self.current_academic_year,
         assistant=self.assistant,
         state=assistant_mandate_state.RESEARCH
     )
     self.phd_supervisor_review = ReviewFactory(
         reviewer=None,
         mandate=self.assistant_mandate,
         status=review_status.DONE
     )
     self.entity_mandate = MandateEntityFactory(assistant_mandate=self.assistant_mandate,
                                                entity=self.entity_version.entity)
     self.review = ReviewFactory(reviewer=self.reviewer, mandate=self.assistant_mandate,
                                 status=review_status.IN_PROGRESS)
     self.entity_mandate2 = MandateEntityFactory(
         assistant_mandate=self.assistant_mandate,
         entity=self.entity_version2.entity
     )
     self.entity_mandate3 = MandateEntityFactory(
         assistant_mandate=self.assistant_mandate,
         entity=self.entity_version3.entity
     )
 def test_mandate_can_go_backward(self):
     self.assertTrue(mandate_can_go_backward(self.assistant_mandate))
     self.assistant_mandate.state = assistant_mandate_state.RESEARCH
     self.assistant_mandate.save()
     self.review1 = ReviewFactory(
         reviewer=self.reviewer1,
         mandate=self.assistant_mandate,
         status=review_status.IN_PROGRESS
     )
     self.assertFalse(mandate_can_go_backward(self.assistant_mandate))
     self.review1.delete()
     self.assistant_mandate.state = assistant_mandate_state.TO_DO
     self.assistant_mandate.save()
     self.assertFalse(mandate_can_go_backward(self.assistant_mandate))
Ejemplo n.º 20
0
 def test_generate_phd_supervisor_menu_tabs(self):
     self.client.force_login(self.reviewer.person.user)
     self.assertEqual([{
         'action': 'view',
         'class': '',
         'item': 'PHD_SUPERVISOR'
     }, {
         'item': 'RESEARCH',
         'class': '',
         'action': 'edit'
     }],
                      generate_reviewer_menu_tabs(reviewer_role.RESEARCH,
                                                  self.assistant_mandate,
                                                  None))
     self.review.status = review_status.DONE
     self.review.save()
     self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
     self.assistant_mandate.save()
     self.review2 = ReviewFactory(reviewer=self.reviewer2,
                                  mandate=self.assistant_mandate,
                                  status=review_status.IN_PROGRESS)
     self.assertEqual([{
         'action': 'view',
         'class': '',
         'item': 'PHD_SUPERVISOR'
     }, {
         'item': 'RESEARCH',
         'class': 'active',
         'action': 'view'
     }],
                      generate_reviewer_menu_tabs(
                          reviewer_role.RESEARCH, self.assistant_mandate,
                          assistant_mandate_state.RESEARCH))
     self.assertEqual([{
         'action': 'view',
         'class': '',
         'item': 'PHD_SUPERVISOR'
     }, {
         'item': 'RESEARCH',
         'class': '',
         'action': 'view'
     }, {
         'item': 'SUPERVISION',
         'class': '',
         'action': 'edit'
     }],
                      generate_reviewer_menu_tabs(reviewer_role.SUPERVISION,
                                                  self.assistant_mandate,
                                                  None))
 def test_assistant_mandate_step_back_from_institute_president_to_php_supervisor(self):
     self.assistant.supervisor = PersonFactory()
     self.assistant.save()
     self.review1 = ReviewFactory(
         reviewer=self.reviewer1,
         mandate=self.assistant_mandate,
         status=review_status.DONE
     )
     self.review2 = ReviewFactory(
         reviewer=None,
         mandate=self.assistant_mandate,
         status=review_status.DONE
     )
     self.assistant_mandate.state = assistant_mandate_state.RESEARCH
     self.assistant_mandate.save()
     self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate.id})
     self.assistant_mandate.refresh_from_db()
     self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.PHD_SUPERVISOR)
 def setUp(self):
     self.factory = RequestFactory()
     self.client = Client()
     self.settings = SettingsFactory()
     today = datetime.date.today()
     self.current_academic_year = AcademicYearFactory(start_date=today,
                                                      end_date=today.replace(year=today.year + 1),
                                                      year=today.year)
     self.phd_supervisor = PersonFactory()
     self.assistant = AcademicAssistantFactory(supervisor=self.phd_supervisor)
     self.assistant_mandate = AssistantMandateFactory(academic_year=self.current_academic_year,
                                                      assistant=self.assistant)
     self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
     self.assistant_mandate.save()
     self.review = ReviewFactory(reviewer=None, mandate=self.assistant_mandate,
                                 status=review_status.IN_PROGRESS)
     self.entity1 = EntityFactory()
     self.entity_version1 = EntityVersionFactory(entity=self.entity1, entity_type=entity_type.INSTITUTE)
     self.mandate_entity = MandateEntityFactory(assistant_mandate=self.assistant_mandate, entity=self.entity1)
Ejemplo n.º 23
0
    def setUpTestData(cls):
        cls.settings = SettingsFactory()
        today = datetime.date.today()
        cls.current_academic_year = AcademicYearFactory(start_date=today,
                                                        end_date=today.replace(year=today.year + 1),
                                                        year=today.year)
        cls.phd_supervisor = PersonFactory()
        cls.assistant = AcademicAssistantFactory(supervisor=cls.phd_supervisor)
        cls.assistant_mandate = AssistantMandateFactory(academic_year=cls.current_academic_year,
                                                        assistant=cls.assistant)
        cls.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
        cls.assistant_mandate.save()
        cls.review = ReviewFactory(reviewer=None, mandate=cls.assistant_mandate,
                                   status=review_status.IN_PROGRESS)
        cls.entity = EntityFactory()
        cls.entity_version = EntityVersionFactory(entity=cls.entity, entity_type=entity_type.INSTITUTE)
        cls.mandate_entity = MandateEntityFactory(assistant_mandate=cls.assistant_mandate, entity=cls.entity)

        cls.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                       entity=cls.entity_version.entity)
Ejemplo n.º 24
0
    def setUp(self):
        self.factory = RequestFactory()
        self.client = Client()
        self.person2 = PersonFactory()
        self.manager = ManagerFactory()
        self.person = self.manager.person
        self.client.force_login(self.person.user)
        self.entity_factory = EntityFactory()
        self.entity_factory2 = EntityFactory()
        self.entity_version = EntityVersionFactory(
            entity_type=entity_type.INSTITUTE,
            end_date=None,
            entity=self.entity_factory)
        self.entity_version2 = EntityVersionFactory(
            entity_type=entity_type.INSTITUTE,
            end_date=None,
            entity=self.entity_factory2)
        self.phd_supervisor = PersonFactory()

        self.assistant = AcademicAssistantFactory(
            supervisor=self.phd_supervisor)
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year, assistant=self.assistant)
        self.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH_ASSISTANT,
                                        entity=self.entity_version.entity)
        self.reviewer2 = ReviewerFactory(role=reviewer_role.RESEARCH,
                                         entity=self.entity_version.entity)
        self.reviewer3 = ReviewerFactory(role=reviewer_role.RESEARCH,
                                         entity=self.entity_version.entity)
        self.review = ReviewFactory(reviewer=self.reviewer2)
        self.formset = formset_factory(ReviewersFormset)
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
class TestMandateEntity(TestCase):

    def setUp(self):
        self.factory = RequestFactory()
        self.client = Client()
        self.manager = ManagerFactory()
        self.settings = SettingsFactory()
        self.client.force_login(self.manager.person.user)
        self.assistant = AcademicAssistantFactory()
        self.assistant_mandate = AssistantMandateFactory(
            state=assistant_mandate_state.TRTS,
            assistant=self.assistant,
            assistant_type=assistant_type.ASSISTANT
        )
        self.assistant2 = AcademicAssistantFactory()
        self.assistant_mandate2 = AssistantMandateFactory(
            state=assistant_mandate_state.SUPERVISION,
            assistant=self.assistant2,
            assistant_type=assistant_type.TEACHING_ASSISTANT
        )
        self.entity1 = EntityFactory()
        self.entity_version1 = EntityVersionFactory(entity=self.entity1, entity_type=entity_type.SECTOR)
        self.entity2 = EntityFactory()
        self.entity_version2 = EntityVersionFactory(entity=self.entity2, entity_type=entity_type.FACULTY)
        self.entity3 = EntityFactory()
        self.entity_version3 = EntityVersionFactory(entity=self.entity3, entity_type=entity_type.INSTITUTE)
        self.entity4 = EntityFactory()
        self.entity_version4 = EntityVersionFactory(
            entity=self.entity4, parent=self.entity2, entity_type=entity_type.SCHOOL)

        self.mandate_entity1 = MandateEntityFactory(assistant_mandate=self.assistant_mandate, entity=self.entity1)
        self.mandate_entity2 = MandateEntityFactory(assistant_mandate=self.assistant_mandate, entity=self.entity2)
        self.mandate_entity3 = MandateEntityFactory(assistant_mandate=self.assistant_mandate, entity=self.entity3)

        self.mandate_entity4 = MandateEntityFactory(assistant_mandate=self.assistant_mandate2, entity=self.entity1)
        self.mandate_entity5 = MandateEntityFactory(assistant_mandate=self.assistant_mandate2, entity=self.entity2)

        self.reviewer1 = ReviewerFactory(entity=self.entity3, role=reviewer_role.RESEARCH)
        self.reviewer2 = ReviewerFactory(entity=self.entity2, role=reviewer_role.SUPERVISION)
        self.reviewer3 = ReviewerFactory(entity=self.entity1, role=reviewer_role.VICE_RECTOR)
        self.reviewer4 = ReviewerFactory(entity=None, role=reviewer_role.PHD_SUPERVISOR)

    def test_mandate_can_go_backward(self):
        self.assertTrue(mandate_can_go_backward(self.assistant_mandate))
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.review1 = ReviewFactory(
            reviewer=self.reviewer1,
            mandate=self.assistant_mandate,
            status=review_status.IN_PROGRESS
        )
        self.assertFalse(mandate_can_go_backward(self.assistant_mandate))
        self.review1.delete()
        self.assistant_mandate.state = assistant_mandate_state.TO_DO
        self.assistant_mandate.save()
        self.assertFalse(mandate_can_go_backward(self.assistant_mandate))

    def test_assistant_mandate_step_back_from_assistant_to_beginning(self):
        self.assistant_mandate.state = assistant_mandate_state.TRTS
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.TO_DO)

    def test_assistant_mandate_step_back_from_phd_supervisor_to_assistant(self):
        self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.TRTS)

    def test_assistant_mandate_step_back_from_institute_president_to_php_supervisor(self):
        self.assistant.supervisor = PersonFactory()
        self.assistant.save()
        self.review1 = ReviewFactory(
            reviewer=self.reviewer1,
            mandate=self.assistant_mandate,
            status=review_status.DONE
        )
        self.review2 = ReviewFactory(
            reviewer=None,
            mandate=self.assistant_mandate,
            status=review_status.DONE
        )
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.PHD_SUPERVISOR)

    def test_assistant_mandate_step_back_from_institute_president_to_assistant(self):
        # Test if assistant does not have a phd supervisor
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.assistant.supervisor = None
        self.assistant.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.TRTS)

    def test_assistant_mandate_step_back_from_dean_of_faculty_to_institute_president(self):
        self.research_review = ReviewFactory(mandate=self.assistant_mandate, reviewer=self.reviewer1)
        self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.RESEARCH)

    def test_assistant_mandate_step_back_from_vice_rector_to_dean_of_faculty(self):
        self.supervision_review = ReviewFactory(mandate=self.assistant_mandate, reviewer=self.reviewer2)
        self.assistant_mandate.state = assistant_mandate_state.VICE_RECTOR
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.SUPERVISION)

    def test_assistant_mandate_step_back_from_dean_of_faculty_to_assistant(self):
        # Test if assistant is teaching assistant
        self.research_review = ReviewFactory(mandate=self.assistant_mandate, reviewer=self.reviewer1)
        self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate2.id})
        self.assistant_mandate2.refresh_from_db()
        self.assertEqual(self.assistant_mandate2.state, assistant_mandate_state.TRTS)

    def test_assistant_mandate_step_back_from_done_to_vice_rector(self):
        self.review4 = ReviewFactory(
            reviewer=self.reviewer3,
            mandate=self.assistant_mandate2,
            status=review_status.DONE
        )
        self.review5 = ReviewFactory(
            reviewer=self.reviewer2,
            mandate=self.assistant_mandate2,
            status=review_status.DONE
        )
        self.assistant_mandate2.state = assistant_mandate_state.DONE
        self.assistant_mandate2.save()
        self.client.post(reverse('assistant_mandate_step_back'), {'mandate_id': self.assistant_mandate2.id})
        self.assistant_mandate2.refresh_from_db()
        self.assertEqual(self.assistant_mandate2.state, assistant_mandate_state.VICE_RECTOR)

    def test_add_actions_to_mandates_list(self):
        self.client.force_login(self.reviewer1.person.user)
        response = self.client.get('/assistants/reviewer/')
        context = add_actions_to_mandates_list(response.context, self.reviewer1)
        for mandate in context['object_list']:
            if mandate.id == self.assistant_mandate.id:
                self.assertFalse(mandate.view)
                self.assertFalse(mandate.edit)
        self.client.force_login(self.reviewer2.person.user)
        response = self.client.get('/assistants/reviewer/')
        context = add_actions_to_mandates_list(response.context, self.reviewer2)
        for mandate in context['object_list']:
            if mandate.id == self.assistant_mandate2.id:
                self.assertTrue(mandate.view)
                self.assertTrue(mandate.edit)
    def setUp(self):
        self.client = Client()
        self.settings = SettingsFactory()
        self.manager = ManagerFactory()
        self.factory = RequestFactory()
        self.supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(
            phd_inscription_date=datetime.date(2015, 10, 2),
            thesis_title='Data fitting on manifolds',
            confirmation_test_date=datetime.date(2017, 9, 25),
            remark=
            "Deux co-promoteurs (l'application ne m'autorise à n'en renseigner qu'un)",
            supervisor=self.supervisor)
        self.mandate = AssistantMandateFactory(
            assistant=self.assistant,
            assistant_type=assistant_type.ASSISTANT,
            sap_id='1120019',
            entry_date=datetime.date(2012, 9, 15),
            end_date=datetime.date(2018, 9, 14),
            contract_duration='6 ans',
            contract_duration_fte='6 ans',
            fulltime_equivalent=1,
            other_status=None,
            renewal_type=assistant_mandate_renewal.NORMAL,
            justification=None,
            external_contract='',
            external_functions='',
        )
        self.tutoring_learning_unit_year = TutoringLearningUnitYearFactory(
            mandate=self.mandate)
        self.review3 = ReviewFactory(mandate=self.mandate, reviewer=None)
        self.entity_version = EntityVersionFactory()
        self.mandate_entity = MandateEntityFactory(
            assistant_mandate=self.mandate, entity=self.entity_version.entity)
        self.entity_version2 = EntityVersionFactory(
            entity_type=entity_type.FACULTY, end_date=None)
        self.mandate_entity2 = MandateEntityFactory(
            assistant_mandate=self.mandate, entity=self.entity_version2.entity)
        self.reviewer = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                        entity=self.mandate_entity.entity)

        self.reviewer2 = ReviewerFactory(entity=self.mandate_entity2.entity)
        self.styles = getSampleStyleSheet()
        self.styles.add(
            ParagraphStyle(
                name='Tiny',
                fontSize=6,
                font='Helvetica',
                leading=8,
                leftIndent=0,
                rightIndent=0,
                firstLineIndent=0,
                alignment=TA_LEFT,
                spaceBefore=0,
                spaceAfter=0,
                splitLongWords=1,
            ))
        self.review1 = ReviewFactory(mandate=self.mandate,
                                     reviewer=self.reviewer)
        self.review2 = ReviewFactory(mandate=self.mandate,
                                     reviewer=self.reviewer2,
                                     status=review_status.IN_PROGRESS)
        self.review3 = ReviewFactory(mandate=self.mandate, reviewer=None)
        self.reviewer3 = ReviewerFactory()
Ejemplo n.º 27
0
class PhdSupervisorReviewViewTestCase(TestCase):
    def setUp(self):
        self.factory = RequestFactory()
        self.client = Client()
        self.settings = SettingsFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.phd_supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(
            supervisor=self.phd_supervisor)
        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year, assistant=self.assistant)
        self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
        self.assistant_mandate.save()
        self.review = ReviewFactory(reviewer=None,
                                    mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)
        self.entity1 = EntityFactory()
        self.entity_version1 = EntityVersionFactory(
            entity=self.entity1, entity_type=entity_type.INSTITUTE)
        self.mandate_entity = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate, entity=self.entity1)

    def test_generate_phd_supervisor_menu_tabs(self):
        self.client.force_login(self.phd_supervisor)
        # Review has not been completed -> supervisor can edit
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(self.assistant_mandate, None),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': '',
                'action': 'edit'
            }])
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(
                self.assistant_mandate,
                assistant_mandate_state.PHD_SUPERVISOR),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': 'active',
                'action': 'edit'
            }])
        # Review has been completed -> supervisor can only view his review
        self.review.status = review_status.DONE
        self.review.save()
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(self.assistant_mandate, None),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': '',
                'action': 'view'
            }])
        self.assertEqual(
            generate_phd_supervisor_menu_tabs(
                self.assistant_mandate,
                assistant_mandate_state.PHD_SUPERVISOR),
            [{
                'item': assistant_mandate_state.PHD_SUPERVISOR,
                'class': 'active',
                'action': 'view'
            }])

    def test_pst_form_view(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post('/assistants/phd_supervisor/pst_form/',
                                    {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_view(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post('/assistants/phd_supervisor/review/view/',
                                    {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_edit(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post('/assistants/phd_supervisor/review/edit/',
                                    {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)
        self.review.status = review_status.DONE
        self.review.save()
        response = self.client.post('/assistants/phd_supervisor/review/edit/',
                                    {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, 302)

    def test_review_save(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post(
            '/assistants/phd_supervisor/review/save/', {
                'mandate_id': self.assistant_mandate.id,
                'review_id': self.review.id
            })
        self.assertEqual(response.status_code, HTTP_OK)

    def test_validate_review_and_update_mandate(self):
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.review.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.RESEARCH)
        self.entity_version1.entity_type = entity_type.POLE
        self.entity_version1.save()
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.RESEARCH)
        self.entity_version1.entity_type = entity_type.FACULTY
        self.entity_version1.save()
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.SUPERVISION)
Ejemplo n.º 28
0
 def setUp(self):
     self.mandate = AssistantMandateFactory()
     self.review = ReviewFactory(mandate=self.mandate)
Ejemplo n.º 29
0
class ReviewerReviewViewTestCase(TestCase):
    def setUp(self):

        self.factory = RequestFactory()
        self.client = Client()
        self.settings = SettingsFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.current_academic_year.save()
        self.phd_supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(
            supervisor=self.phd_supervisor)

        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH)
        self.assistant_mandate2 = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH)
        self.phd_supervisor_review = ReviewFactory(
            reviewer=None,
            mandate=self.assistant_mandate,
            status=review_status.DONE)
        self.entity_version = EntityVersionFactory(
            entity_type=entity_type.INSTITUTE)
        self.entity_mandate = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version.entity)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate2,
            entity=self.entity_version.entity)
        self.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=self.entity_version.entity)
        self.review = ReviewFactory(reviewer=self.reviewer,
                                    mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)
        self.entity_version2 = EntityVersionFactory(
            entity_type=entity_type.FACULTY)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version2.entity)
        self.reviewer2 = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                         entity=self.entity_version2.entity)
        self.entity_version3 = EntityVersionFactory(
            entity_type=entity_type.SECTOR)
        self.entity_mandate3 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version3.entity)
        self.reviewer3 = ReviewerFactory(role=reviewer_role.VICE_RECTOR,
                                         entity=self.entity_version3.entity)

    def test_pst_form_view(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post('/assistants/reviewer/pst_form/',
                                    {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_edit(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post('/assistants/reviewer/review/edit/',
                                    {'mandate_id': self.assistant_mandate2.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_save(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post('/assistants/reviewer/review/save/', {
            'mandate_id': self.assistant_mandate.id,
            'review_id': self.review.id
        })
        self.assertEqual(response.status_code, HTTP_OK)

    def test_validate_review_and_update_mandate(self):
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.review.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.SUPERVISION)
        self.review2 = ReviewFactory(reviewer=self.reviewer2,
                                     mandate=self.assistant_mandate,
                                     status=review_status.IN_PROGRESS)
        validate_review_and_update_mandate(self.review2,
                                           self.assistant_mandate)
        self.assertEqual(self.review2.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.VICE_RECTOR)
        self.review3 = ReviewFactory(reviewer=self.reviewer3,
                                     mandate=self.assistant_mandate,
                                     status=review_status.IN_PROGRESS)
        validate_review_and_update_mandate(self.review3,
                                           self.assistant_mandate)
        self.assertEqual(self.review3.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.DONE)

    def test_review_view(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post(
            '/assistants/reviewer/review/view/', {
                'mandate_id': self.assistant_mandate.id,
                'role': reviewer_role.PHD_SUPERVISOR
            })
        self.assertEqual(response.status_code, HTTP_OK)
        response = self.client.post(
            '/assistants/reviewer/review/view/', {
                'mandate_id': self.assistant_mandate.id,
                'role': reviewer_role.RESEARCH
            })
        self.assertEqual(response.status_code, HTTP_OK)

    def test_generate_phd_supervisor_menu_tabs(self):
        self.client.force_login(self.reviewer.person.user)
        self.assertEqual([{
            'action': 'view',
            'class': '',
            'item': 'PHD_SUPERVISOR'
        }, {
            'item': 'RESEARCH',
            'class': '',
            'action': 'edit'
        }],
                         generate_reviewer_menu_tabs(reviewer_role.RESEARCH,
                                                     self.assistant_mandate,
                                                     None))
        self.review.status = review_status.DONE
        self.review.save()
        self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
        self.assistant_mandate.save()
        self.review2 = ReviewFactory(reviewer=self.reviewer2,
                                     mandate=self.assistant_mandate,
                                     status=review_status.IN_PROGRESS)
        self.assertEqual([{
            'action': 'view',
            'class': '',
            'item': 'PHD_SUPERVISOR'
        }, {
            'item': 'RESEARCH',
            'class': 'active',
            'action': 'view'
        }],
                         generate_reviewer_menu_tabs(
                             reviewer_role.RESEARCH, self.assistant_mandate,
                             assistant_mandate_state.RESEARCH))
        self.assertEqual([{
            'action': 'view',
            'class': '',
            'item': 'PHD_SUPERVISOR'
        }, {
            'item': 'RESEARCH',
            'class': '',
            'action': 'view'
        }, {
            'item': 'SUPERVISION',
            'class': '',
            'action': 'edit'
        }],
                         generate_reviewer_menu_tabs(reviewer_role.SUPERVISION,
                                                     self.assistant_mandate,
                                                     None))
Ejemplo n.º 30
0
 def setUpTestData(cls):
     cls.mandate = AssistantMandateFactory()
     cls.review = ReviewFactory(mandate=cls.mandate)
class PhdSupervisorReviewViewTestCase(TestCase):

    def setUp(self):
        self.factory = RequestFactory()
        self.client = Client()
        self.settings = SettingsFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(start_date=today,
                                                         end_date=today.replace(year=today.year + 1),
                                                         year=today.year)
        self.phd_supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(supervisor=self.phd_supervisor)
        self.assistant_mandate = AssistantMandateFactory(academic_year=self.current_academic_year,
                                                         assistant=self.assistant)
        self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
        self.assistant_mandate.save()
        self.review = ReviewFactory(reviewer=None, mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)
        self.entity1 = EntityFactory()
        self.entity_version1 = EntityVersionFactory(entity=self.entity1, entity_type=entity_type.INSTITUTE)
        self.mandate_entity = MandateEntityFactory(assistant_mandate=self.assistant_mandate, entity=self.entity1)


    def test_generate_phd_supervisor_menu_tabs(self):
        self.client.force_login(self.phd_supervisor)
        # Review has not been completed -> supervisor can edit
        self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate, None),
                         [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': '',
                          'action': 'edit'}])
        self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate,
                                                           assistant_mandate_state.PHD_SUPERVISOR),
                         [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': 'active',
                           'action': 'edit'}])
        # Review has been completed -> supervisor can only view his review
        self.review.status = review_status.DONE
        self.review.save()
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate, None),
                         [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': '',
                           'action': 'view'}])
        self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate,
                                                           assistant_mandate_state.PHD_SUPERVISOR),
                         [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': 'active',
                           'action': 'view'}])

    def test_pst_form_view(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post('/assistants/phd_supervisor/pst_form/', {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_view(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post('/assistants/phd_supervisor/review/view/', {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_edit(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post('/assistants/phd_supervisor/review/edit/', {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)
        self.review.status = review_status.DONE
        self.review.save()
        response = self.client.post('/assistants/phd_supervisor/review/edit/',{'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_FOUND)

    def test_review_save(self):
        self.client.force_login(self.phd_supervisor.user)
        response = self.client.post('/assistants/phd_supervisor/review/save/', {'mandate_id': self.assistant_mandate.id,
                                                                                'review_id': self.review.id
                                                                                })
        self.assertEqual(response.status_code, HTTP_OK)

    def test_validate_review_and_update_mandate(self):
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.review.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.RESEARCH)
        self.entity_version1.entity_type = entity_type.POLE
        self.entity_version1.save()
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.RESEARCH)
        self.entity_version1.entity_type = entity_type.FACULTY
        self.entity_version1.save()
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.SUPERVISION)
class TestMandateEntity(TestCase):
    def setUp(self):
        self.factory = RequestFactory()
        self.client = Client()
        self.manager = ManagerFactory()
        self.settings = SettingsFactory()
        self.client.force_login(self.manager.person.user)
        self.assistant = AcademicAssistantFactory()
        self.assistant_mandate = AssistantMandateFactory(
            state=assistant_mandate_state.TRTS,
            assistant=self.assistant,
            assistant_type=assistant_type.ASSISTANT)
        self.assistant2 = AcademicAssistantFactory()
        self.assistant_mandate2 = AssistantMandateFactory(
            state=assistant_mandate_state.SUPERVISION,
            assistant=self.assistant2,
            assistant_type=assistant_type.TEACHING_ASSISTANT)
        self.entity1 = EntityFactory()
        self.entity_version1 = EntityVersionFactory(
            entity=self.entity1, entity_type=entity_type.SECTOR)
        self.entity2 = EntityFactory()
        self.entity_version2 = EntityVersionFactory(
            entity=self.entity2, entity_type=entity_type.FACULTY)
        self.entity3 = EntityFactory()
        self.entity_version3 = EntityVersionFactory(
            entity=self.entity3, entity_type=entity_type.INSTITUTE)
        self.entity4 = EntityFactory()
        self.entity_version4 = EntityVersionFactory(
            entity=self.entity4,
            parent=self.entity2,
            entity_type=entity_type.SCHOOL)

        self.mandate_entity1 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate, entity=self.entity1)
        self.mandate_entity2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate, entity=self.entity2)
        self.mandate_entity3 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate, entity=self.entity3)

        self.mandate_entity4 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate2, entity=self.entity1)
        self.mandate_entity5 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate2, entity=self.entity2)

        self.reviewer1 = ReviewerFactory(entity=self.entity3,
                                         role=reviewer_role.RESEARCH)
        self.reviewer2 = ReviewerFactory(entity=self.entity2,
                                         role=reviewer_role.SUPERVISION)
        self.reviewer3 = ReviewerFactory(entity=self.entity1,
                                         role=reviewer_role.VICE_RECTOR)
        self.reviewer4 = ReviewerFactory(entity=None,
                                         role=reviewer_role.PHD_SUPERVISOR)

    def test_mandate_can_go_backward(self):
        self.assertTrue(mandate_can_go_backward(self.assistant_mandate))
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.review1 = ReviewFactory(reviewer=self.reviewer1,
                                     mandate=self.assistant_mandate,
                                     status=review_status.IN_PROGRESS)
        self.assertFalse(mandate_can_go_backward(self.assistant_mandate))
        self.review1.delete()
        self.assistant_mandate.state = assistant_mandate_state.TO_DO
        self.assistant_mandate.save()
        self.assertFalse(mandate_can_go_backward(self.assistant_mandate))

    def test_assistant_mandate_step_back_from_assistant_to_beginning(self):
        self.assistant_mandate.state = assistant_mandate_state.TRTS
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.TO_DO)

    def test_assistant_mandate_step_back_from_phd_supervisor_to_assistant(
            self):
        self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.TRTS)

    def test_assistant_mandate_step_back_from_institute_president_to_php_supervisor(
            self):
        self.assistant.supervisor = PersonFactory()
        self.assistant.save()
        self.review1 = ReviewFactory(reviewer=self.reviewer1,
                                     mandate=self.assistant_mandate,
                                     status=review_status.DONE)
        self.review2 = ReviewFactory(reviewer=None,
                                     mandate=self.assistant_mandate,
                                     status=review_status.DONE)
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.PHD_SUPERVISOR)

    def test_assistant_mandate_step_back_from_institute_president_to_assistant(
            self):
        # Test if assistant does not have a phd supervisor
        self.assistant_mandate.state = assistant_mandate_state.RESEARCH
        self.assistant_mandate.save()
        self.assistant.supervisor = None
        self.assistant.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.TRTS)

    def test_assistant_mandate_step_back_from_dean_of_faculty_to_institute_president(
            self):
        self.research_review = ReviewFactory(mandate=self.assistant_mandate,
                                             reviewer=self.reviewer1)
        self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.RESEARCH)

    def test_assistant_mandate_step_back_from_vice_rector_to_dean_of_faculty(
            self):
        self.supervision_review = ReviewFactory(mandate=self.assistant_mandate,
                                                reviewer=self.reviewer2)
        self.assistant_mandate.state = assistant_mandate_state.VICE_RECTOR
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate.id})
        self.assistant_mandate.refresh_from_db()
        self.assertEqual(self.assistant_mandate.state,
                         assistant_mandate_state.SUPERVISION)

    def test_assistant_mandate_step_back_from_dean_of_faculty_to_assistant(
            self):
        # Test if assistant is teaching assistant
        self.research_review = ReviewFactory(mandate=self.assistant_mandate,
                                             reviewer=self.reviewer1)
        self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
        self.assistant_mandate.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate2.id})
        self.assistant_mandate2.refresh_from_db()
        self.assertEqual(self.assistant_mandate2.state,
                         assistant_mandate_state.TRTS)

    def test_assistant_mandate_step_back_from_done_to_vice_rector(self):
        self.review4 = ReviewFactory(reviewer=self.reviewer3,
                                     mandate=self.assistant_mandate2,
                                     status=review_status.DONE)
        self.review5 = ReviewFactory(reviewer=self.reviewer2,
                                     mandate=self.assistant_mandate2,
                                     status=review_status.DONE)
        self.assistant_mandate2.state = assistant_mandate_state.DONE
        self.assistant_mandate2.save()
        self.client.post(reverse('assistant_mandate_step_back'),
                         {'mandate_id': self.assistant_mandate2.id})
        self.assistant_mandate2.refresh_from_db()
        self.assertEqual(self.assistant_mandate2.state,
                         assistant_mandate_state.VICE_RECTOR)

    def test_add_actions_to_mandates_list(self):
        self.client.force_login(self.reviewer1.person.user)
        response = self.client.get('/assistants/reviewer/')
        context = add_actions_to_mandates_list(response.context,
                                               self.reviewer1)
        for mandate in context['object_list']:
            if mandate.id == self.assistant_mandate.id:
                self.assertFalse(mandate.view)
                self.assertFalse(mandate.edit)
        self.client.force_login(self.reviewer2.person.user)
        response = self.client.get('/assistants/reviewer/')
        context = add_actions_to_mandates_list(response.context,
                                               self.reviewer2)
        for mandate in context['object_list']:
            if mandate.id == self.assistant_mandate2.id:
                self.assertTrue(mandate.view)
                self.assertTrue(mandate.edit)
class ReviewerReviewViewTestCase(TestCase):

    def setUp(self):

        self.factory = RequestFactory()
        self.client = Client()
        self.settings = SettingsFactory()
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(start_date=today,
                                                         end_date=today.replace(year=today.year + 1),
                                                         year=today.year)
        self.current_academic_year.save()
        self.phd_supervisor = PersonFactory()
        self.assistant = AcademicAssistantFactory(supervisor=self.phd_supervisor)

        self.assistant_mandate = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH
        )
        self.assistant_mandate2 = AssistantMandateFactory(
            academic_year=self.current_academic_year,
            assistant=self.assistant,
            state=assistant_mandate_state.RESEARCH
        )
        self.phd_supervisor_review = ReviewFactory(
            reviewer=None,
            mandate=self.assistant_mandate,
            status=review_status.DONE
        )
        self.entity_version = EntityVersionFactory(entity_type=entity_type.INSTITUTE)
        self.entity_mandate = MandateEntityFactory(assistant_mandate=self.assistant_mandate,
                                                   entity=self.entity_version.entity)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate2,
            entity=self.entity_version.entity
        )
        self.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=self.entity_version.entity)
        self.review = ReviewFactory(reviewer=self.reviewer, mandate=self.assistant_mandate,
                                    status=review_status.IN_PROGRESS)
        self.entity_version2 = EntityVersionFactory(entity_type=entity_type.FACULTY)
        self.entity_mandate2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version2.entity
        )
        self.reviewer2 = ReviewerFactory(
            role=reviewer_role.SUPERVISION,
            entity=self.entity_version2.entity
        )
        self.entity_version3 = EntityVersionFactory(entity_type=entity_type.SECTOR)
        self.entity_mandate3 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate,
            entity=self.entity_version3.entity
        )
        self.reviewer3 = ReviewerFactory(
            role=reviewer_role.VICE_RECTOR,
            entity=self.entity_version3.entity
        )

    def test_pst_form_view(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post('/assistants/reviewer/pst_form/', {'mandate_id': self.assistant_mandate.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_edit(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post('/assistants/reviewer/review/edit/', {'mandate_id': self.assistant_mandate2.id})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_review_save(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post('/assistants/reviewer/review/save/', {'mandate_id': self.assistant_mandate.id,
                                                                          'review_id': self.review.id
                                                                          })
        self.assertEqual(response.status_code, HTTP_OK)

    def test_validate_review_and_update_mandate(self):
        validate_review_and_update_mandate(self.review, self.assistant_mandate)
        self.assertEqual(self.review.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.SUPERVISION)
        self.review2 = ReviewFactory(
            reviewer=self.reviewer2, mandate=self.assistant_mandate,
            status=review_status.IN_PROGRESS
        )
        validate_review_and_update_mandate(self.review2, self.assistant_mandate)
        self.assertEqual(self.review2.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.VICE_RECTOR)
        self.review3 = ReviewFactory(reviewer=self.reviewer3, mandate=self.assistant_mandate,
                                     status=review_status.IN_PROGRESS)
        validate_review_and_update_mandate(self.review3, self.assistant_mandate)
        self.assertEqual(self.review3.status, review_status.DONE)
        self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.DONE)

    def test_review_view(self):
        self.client.force_login(self.reviewer.person.user)
        response = self.client.post('/assistants/reviewer/review/view/', {'mandate_id': self.assistant_mandate.id,
                                                                          'role': reviewer_role.PHD_SUPERVISOR})
        self.assertEqual(response.status_code, HTTP_OK)
        response = self.client.post('/assistants/reviewer/review/view/', {'mandate_id': self.assistant_mandate.id,
                                                                          'role': reviewer_role.RESEARCH})
        self.assertEqual(response.status_code, HTTP_OK)

    def test_generate_reviewer_menu_tabs(self):
        self.client.force_login(self.reviewer.person.user)
        self.assertEqual([{'action': 'view', 'class': '', 'item': 'PHD_SUPERVISOR'},
                          {'item': 'RESEARCH', 'class': '', 'action': 'edit'}],
                         generate_reviewer_menu_tabs(reviewer_role.RESEARCH, self.assistant_mandate, None))
        self.review.status = review_status.DONE
        self.review.save()
        self.assistant_mandate.state = assistant_mandate_state.SUPERVISION
        self.assistant_mandate.save()
        self.review2 = ReviewFactory(
            reviewer=self.reviewer2,
            mandate=self.assistant_mandate,
            status=review_status.IN_PROGRESS
        )
        self.assertEqual([{'action': 'view', 'class': '', 'item': 'PHD_SUPERVISOR'},
                          {'item': 'RESEARCH', 'class': 'active', 'action': 'view'}],
                         generate_reviewer_menu_tabs(reviewer_role.RESEARCH, self.assistant_mandate,
                                                     assistant_mandate_state.RESEARCH))
        self.assertEqual([{'action': 'view', 'class': '', 'item': 'PHD_SUPERVISOR'},
                          {'item': 'RESEARCH', 'class': '', 'action': 'view'},
                          {'item': 'SUPERVISION', 'class': '', 'action': 'edit'}],
                         generate_reviewer_menu_tabs(reviewer_role.SUPERVISION, self.assistant_mandate, None))