コード例 #1
0
 def setUp(self):
     self.simple_acronym_input = 'DROI1BA'
     self.simple_acronym = "DROI1BA"
     self.complex_acronym_input = 'DROI2MS_G'
     self.complex_acronym = "DROI2MS/G"
     self.invalid_acronym_input = "BIR1BA"
     self.acronym_with_space_input = "IAG IS"
     self.acronym_with_space = "IAG IS"
     self.valid_year = 2017
     self.invalid_year = 2020
     self.person = PersonFactory()
     students_group = Group.objects.create(name="students")
     permission = Permission.objects.get(codename="is_student")
     students_group.permissions.add(permission)
     self.student = StudentFactory()
     self.student_performance = StudentPerformanceFactory(
         registration_id=self.student.registration_id,
         academic_year=self.valid_year,
         acronym=self.simple_acronym)
     self.student_performance_complex = StudentPerformanceFactory(
         registration_id=self.student.registration_id,
         academic_year=self.valid_year,
         acronym=self.complex_acronym)
     self.student_performance_with_space = StudentPerformanceFactory(
         registration_id=self.student.registration_id,
         academic_year=self.valid_year,
         acronym=self.acronym_with_space)
コード例 #2
0
ファイル: test_main.py プロジェクト: dukku1/osis-portal
 def setUp(self):
     self.person = PersonFactory()
     self.person.user.user_permissions.add(
         Permission.objects.get(codename="is_faculty_administrator"))
     self.student_performance = StudentPerformanceFactory(acronym='CHIM1BA')
     self.url = reverse('performance_student_result_admin',
                        args=[self.student_performance.pk])
コード例 #3
0
    def setUp(self):
        students_group = Group.objects.create(name="students")
        permission = Permission.objects.get(codename="is_student")
        students_group.permissions.add(permission)

        self.student = StudentFactory()
        self.student_performance = StudentPerformanceFactory(
            registration_id=self.student.registration_id)

        self.url = reverse('performance_student_result',
                           args=[self.student_performance.pk])
        self.client.force_login(self.student.person.user)
コード例 #4
0
ファイル: test_main.py プロジェクト: dukku1/osis-portal
    def setUp(self):
        self.person = PersonFactory()
        self.person.user.user_permissions.add(
            Permission.objects.get(codename="is_faculty_administrator"))
        Group.objects.create(name="students")
        self.student = StudentFactory()
        self.student_performance = StudentPerformanceFactory(
            registration_id=self.student.registration_id, academic_year=2017)

        self.url = reverse('performance_student_programs_admin',
                           args=[self.student.registration_id])
        self.client.force_login(self.person.user)
コード例 #5
0
ファイル: model.py プロジェクト: kelvinninja1/osis-portal
 def __create_random_perfs(student, count_perf, authorized_results,
                           course_registration_validated,
                           learning_units_outside_catalog, fetch_timed_out):
     academic_year = datetime.datetime.today().year
     if not count_perf:
         count_perf = random.randint(1, 10)
     for idx in range(count_perf):
         StudentPerformanceFactory(
             registration_id=student.registration_id,
             academic_year=academic_year - idx,
             authorized=authorized_results,
             courses_registration_validated=course_registration_validated,
             learning_units_outside_catalog=learning_units_outside_catalog)
コード例 #6
0
ファイル: test_main.py プロジェクト: dukku1/osis-portal
 def test_user_is_manager_program_ok(self):
     a_person = PersonFactory()
     a_student_performance = StudentPerformanceFactory(academic_year=2017,
                                                       acronym='PHYS1BA')
     url = reverse('performance_student_result_admin',
                   args=[a_student_performance.pk])
     self.client.force_login(a_person.user)
     session = self.client.session
     session['is_faculty_manager'] = True
     session['managed_programs'] = json.dumps(
         {
             '2017': ['PHYS1BA', 'BIOL1BA'],
             '2018': ['PHYS1BA', 'BIOL1BA']
         },
         cls=DjangoJSONEncoder)
     session.save()
     response = self.client.get(url)
     self.assertEqual(response.status_code, OK)
     self.assertTemplateUsed(response,
                             'admin/performance_result_admin.html')
