コード例 #1
0
class AcademicCalendarDeleteTestCase(TestCase):
    def setUp(self):
        academic_year = AcademicYearFactory(
            start_date=today.replace(year=today.year),
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.academic_calendar = AcademicCalendarFactory(
            academic_year=academic_year)
        self.user = SuperUserFactory()
        self.person = PersonFactory(user=self.user)
        self.client.force_login(self.person.user)
        self.url = reverse('academic_calendar_delete',
                           kwargs={'pk': self.academic_calendar.pk})

    def test_academic_calendar_delete_not_superuser(self):
        self.user.is_superuser = False
        self.user.save()

        response = self.client.post(self.url)

        self.assertEqual(response.status_code,
                         HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, "access_denied.html")

    def test_academic_calendar_delete(self):
        response = self.client.post(self.url)

        self.assertRedirects(response, reverse('academic_calendars'))

        with self.assertRaises(AcademicCalendar.DoesNotExist):
            self.academic_calendar.refresh_from_db()
コード例 #2
0
 def setUp(self):
     academic_year = AcademicYearFactory(
         start_date=today.replace(year=today.year),
         end_date=today.replace(year=today.year + 1),
         year=today.year)
     self.academic_calendar = AcademicCalendarFactory(
         academic_year=academic_year)
     self.user = SuperUserFactory()
     self.person = PersonFactory(user=self.user)
     self.client.force_login(self.person.user)
     self.url = reverse('academic_calendar_delete',
                        kwargs={'pk': self.academic_calendar.pk})
コード例 #3
0
    def test_project_calendars_search_progress_1(self, mock_render,
                                                 mock_decorators):
        mock_decorators.login_required = lambda x: x
        mock_decorators.permission_required = lambda *args, **kwargs: lambda func: func

        self.academic_calendars[1].reference = academic_calendar_type.TESTING
        self.academic_calendars[1].start_date = today - datetime.timedelta(
            days=10)
        self.academic_calendars[1].end_date = today - datetime.timedelta(
            days=1)
        self.academic_calendars[1].save()

        request_factory = RequestFactory()
        get_data = {
            'academic_year': self.academic_years[1].id,
            'show_project_events': 'on'
        }
        request = request_factory.get(reverse('academic_calendars'), get_data)
        request.user = SuperUserFactory()

        academic_calendars(request)

        self.assertTrue(mock_render.called)
        request, template, context = mock_render.call_args[0]

        self.assertEqual(template, 'academic_calendar/academic_calendars.html')
        self._compare_project_calendar_json(context,
                                            self.academic_calendars[1], 1)
コード例 #4
0
ファイル: test_quicksearch.py プロジェクト: allouchmed/osis
 def setUpTestData(cls):
     cls.root_egy = EducationGroupYearFactory()
     cls.luy_to_find = LearningUnitYearFactory(
         acronym='CYN', specific_title='Drop dead cynical')
     cls.user = SuperUserFactory()
     cls.url = reverse('quick_search_learning_unit',
                       args=[cls.root_egy.id, cls.root_egy.id])
コード例 #5
0
ファイル: test_read.py プロジェクト: austinsdoe/osis
 def setUpTestData(cls):
     cls.person = PersonFactory()
     cls.education_group_year_1 = EducationGroupYearFactory()
     cls.education_group_year_2 = EducationGroupYearFactory()
     cls.education_group_year_3 = EducationGroupYearFactory()
     cls.learning_unit_year_1 = LearningUnitYearFactory()
     cls.learning_unit_year_2 = LearningUnitYearFactory()
     cls.learning_component_year_1 = LearningComponentYearFactory(
         learning_container_year=cls.learning_unit_year_1.learning_container_year, hourly_volume_partial_q1=10,
         hourly_volume_partial_q2=10)
     cls.learning_component_year_2 = LearningComponentYearFactory(
         learning_container_year=cls.learning_unit_year_1.learning_container_year, hourly_volume_partial_q1=10,
         hourly_volume_partial_q2=10)
     cls.learning_unit_component_1 = LearningUnitComponentFactory(
         learning_component_year=cls.learning_component_year_1,
         learning_unit_year=cls.learning_unit_year_1)
     cls.learning_unit_component_2 = LearningUnitComponentFactory(
         learning_component_year=cls.learning_component_year_2,
         learning_unit_year=cls.learning_unit_year_1)
     cls.group_element_year_1 = GroupElementYearFactory(parent=cls.education_group_year_1,
                                                        child_branch=cls.education_group_year_2)
     cls.group_element_year_2 = GroupElementYearFactory(parent=cls.education_group_year_2,
                                                        child_branch=None,
                                                        child_leaf=cls.learning_unit_year_1)
     cls.group_element_year_3 = GroupElementYearFactory(parent=cls.education_group_year_1,
                                                        child_branch=cls.education_group_year_3)
     cls.group_element_year_4 = GroupElementYearFactory(parent=cls.education_group_year_3,
                                                        child_branch=None,
                                                        child_leaf=cls.learning_unit_year_2)
     cls.a_superuser = SuperUserFactory()
コード例 #6
0
    def test_apply_learning_unit_year_postponement(self):
        """ Postpone to N+6 in Learning Unit Admin """
        current_year = get_current_year()
        academic_years = GenerateAcademicYear(current_year, current_year + 6)

        lu = LearningUnitFactory(end_year=None)
        LearningUnitYearFactory(academic_year=academic_years[0],
                                learning_unit=lu)

        postpone_url = reverse('admin:base_learningunit_changelist')

        self.client.force_login(SuperUserFactory())
        response = self.client.post(
            postpone_url,
            data={
                'action': 'apply_learning_unit_year_postponement',
                '_selected_action': [lu.pk]
            })

        msg = [m.message for m in get_messages(response.wsgi_request)]
        self.assertEqual(
            msg[0],
            ngettext(
                "%(count)d learning unit has been postponed with success",
                "%(count)d learning units have been postponed with success", 6)
            % {'count': 6})
コード例 #7
0
    def test_apply_education_group_year_postponement(self):
        """ Postpone to N+6 in Education Group Admin """
        current_year = get_current_year()
        academic_years = GenerateAcademicYear(current_year, current_year + 6)

        eg = EducationGroupFactory(end_year=None)
        EducationGroupYearFactory(academic_year=academic_years[0],
                                  education_group=eg)

        postpone_url = reverse('admin:base_educationgroup_changelist')

        self.client.force_login(SuperUserFactory())
        response = self.client.post(
            postpone_url,
            data={
                'action': 'apply_education_group_year_postponement',
                '_selected_action': [eg.pk]
            })

        msg = [m.message for m in get_messages(response.wsgi_request)]
        self.assertEqual(
            msg[0],
            ngettext(
                "%(count)d education group has been postponed with success.",
                "%(count)d education groups have been postponed with success.",
                6) % {'count': 6})
コード例 #8
0
    def setUp(self):
        self.academic_year = create_current_academic_year()
        self.learning_unit_year = LearningUnitYearFactory(
            academic_year=self.academic_year,
            subtype=learning_unit_year_subtypes.FULL)

        self.language_fr = LanguageFactory(code="FR")
        self.language_en = LanguageFactory(code="EN")
        self.user = UserFactory()
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_access_learningunit"))
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_create_learningunit"))

        self.person = PersonFactory(user=self.user)
        self.a_superuser = SuperUserFactory()
        self.client.force_login(self.a_superuser)
        self.superperson = PersonFactory(user=self.a_superuser)

        self.person_entity = PersonEntityFactory(person=self.superperson)
        EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.
            learning_container_year,
            entity=self.person_entity.entity,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY)
