Beispiel #1
0
    def setUp(self):

        self.learning_unit_year = LearningUnitYearFullFactory(
            learning_container_year = self.learning_container_year
        )
        self.lecturing_component = LecturingLearningComponentYearFactory(
            learning_unit_year=self.learning_unit_year)
        self.practical_component = PracticalLearningComponentYearFactory(
            learning_unit_year=self.learning_unit_year)
        self.attribution = AttributionNewFactory(
            learning_container_year=self.learning_unit_year.learning_container_year
        )
        self.charge_lecturing = AttributionChargeNewFactory(
            attribution=self.attribution,
            learning_component_year=self.lecturing_component
        )
        self.charge_practical = AttributionChargeNewFactory(
            attribution=self.attribution,
            learning_component_year=self.practical_component
        )

        self.client.force_login(self.person.user)
        self.url = reverse("update_attribution", args=[self.learning_unit_year.id, self.attribution.id])

        self.patcher = patch.object(RulesRequiredMixin, "test_func", return_value=True)
        self.mocked_permission_function = self.patcher.start()
Beispiel #2
0
    def setUp(self):
        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_edit_learningunit"))
        self.person = CentralManagerFactory(user=self.user)
        self.client.force_login(self.user)

        self.academic_year = create_current_academic_year()

        luy = LearningUnitYearFullFactory(academic_year=self.academic_year)
        self.external = ExternalLearningUnitYearFactory(learning_unit_year=luy)

        luy.learning_container_year.container_type = EXTERNAL
        luy.learning_container_year.save()

        EntityVersionFactory(entity=self.external.requesting_entity)
        PersonEntityFactory(person=self.person,
                            entity=self.external.requesting_entity)

        self.data = get_valid_external_learning_unit_form_data(
            self.academic_year, self.person, self.external.learning_unit_year)

        self.url = reverse(update_learning_unit,
                           args=[self.external.learning_unit_year.pk])
Beispiel #3
0
    def setUpTestData(cls):
        cls.user = UserFactory()
        cls.person = CentralManagerFactory(
            "can_access_learningunit", "can_edit_learningunit",
            user=cls.user
        )

        person_entity = PersonEntityFactory(
            person=cls.person,
            entity=EntityVersionFactory().entity,
        )

        cls.academic_year = create_current_academic_year()
        AcademicCalendarLearningUnitCentralEditionFactory(
            data_year=cls.academic_year,
            start_date=datetime.datetime(cls.academic_year.year - 6, 9, 15),
            end_date=datetime.datetime(cls.academic_year.year + 1, 9, 14)
        )

        cls.luy = LearningUnitYearFullFactory(
            academic_year=cls.academic_year,
            internship_subtype=None,
            acronym="EFAC1000",
            learning_container_year__container_type=EXTERNAL,
            learning_container_year__requirement_entity=person_entity.entity,
        )
        cls.data = get_valid_external_learning_unit_form_data(cls.academic_year, cls.person, cls.luy)

        cls.url = reverse(update_learning_unit, args=[cls.luy.pk])
Beispiel #4
0
    def setUp(self):
        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_edit_learningunit"))
        self.person = CentralManagerFactory(user=self.user)
        self.client.force_login(self.user)

        person_entity = PersonEntityFactory(
            person=self.person,
            entity=EntityVersionFactory().entity,
        )

        self.academic_year = create_current_academic_year()

        luy = LearningUnitYearFullFactory(
            academic_year=self.academic_year,
            internship_subtype=None,
            acronym="EFAC0000",
            learning_container_year__container_type=EXTERNAL,
            learning_container_year__requirement_entity=person_entity.entity,
        )
        self.external = ExternalLearningUnitYearFactory(learning_unit_year=luy)

        self.data = get_valid_external_learning_unit_form_data(
            self.academic_year, self.person, self.external.learning_unit_year)

        self.url = reverse(update_learning_unit,
                           args=[self.external.learning_unit_year.pk])
Beispiel #5
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory(current=True)
        cls.learning_container_year = LearningContainerYearFactory(
            container_type=LearningContainerYearType.COURSE.name,
            academic_year=cls.academic_year)
        cls.person = PersonWithPermissionsFactory('can_access_learningunit')
        cls.learning_unit_year = LearningUnitYearFullFactory(
            learning_container_year=cls.learning_container_year,
            academic_year=cls.academic_year)

        cls.education_group_year = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        cls.group_element_year = GroupElementYearFactory(
            parent=cls.education_group_year,
            child_branch=None,
            child_leaf=cls.learning_unit_year)

        cls.education_group_year_formation_parent = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        GroupElementYearFactory(
            parent=cls.education_group_year_formation_parent,
            child_branch=cls.education_group_year)

        cls.education_group_year_formation_great_parent_1 = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        GroupElementYearFactory(
            parent=cls.education_group_year_formation_great_parent_1,
            child_branch=cls.education_group_year_formation_parent)
        cls.education_group_year_formation_great_parent_2 = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        GroupElementYearFactory(
            parent=cls.education_group_year_formation_great_parent_2,
            child_branch=cls.education_group_year_formation_parent)