コード例 #7
0
    def test_with_program_list(self):
        a_student_performance = StudentPerformanceFactory(
            registration_id=self.student.registration_id, academic_year=2017)

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

        self.assertTemplateUsed(response, 'performance_home_student.html')
        self.assertEqual(response.status_code, OK)

        self.assertEqual(response.context['student'], self.student)
        self.assertEqual(response.context['programs'], [{
            'academic_year':
            '2017 - 2018',
            'acronym':
            a_student_performance.acronym,
            'offer_registration_state':
            'CESSATION',
            'pk':
            a_student_performance.pk,
            'title':
            ' Master [120] en sciences informatiques, à finalité spécialisée '
        }])
        self.assertEqual(response.context['registration_states_to_show'],
                         offer_registration_state.STATES_TO_SHOW_ON_PAGE)
コード例 #8
0
class VisualizeStudentResult(TestCase):
    def setUp(self):
        self.person = PersonFactory()
        self.person.user.user_permissions.add(
            Permission.objects.get(codename="is_faculty_administrator"))
        self.student_performance = StudentPerformanceFactory()

        self.url = reverse('performance_student_result_admin',
                           args=[self.student_performance.pk])

        self.client.force_login(self.person.user)

    def test_user_not_logged(self):
        self.client.logout()
        response = self.client.get(self.url)
        self.assertRedirects(response, "/login/?next={}".format(self.url))

    def test_user_has_not_permission(self):
        a_person = PersonFactory()
        self.client.force_login(a_person.user)

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

        self.assertEqual(response.status_code, ACCESS_DENIED)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_no_corresponding_student_performance(self):
        self.student_performance.delete()

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

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response,
                                'admin/performance_result_admin.html')

        self.assertEqual(response.context['results'], None)
        self.assertEqual(response.context['creation_date'], None)
        self.assertEqual(response.context['update_date'], None)
        self.assertEqual(response.context['fetch_timed_out'], None)
        self.assertEqual(response.context['not_authorized_message'], None)

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

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response,
                                'admin/performance_result_admin.html')

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        self.assertEqual(response.context['not_authorized_message'], None)

    def test_with_not_authorized_message(self):
        self.student_performance.authorized = False
        self.student_performance.save()

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

        self.assertTemplateUsed(response,
                                'admin/performance_result_admin.html')
        self.assertEqual(response.status_code, OK)

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        self.assertEqual(
            response.context['not_authorized_message'],
            _('performance_result_note_not_autorized').format(
                _(self.student_performance.session_locked)))
コード例 #9
0
class VisualizeStudentPrograms(TestCase):
    def setUp(self):
        self.person = PersonFactory()
        self.person.user.user_permissions.add(
            Permission.objects.get(codename="is_faculty_administrator"))
        Group.objects.create(name="students")
        self.student = StudentFactory()
        self.student_performance = StudentPerformanceFactory(
            registration_id=self.student.registration_id, academic_year=2017)

        self.url = reverse('performance_student_programs_admin',
                           args=[self.student.registration_id])

        self.client.force_login(self.person.user)

    def test_user_not_logged(self):
        self.client.logout()
        response = self.client.get(self.url)
        self.assertRedirects(response, "/login/?next={}".format(self.url))

    def test_user_has_not_permission(self):
        a_person = PersonFactory()
        self.client.force_login(a_person.user)

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

        self.assertEqual(response.status_code, ACCESS_DENIED)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_with_no_corresponding_student(self):
        self.student.delete()

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

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response, 'admin/performance_home_admin.html')

        self.assertEqual(response.context['student'], None)
        self.assertEqual(response.context['programs'], None)
        self.assertEqual(response.context['registration_states_to_show'],
                         offer_registration_state.STATES_TO_SHOW_ON_PAGE)

    def test_when_empty_programs_list(self):
        self.student_performance.delete()

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

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response, 'admin/performance_home_admin.html')

        self.assertEqual(response.context['student'], self.student)
        self.assertEqual(response.context['programs'], [])
        self.assertEqual(response.context['registration_states_to_show'],
                         offer_registration_state.STATES_TO_SHOW_ON_PAGE)

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

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response, 'admin/performance_home_admin.html')

        self.assertEqual(response.context['student'], self.student)
        self.assertEqual(response.context['programs'], [{
            'academic_year':
            '2017 - 2018',
            'acronym':
            self.student_performance.acronym,
            'offer_registration_state':
            'CESSATION',
            'pk':
            self.student_performance.pk,
            'title':
            ' Master [120] en sciences informatiques, à finalité spécialisée '
        }])
        self.assertEqual(response.context['registration_states_to_show'],
                         offer_registration_state.STATES_TO_SHOW_ON_PAGE)