コード例 #9
0
ファイル: test_common.py プロジェクト: kelvinninja1/osis
    def setUp(self):
        today = datetime.date.today()
        self.academic_years = GenerateAcademicYear(start_year=today.year+1, end_year=today.year+7)

        self.a_superuser = SuperUserFactory()
        self.person = PersonFactory(user=self.a_superuser)
        self.client.force_login(self.a_superuser)
コード例 #10
0
ファイル: test_quicksearch.py プロジェクト: allouchmed/osis
 def setUpTestData(cls):
     cls.root_egy = EducationGroupYearFactory()
     cls.egy_to_find = GroupFactory(acronym='RAV',
                                    title='The Ravenlord',
                                    partial_acronym="RV")
     cls.user = SuperUserFactory()
     cls.url = reverse('quick_search_education_group',
                       args=[cls.root_egy.id, cls.root_egy.id])
コード例 #11
0
 def setUp(self):
     self.super_user = SuperUserFactory()
     self.url = reverse("certificate_aim_autocomplete")
     self.certificate_aim = CertificateAimFactory(
         code=1234,
         section=5,
         description="description",
     )
コード例 #12
0
    def test_offer_score_encoding_tab(self):
        self.client.force_login(SuperUserFactory())
        response = self.client.get(reverse('offer_score_encoding_tab', args=[self.offer_year.id]))

        self.assertTemplateUsed(response, 'offer/score_sheet_address_tab.html')
        context_keys = self.COMMON_CONTEXT_KEYS + ['entity_id_selected', 'form']
        self.assert_list_contains(list(response.context.keys()), context_keys)
        self.assertEqual(response.context['offer_year'], self.offer_year)