Beispiel #6
0
 def setUpTestData(cls):
     cls.learning_unit_year = LearningUnitYearFullFactory()
     cls.lecturing_unit_component = LecturingLearningUnitComponentFactory(
         learning_unit_year=cls.learning_unit_year)
     cls.practical_unit_component = PracticalLearningUnitComponentFactory(
         learning_unit_year=cls.learning_unit_year)
     cls.person = PersonWithPermissionsFactory('can_access_learningunit')
Beispiel #7
0
 def test_fill_acronym_initial_letter_instance(self):
     luy = LearningUnitYearFullFactory(campus=CampusFactory())
     form = LearningUnitYearForExternalModelForm(person=self.person,
                                                 data=None,
                                                 subtype=FULL,
                                                 instance=luy,
                                                 initial={})
     self.assertEqual(form.data['acronym_0'], luy.acronym[0])
Beispiel #8
0
    def test_init(self):
        campus = CampusFactory()
        address = OrganizationAddressFactory(is_main=True, organization=campus.organization)

        luy = LearningUnitYearFullFactory(campus=campus)

        form = LearningUnitYearForExternalModelForm(
            person=self.person, data=None,
            subtype=FULL, instance=luy, initial={})
        self.assertEqual(form.fields["country_external_institution"].initial, address.country.pk)
Beispiel #9
0
 def setUpTestData(cls):
     cls.learning_unit_year = LearningUnitYearFullFactory(
         learning_container_year__container_type=COURSE)
     cls.lecturing_component = LecturingLearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year)
     cls.practical_component = PracticalLearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year)
     cls.person = PersonWithPermissionsFactory('can_access_learningunit')
     cls.tutor = TutorFactory(person=cls.person)
     cls.url = reverse("add_attribution", args=[cls.learning_unit_year.id])
Beispiel #10
0
    def setUpTestData(cls):
        cls.person = PersonWithPermissionsFactory('can_access_learningunit')

        cls.luy_without_attribution = LearningUnitYearFullFactory()

        cls.luy = LearningUnitYearFullFactory()

        cls.lecturing_component = LecturingLearningComponentYearFactory(
            learning_unit_year=cls.luy)
        cls.practical_component = PracticalLearningComponentYearFactory(
            learning_unit_year=cls.luy)
        cls.attribution = AttributionNewFactory(
            learning_container_year=cls.luy.learning_container_year)
        cls.charge_lecturing = AttributionChargeNewFactory(
            attribution=cls.attribution,
            learning_component_year=cls.lecturing_component)
        cls.charge_practical = AttributionChargeNewFactory(
            attribution=cls.attribution,
            learning_component_year=cls.practical_component)
Beispiel #11
0
    def setUpTestData(cls):
        cls.learning_unit_year = LearningUnitYearPartimFactory()
        cls.lecturing_component = LecturingLearningComponentYearFactory(
            learning_unit_year=cls.learning_unit_year)
        cls.practical_component = PracticalLearningComponentYearFactory(
            learning_unit_year=cls.learning_unit_year)

        cls.full_learning_unit_year = LearningUnitYearFullFactory(
            learning_container_year=cls.learning_unit_year.
            learning_container_year,
            academic_year=cls.learning_unit_year.academic_year)
        cls.lecturing_component_full = LecturingLearningComponentYearFactory(
            learning_unit_year=cls.full_learning_unit_year)
        cls.practical_component_full = PracticalLearningComponentYearFactory(
            learning_unit_year=cls.full_learning_unit_year)
        cls.person = PersonWithPermissionsFactory('can_access_learningunit')