コード例 #10
0
class DisplayResultForSpecificStudentPerformanceTest(TestCase):
    def setUp(self):
        students_group = Group.objects.create(name="students")
        permission = Permission.objects.get(codename="is_student")
        students_group.permissions.add(permission)

        self.student = StudentFactory()
        self.student_performance = StudentPerformanceFactory(
            registration_id=self.student.registration_id)

        self.url = reverse('performance_student_result',
                           args=[self.student_performance.pk])
        self.client.force_login(self.student.person.user)

    def test_user_not_logged(self):
        self.client.logout()
        response = self.client.get(self.url, follow=True)
        self.assertRedirects(response, "/login/?next={}".format(self.url))

    def test_user_not_a_student(self):
        a_person = PersonFactory()
        self.client.logout()
        self.client.force_login(a_person.user)

        response = self.client.get(self.url, follow=True)

        self.assertEqual(response.status_code, ACCESS_DENIED)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_multiple_students_objects_for_one_user(self):
        StudentFactory(person=self.student.person)

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

        self.assertTemplateUsed(response, 'dashboard.html')

        messages = list(response.context['messages'])

        self.assertEqual(len(messages), 1)
        self.assertEqual(messages[0].tags, 'error')
        self.assertEqual(messages[0].message,
                         _('error_multiple_registration_id'))

    def test_when_none_student_performance(self):
        self.student_performance.delete()

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

        self.assertTemplateUsed(response, 'access_denied.html')
        self.assertEqual(response.status_code, ACCESS_DENIED)

    def test_when_trying_to_access_other_student_performance(self):
        an_other_student = StudentFactory()
        self.client.force_login(an_other_student.person.user)

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

        self.assertTemplateUsed(response, 'access_denied.html')
        self.assertEqual(response.status_code, ACCESS_DENIED)

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

        self.assertTemplateUsed(response, 'performance_result_student.html')
        self.assertEqual(response.status_code, OK)

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        self.assertEqual(response.context['not_authorized_message'], None)

    def test_with_not_authorized_message(self):
        self.student_performance.authorized = False
        self.student_performance.save()

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

        self.assertTemplateUsed(response, 'performance_result_student.html')
        self.assertEqual(response.status_code, OK)

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        self.assertEqual(
            response.context['not_authorized_message'],
            _('performance_result_note_not_autorized').format(
                _(self.student_performance.session_locked)))
コード例 #11
0
ファイル: test_main.py プロジェクト: dukku1/osis-portal
class VisualizeStudentResult(TestCase):
    def setUp(self):
        self.person = PersonFactory()
        self.person.user.user_permissions.add(
            Permission.objects.get(codename="is_faculty_administrator"))
        self.student_performance = StudentPerformanceFactory(acronym='CHIM1BA')
        self.url = reverse('performance_student_result_admin',
                           args=[self.student_performance.pk])

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

    def test_user_not_logged(self):
        response = self.client.get(self.url)
        self.assertRedirects(response, "/login/?next={}".format(self.url))

    def test_user_has_not_permission(self):
        a_person = PersonFactory()
        self.client.force_login(a_person.user)

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

        self.assertEqual(response.status_code, ACCESS_DENIED)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_user_is_manager_wrong_program(self):
        a_person = PersonFactory()
        self.client.force_login(a_person.user)
        session = self.client.session
        session['is_faculty_manager'] = True
        session['managed_programs'] = json.dumps(
            {
                '2017': ['PHYS1BA', 'BIOL1BA'],
                '2018': ['PHYS1BA', 'BIOL1BA']
            },
            cls=DjangoJSONEncoder)
        session.save()
        response = self.client.get(self.url)
        self.assertEqual(response.status_code, ACCESS_DENIED)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_user_is_manager_program_ok(self):
        a_person = PersonFactory()
        a_student_performance = StudentPerformanceFactory(academic_year=2017,
                                                          acronym='PHYS1BA')
        url = reverse('performance_student_result_admin',
                      args=[a_student_performance.pk])
        self.client.force_login(a_person.user)
        session = self.client.session
        session['is_faculty_manager'] = True
        session['managed_programs'] = json.dumps(
            {
                '2017': ['PHYS1BA', 'BIOL1BA'],
                '2018': ['PHYS1BA', 'BIOL1BA']
            },
            cls=DjangoJSONEncoder)
        session.save()
        response = self.client.get(url)
        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response,
                                'admin/performance_result_admin.html')

    def test_no_corresponding_student_performance(self):
        self.student_performance.delete()
        self.client.force_login(self.person.user)
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response,
                                'admin/performance_result_admin.html')

        self.assertEqual(response.context['results'], None)
        self.assertEqual(response.context['creation_date'], None)
        self.assertEqual(response.context['update_date'], None)
        self.assertEqual(response.context['fetch_timed_out'], None)
        self.assertEqual(response.context['not_authorized_message'], None)

    def test_when_found_student_performance(self):
        self.client.force_login(self.person.user)
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response,
                                'admin/performance_result_admin.html')

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        self.assertEqual(response.context['not_authorized_message'], None)

    def test_with_not_authorized_message(self):
        self.student_performance.authorized = False
        self.student_performance.save()
        self.client.force_login(self.person.user)
        response = self.client.get(self.url)

        self.assertTemplateUsed(response,
                                'admin/performance_result_admin.html')
        self.assertEqual(response.status_code, OK)

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        response_message = _(
            'The publication of the notes from the %(session_month)s session was not authorized by our faculty.') \
                           % {"session_month": self.student_performance.get_session_locked_display()}
        self.assertEqual(response.context['not_authorized_message'],
                         response_message)