コード例 #13
0
ファイル: test_organization.py プロジェクト: ultrasound/osis
    def setUp(self):
        self.super_user = SuperUserFactory()
        self.url = reverse("organization_autocomplete")

        self.organization = OrganizationFactory(name="Université de Louvain")
        self.organization_address = OrganizationAddressFactory(
            organization=self.organization,
            country__iso_code='BE',
            is_main=True)
コード例 #14
0
    def test_save_score_sheet_address_case_customized_address(self, mock_save_customized_address):
        self.client.force_login(SuperUserFactory())

        mock_save_customized_address.return_value = ScoreSheetAddressForm()

        response = self.client.post(reverse('save_score_sheet_address', args=[self.offer_year.id]))

        self.assertTemplateUsed(response, 'offer/score_sheet_address_tab.html')
        self.assert_list_contains(list(response.context.keys()), self.COMMON_CONTEXT_KEYS + ['form'])
コード例 #15
0
 def setUp(self):
     self.super_user = SuperUserFactory()
     self.url = reverse("entity_autocomplete")
     today = datetime.date.today()
     self.entity_version = EntityVersionFactory(
         entity_type=entity_type.SCHOOL,
         start_date=today.replace(year=1900),
         end_date=None,
         acronym="DRT")
コード例 #16
0
 def test_save_score_sheet_address_case_reuse_entity_address(self,
                                                             mock_add_message,
                                                             mock_save_address_from_entity):
     self.a_superuser = SuperUserFactory()
     self.client.force_login(self.a_superuser)
     url = reverse('save_score_sheet_address', args=[self.offer_year.id])
     response = self.client.post(url, data={'related_entity': 1234})
     self.assertTrue(mock_add_message.called)
     self.assertEqual(response.url, reverse('offer_score_encoding_tab', args=[self.offer_year.id]))
コード例 #17
0
ファイル: test_perms.py プロジェクト: allouchmed/osis
 def test_education_group_year_is_not_training_type(self):
     type_not_allowed = (MiniTrainingFactory(
         academic_year=self.academic_year),
                         GroupFactory(academic_year=self.academic_year))
     for education_group_year in type_not_allowed:
         with self.subTest(education_group_year=education_group_year):
             perm = CertificateAimsPerms(
                 user=SuperUserFactory(),
                 education_group_year=education_group_year)
             self.assertFalse(perm.is_eligible())
コード例 #18
0
ファイル: test_common.py プロジェクト: allouchmed/osis
    def setUpTestData(cls):
        today = datetime.date.today()
        start_year = AcademicYearFactory(year=today.year + 1)
        end_year = AcademicYearFactory(year=today.year + 7)
        cls.academic_years = GenerateAcademicYear(start_year=start_year,
                                                  end_year=end_year)

        cls.a_superuser = SuperUserFactory()
        cls.person = PersonFactory(user=cls.a_superuser)
        cls.url = reverse('check_acronym', kwargs={'subtype': FULL})
コード例 #19
0
ファイル: test_organization.py プロジェクト: allouchmed/osis
    def setUpTestData(cls):
        cls.super_user = SuperUserFactory()
        cls.url = reverse("campus-autocomplete")

        cls.organization = OrganizationFactory(name="Université de Louvain")
        cls.organization_address = OrganizationAddressFactory(
            organization=cls.organization,
            country__iso_code='BE',
            is_main=True
        )
        cls.campus = CampusFactory(organization=cls.organization)
コード例 #20
0
 def setUpTestData(cls):
     cls.super_user = SuperUserFactory()
     cls.url = reverse("entity_autocomplete")
     today = datetime.date.today()
     cls.external_entity_version = EntityVersionFactory(
         entity_type=entity_type.SCHOOL,
         start_date=today.replace(year=1900),
         end_date=None,
         acronym="DRT",
         entity__organization__type=ACADEMIC_PARTNER
     )
コード例 #21
0
ファイル: test_score_sheet.py プロジェクト: allouchmed/osis
 def setUpTestData(cls):
     today = datetime.date.today()
     cls.academic_year = AcademicYearFactory(
         start_date=today,
         end_date=today.replace(year=today.year + 1),
         year=today.year)
     cls.offer_year = OfferYearFactory(academic_year=cls.academic_year)
     cls.COMMON_CONTEXT_KEYS = [
         'offer_year', 'countries', 'is_program_manager', 'entity_versions'
     ]
     cls.a_superuser = SuperUserFactory()