Beispiel #12
0
    def setUp(self):
        self.academic_year = AcademicYearFactory(current=True)
        self.learning_container_year = LearningContainerYearFactory(
            container_type=LearningContainerYearType.COURSE.name,
            academic_year=self.academic_year
        )
        self.person = PersonWithPermissionsFactory('can_access_learningunit')
        self.learning_unit_year = LearningUnitYearFullFactory(
            learning_container_year=self.learning_container_year,
            academic_year=self.academic_year
        )

        self.education_group_year = EducationGroupYearFactory(
            academic_year=self.academic_year
        )
        self.group_element_year = GroupElementYearFactory(
            parent=self.education_group_year,
            child_branch=None,
            child_leaf=self.learning_unit_year
        )

        self.education_group_year_formation_parent = EducationGroupYearFactory(
            academic_year=self.academic_year
        )
        GroupElementYearFactory(
            parent=self.education_group_year_formation_parent,
            child_branch=self.education_group_year
        )

        self.education_group_year_formation_great_parent_1 = EducationGroupYearFactory(
            academic_year=self.academic_year
        )
        GroupElementYearFactory(
            parent=self.education_group_year_formation_great_parent_1,
            child_branch=self.education_group_year_formation_parent
        )
        self.education_group_year_formation_great_parent_2 = EducationGroupYearFactory(
            academic_year=self.academic_year
        )
        GroupElementYearFactory(
            parent=self.education_group_year_formation_great_parent_2,
            child_branch=self.education_group_year_formation_parent
        )

        self.client.force_login(self.person.user)
Beispiel #13
0
def step_impl(context, acronym, year, entity):
    campus = Campus.objects.filter(organization__type='MAIN').first()

    e = Entity.objects.filter(entityversion__acronym=entity).first()
    luy = LearningUnitYearFullFactory(
        acronym=acronym,
        campus=campus,
        academic_year=AcademicYear.objects.get(year=year[:4]),
        internship_subtype=None,
        learning_container_year__requirement_entity=e,
        learning_container_year__allocation_entity=e,
    )

    ProposalLearningUnitFactory(
        learning_unit_year=luy,
        type=ProposalType.CREATION.name,
        state=ProposalState.FACULTY.name,
        entity=e,
    )
Beispiel #14
0
    def setUpTestData(cls):
        cls.full_luy = LearningUnitYearFullFactory()
        cls.partim_luy_1 = LearningUnitYearPartimFactory(
            academic_year=cls.full_luy.academic_year,
            learning_container_year=cls.full_luy.learning_container_year)
        cls.partim_luy_2 = LearningUnitYearPartimFactory(
            academic_year=cls.full_luy.academic_year,
            learning_container_year=cls.full_luy.learning_container_year)
        cls.attribution_full = AttributionNewFactory(
            learning_container_year=cls.full_luy.learning_container_year)
        cls.full_lecturing_component = LecturingLearningComponentYearFactory(
            learning_unit_year=cls.full_luy)
        cls.full_practical_component = PracticalLearningComponentYearFactory(
            learning_unit_year=cls.full_luy)

        cls.partim_1_lecturing_component = \
            LecturingLearningComponentYearFactory(learning_unit_year=cls.partim_luy_1)
        cls.partim_1_practical_component = \
            PracticalLearningComponentYearFactory(learning_unit_year=cls.partim_luy_1)

        cls.partim_2_lecturing_component = \
            LecturingLearningComponentYearFactory(learning_unit_year=cls.partim_luy_2)
        cls.partim_2_practical_component = \
            PracticalLearningComponentYearFactory(learning_unit_year=cls.partim_luy_2)

        cls.charge_lecturing = AttributionChargeNewFactory(
            attribution=cls.attribution_full,
            learning_component_year=cls.full_lecturing_component,
            allocation_charge=20)
        cls.charge_practical = AttributionChargeNewFactory(
            attribution=cls.attribution_full,
            learning_component_year=cls.full_practical_component,
            allocation_charge=20)

        cls.attribution_partim_1 = cls.attribution_full
        cls.attribution_partim_1.id = None
        cls.attribution_partim_1.save()

        cls.attribution_partim_2 = cls.attribution_full
        cls.attribution_partim_2.id = None
        cls.attribution_partim_2.save()
Beispiel #15
0
    def test_learning_unit_read_versions(self):
        learning_unit_year = LearningUnitYearFullFactory(
            academic_year=self.current_academic_year, )
        LearningComponentYearFactory(learning_unit_year=learning_unit_year)

        response = self.client.get(
            reverse('learning_unit', args=[learning_unit_year.pk]))
        self.assertEqual(len(response.context['versions']), 0)

        with reversion.create_revision():
            learning_unit_year.learning_container_year.save()

        response = self.client.get(
            reverse('learning_unit', args=[learning_unit_year.pk]))
        self.assertEqual(len(response.context['versions']), 1)

        with reversion.create_revision():
            learning_unit_year.learningcomponentyear_set.first().save()

        response = self.client.get(
            reverse('learning_unit', args=[learning_unit_year.pk]))
        self.assertEqual(len(response.context['versions']), 2)