コード例 #12
0
ファイル: test_main.py プロジェクト: dukku1/osis-portal
class DisplayResultForSpecificStudentPerformanceTest(TestCase):
    def setUp(self):
        students_group = Group.objects.create(name="students")
        permission = Permission.objects.get(codename="is_student")
        students_group.permissions.add(permission)

        self.student = StudentFactory()
        self.student_performance = StudentPerformanceFactory(
            registration_id=self.student.registration_id)

        self.url = reverse('performance_student_result',
                           args=[self.student_performance.pk])
        self.client.force_login(self.student.person.user)

    def test_user_not_logged(self):
        self.client.logout()
        response = self.client.get(self.url, follow=True)
        self.assertRedirects(response, "/login/?next={}".format(self.url))

    def test_user_not_a_student(self):
        a_person = PersonFactory()
        self.client.logout()
        self.client.force_login(a_person.user)

        response = self.client.get(self.url, follow=True)

        self.assertEqual(response.status_code, ACCESS_DENIED)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_multiple_students_objects_for_one_user(self):
        StudentFactory(person=self.student.person)
        msg = _(
            "A problem was detected with your registration : 2 registration id's are linked to your user. Please "
            "contact the registration departement (SIC). Thank you.")

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

        self.assertTemplateUsed(response, 'dashboard.html')

        messages = list(response.context['messages'])

        self.assertEqual(len(messages), 1)
        self.assertEqual(messages[0].tags, 'error')
        self.assertEqual(messages[0].message, msg)

    def test_when_none_student_performance(self):
        self.student_performance.delete()

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

        self.assertTemplateUsed(response, 'access_denied.html')
        self.assertEqual(response.status_code, ACCESS_DENIED)

    def test_when_trying_to_access_other_student_performance(self):
        an_other_student = StudentFactory()
        self.client.force_login(an_other_student.person.user)

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

        self.assertTemplateUsed(response, 'access_denied.html')
        self.assertEqual(response.status_code, ACCESS_DENIED)

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

        self.assertTemplateUsed(response, 'performance_result_student.html')
        self.assertEqual(response.status_code, OK)

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        self.assertEqual(response.context['not_authorized_message'], None)

    def test_with_not_authorized_message(self):
        self.student_performance.authorized = False
        self.student_performance.save()

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

        self.assertTemplateUsed(response, 'performance_result_student.html')
        self.assertEqual(response.status_code, OK)

        self.assertJSONEqual(response.context['results'],
                             json.dumps(self.student_performance.data))
        self.assertEqual(response.context['creation_date'],
                         self.student_performance.creation_date)
        self.assertEqual(response.context['update_date'],
                         self.student_performance.update_date)
        self.assertEqual(response.context['fetch_timed_out'], False)
        response_message = _(
            'The publication of the notes from the %(session_month)s session was not authorized by our faculty.') \
                           % {"session_month": self.student_performance.get_session_locked_display()}
        self.assertEqual(response.context['not_authorized_message'],
                         response_message)