コード例 #22
0
 def create_admin(self, user=None):
     """
     Create an administrator person object with all related objects and permissions
     :param user: related user object , if none it will be created
     :return: The administrator
     """
     if user:
         person = PersonFactory(user=user)
     else:
         super_user = SuperUserFactory()
         person = PersonFactory(user=super_user)
     return person
コード例 #23
0
ファイル: test_detail.py プロジェクト: allouchmed/osis
    def setUpTestData(cls):
        cls.current_academic_year, *cls.academic_years = AcademicYearFactory.produce_in_future(
            quantity=8)

        AcademicCalendarFactory(
            data_year=cls.current_academic_year,
            start_date=datetime.datetime(cls.current_academic_year.year - 2, 9,
                                         15),
            end_date=datetime.datetime(cls.current_academic_year.year + 1, 9,
                                       14),
            reference=LEARNING_UNIT_EDITION_FACULTY_MANAGERS)
        cls.a_superuser = SuperUserFactory()
        cls.person = PersonFactory(user=cls.a_superuser)
コード例 #24
0
 def setUpTestData(cls):
     cls.academic_year = AcademicYearFactory()
     cls.person = PersonFactory()
     cls.education_group_year_1 = EducationGroupYearFactory(
         title_english="", academic_year=cls.academic_year)
     cls.education_group_year_2 = EducationGroupYearFactory(
         title_english="", academic_year=cls.academic_year)
     cls.education_group_year_3 = EducationGroupYearFactory(
         title_english="", academic_year=cls.academic_year, acronym='ed3')
     cls.learning_unit_year_1 = LearningUnitYearFactory(
         specific_title_english="")
     cls.learning_unit_year_2 = LearningUnitYearFactory(
         specific_title_english="", acronym="luy2")
     cls.learning_component_year_1 = LearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year_1,
         hourly_volume_partial_q1=10,
         hourly_volume_partial_q2=10)
     cls.learning_component_year_2 = LearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year_1,
         hourly_volume_partial_q1=10,
         hourly_volume_partial_q2=10)
     cls.group_element_year_1 = GroupElementYearFactory(
         parent=cls.education_group_year_1,
         child_branch=cls.education_group_year_2,
         comment="commentaire",
         comment_english="english",
         block=1)
     cls.group_element_year_2 = GroupElementYearFactory(
         parent=cls.education_group_year_2,
         child_branch=None,
         child_leaf=cls.learning_unit_year_1,
         comment="commentaire",
         comment_english="english",
         block=6)
     cls.group_element_year_3 = GroupElementYearFactory(
         parent=cls.education_group_year_1,
         child_branch=cls.education_group_year_3,
         comment="commentaire",
         comment_english="english",
         block=1)
     cls.group_element_year_4 = GroupElementYearFactory(
         parent=cls.education_group_year_3,
         child_branch=None,
         child_leaf=cls.learning_unit_year_2,
         comment="commentaire",
         comment_english="english",
         block=123)
     cls.a_superuser = SuperUserFactory()
コード例 #25
0
    def setUpTestData(cls):
        ProgramManagerGroupFactory()

        cls.user = SuperUserFactory()
        cls.person = PersonFactory()

        cls.structure_parent1 = StructureFactory(acronym='SSH')

        cls.structure_child1 = StructureFactory(acronym='TECO', part_of=cls.structure_parent1)
        cls.structure_child11 = StructureFactory(acronym='TEBI', part_of=cls.structure_child1)

        cls.structure_child2 = StructureFactory(acronym='ESPO', part_of=cls.structure_parent1)
        cls.structure_child21 = StructureFactory(acronym='ECON', part_of=cls.structure_child2)
        cls.structure_child22 = StructureFactory(acronym='COMU', part_of=cls.structure_child2)
        EntityManagerFactory(person__user=cls.user, structure=cls.structure_parent1)

        cls.academic_year_previous, cls.academic_year_current = AcademicYearFactory.produce_in_past(quantity=2)