Beispiel #16
0
 def setUpTestData(cls):
     cls.person = PersonWithPermissionsFactory('can_access_learningunit')
     cls.learning_container_year = LearningContainerYearFactory(
         container_type=LearningContainerYearType.COURSE.name
     )
     cls.learning_unit_year = LearningUnitYearFullFactory(
         learning_container_year=cls.learning_container_year
     )
     cls.lecturing_component = LecturingLearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year)
     cls.practical_component = PracticalLearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year)
     cls.attribution = AttributionNewFactory(
         learning_container_year=cls.learning_unit_year.learning_container_year
     )
     cls.charge_lecturing = AttributionChargeNewFactory(
         attribution=cls.attribution,
         learning_component_year=cls.lecturing_component
     )
     cls.charge_practical = AttributionChargeNewFactory(
         attribution=cls.attribution,
         learning_component_year=cls.practical_component
     )
Beispiel #17
0
class TestEditAttribution(TestCase):
    @classmethod
    def setUpTestData(cls):
        cls.person = PersonWithPermissionsFactory('can_access_learningunit')
        cls.learning_container_year = LearningContainerYearFactory(
            container_type=LearningContainerYearType.COURSE.name
        )

    def setUp(self):

        self.learning_unit_year = LearningUnitYearFullFactory(
            learning_container_year = self.learning_container_year
        )
        self.lecturing_component = LecturingLearningComponentYearFactory(
            learning_unit_year=self.learning_unit_year)
        self.practical_component = PracticalLearningComponentYearFactory(
            learning_unit_year=self.learning_unit_year)
        self.attribution = AttributionNewFactory(
            learning_container_year=self.learning_unit_year.learning_container_year
        )
        self.charge_lecturing = AttributionChargeNewFactory(
            attribution=self.attribution,
            learning_component_year=self.lecturing_component
        )
        self.charge_practical = AttributionChargeNewFactory(
            attribution=self.attribution,
            learning_component_year=self.practical_component
        )

        self.client.force_login(self.person.user)
        self.url = reverse("update_attribution", args=[self.learning_unit_year.id, self.attribution.id])

        self.patcher = patch.object(RulesRequiredMixin, "test_func", return_value=True)
        self.mocked_permission_function = self.patcher.start()

    def tearDown(self):
        self.patcher.stop()

    def test_login_required(self):
        self.client.logout()

        response = self.client.get(self.url)
        self.assertRedirects(response, '/login/?next={}'.format(self.url))

    def test_template_used_with_get(self):
        response = self.client.get(self.url)

        self.assertTrue(self.mocked_permission_function.called)
        self.assertEqual(response.status_code, HttpResponse.status_code)
        self.assertTemplateUsed(response, "learning_unit/attribution_inner.html")

    def test_post(self):
        data = {
            'attribution_form-function': COORDINATOR,
            'attribution_form-start_year': 2018,
            'attribution_form-duration': 3,
            'lecturing_form-allocation_charge': 50,
            'practical_form-allocation_charge': 10
        }
        response = self.client.post(self.url, data=data)

        self.attribution.refresh_from_db()
        self.charge_lecturing.refresh_from_db()
        self.charge_practical.refresh_from_db()
        self.assertEqual(self.attribution.function, COORDINATOR)
        self.assertEqual(self.attribution.start_year, 2018)
        self.assertEqual(self.attribution.end_year, 2020)
        self.assertEqual(self.charge_lecturing.allocation_charge, 50)
        self.assertEqual(self.charge_practical.allocation_charge, 10)

        self.assertRedirects(response,
                             reverse("learning_unit_attributions", args=[self.learning_unit_year.id]))

    def test_post_partim(self):
        self.learning_unit_year.subtype = PARTIM
        self.learning_unit_year.save()
        data = {
            'attribution_form-function': COORDINATOR,
            'lecturing_form-allocation_charge': 50,
            'practical_form-allocation_charge': 10
        }
        response = self.client.post(self.url, data=data)

        self.attribution.refresh_from_db()
        self.charge_lecturing.refresh_from_db()
        self.charge_practical.refresh_from_db()
        self.assertEqual(self.charge_lecturing.allocation_charge, 50)
        self.assertEqual(self.charge_practical.allocation_charge, 10)

        self.assertRedirects(response,
                             reverse("learning_unit_attributions", args=[self.learning_unit_year.id]))