コード例 #26
0
ファイル: test_my_osis.py プロジェクト: makinacorpus/osis
    def setUp(self):
        self.a_superuser = SuperUserFactory()
        self.person = PersonFactory(user=self.a_superuser,
                                    language=LANGUAGE_CODE_FR)
        self.client.force_login(self.a_superuser)

        academic_year = create_current_academic_year()
        self.summary_course_submission_calendar = AcademicCalendarFactory(
            academic_year=academic_year,
            start_date=academic_year.start_date,
            end_date=academic_year.end_date,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        self.tutor = TutorFactory(person=self.person)

        self.learning_unit_year = LearningUnitYearFakerFactory(academic_year=academic_year)
        self.attribution = AttributionFactory(learning_unit_year=self.learning_unit_year, summary_responsible=True,
                                              tutor=self.tutor)
コード例 #27
0
    def setUp(self):
        super().setUp()
        self.user = UserFactory(username="******")
        self.person = PersonFactory(user=self.user)
        self.permission = Permission.objects.get(
            codename="can_edit_learningunit_date")
        self.person.user.user_permissions.add(self.permission)
        self.client.force_login(self.user)

        self.setup_academic_years()
        self.learning_unit = self.setup_learning_unit(
            self.current_academic_year.year, learning_unit_periodicity.ANNUAL)
        self.learning_container_year = self.setup_learning_container_year(
            academic_year=self.current_academic_year,
            container_type=learning_container_year_types.COURSE)
        self.learning_unit_year = self.setup_learning_unit_year(
            self.current_academic_year, self.learning_unit,
            self.learning_container_year, learning_unit_periodicity.ANNUAL)

        self.a_superuser = SuperUserFactory()
        self.a_superperson = PersonFactory(user=self.a_superuser)
コード例 #28
0
    def setUpTestData(cls):
        cls.language_fr = LanguageFactory(code="FR")
        cls.language_en = LanguageFactory(code="EN")
        cls.user = UserFactory()
        cls.person = PersonWithPermissionsFactory("can_access_learningunit", "can_create_learningunit", user=cls.user)
        cls.a_superuser = SuperUserFactory()
        cls.superperson = PersonFactory(user=cls.a_superuser)

        cls.person_entity = PersonEntityFactory(person=cls.superperson)

        cls.academic_year = create_current_academic_year()
        AcademicYearFactory.produce_in_future(quantity=2)
        cls.luy = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            subtype=learning_unit_year_subtypes.FULL,
            learning_container_year__requirement_entity=cls.person_entity.entity,
        )
        cls.future_luy = LearningUnitYearFactory(
            academic_year=cls.academic_year.next(),
            learning_unit=cls.luy.learning_unit,
        )
コード例 #29
0
ファイル: test_my_osis.py プロジェクト: allouchmed/osis
    def setUpTestData(cls):
        cls.a_superuser = SuperUserFactory()
        cls.person = PersonFactory(user=cls.a_superuser,
                                   language=LANGUAGE_CODE_FR)
        academic_year = create_current_academic_year()
        cls.summary_course_submission_calendar = AcademicCalendarFactory(
            academic_year=academic_year,
            start_date=academic_year.start_date,
            end_date=academic_year.end_date,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        cls.tutor = TutorFactory(person=cls.person)
        # FIXME CHANGE LEARNINGUNITYEARFACTORY FOR AVOID MULTI ACADEMIC YEAR
        cls.learning_container_year = LearningContainerYearFactory(
            academic_year=academic_year)
        cls.learning_unit_year = LearningUnitYearFakerFactory(
            academic_year=academic_year,
            learning_container_year=cls.learning_container_year)
        cls.attribution = AttributionFactory(
            learning_unit_year=cls.learning_unit_year,
            summary_responsible=True,
            tutor=cls.tutor)
コード例 #30
0
    def setUpTestData(cls):
        super().setUpTestData()
        cls.user = UserFactory(username="******")
        cls.person = CentralManagerFactory(user=cls.user)
        cls.permission = Permission.objects.get(codename="can_edit_learningunit_date")
        cls.person.user.user_permissions.add(cls.permission)
        cls.setup_academic_years()
        cls.learning_unit = cls.setup_learning_unit(cls.starting_academic_year)
        cls.learning_container_year = cls.setup_learning_container_year(
            academic_year=cls.starting_academic_year,
            container_type=learning_container_year_types.COURSE
        )
        cls.learning_unit_year = cls.setup_learning_unit_year(
            cls.starting_academic_year,
            cls.learning_unit,
            cls.learning_container_year,
            learning_unit_year_subtypes.FULL,
            learning_unit_year_periodicity.ANNUAL
        )

        cls.a_superuser = SuperUserFactory()
        cls.a_superperson = PersonFactory(user=cls.a_superuser)
        generate_learning_unit_edition_calendars(cls.list_of_academic_years)