def test_get_registrations_by_free_text(self): self._create_admissions_for_free_text_search() for admission in self.admissions_free_text: admission.state = ACCEPTED admission.save() form = RegistrationFilterForm({"free_text": "testtext"}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, self.admissions_free_text)
def test_get_registrations_by_faculty_and_formation_criteria(self): form = RegistrationFilterForm({ "faculty": self.fac_1_version.id, "formation": self.registrations[0].formation.id }) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, [self.registrations[0]]) form = RegistrationFilterForm({ "faculty": self.fac_1_version.id, "formation": self.registration_validated.formation.id }) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, [])
def test_get_registration_received_file_param(self): self.registrations[0].registration_file_received = True self.registrations[0].save() form = RegistrationFilterForm({"registration_file_received": True}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, [self.registrations[0]]) form = RegistrationFilterForm({"registration_file_received": False}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual( results, [self.registrations[1], self.registration_validated]) form = RegistrationFilterForm({}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, [ self.registrations[0], self.registrations[1], self.registration_validated ])
def list_registrations(request): search_form = RegistrationFilterForm(request.GET, user=request.user) user_is_continuing_education_student_worker = is_continuing_education_student_worker(request.user) admission_list = Admission.registration_objects.all() if search_form.is_valid(): admission_list = search_form.get_registrations() if not user_is_continuing_education_student_worker: admission_list = filter_authorized_admissions(request.user, admission_list) if request.GET.get('xls_status') == "xls_registrations": return export_registrations(request, admission_list, search_form) return render(request, "registrations.html", { 'admissions': get_object_list(request, admission_list), 'admissions_number': admission_list.count(), 'search_form': search_form, 'user_is_continuing_education_student_worker': user_is_continuing_education_student_worker, 'ucl_registration_state_choices': UCLRegistrationState.__members__ })
def test_get_registrations_by_state(self): form = RegistrationFilterForm({"state": ACCEPTED}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, [self.registrations[0]])
def test_get_registrations_by_ucl_registration_complete_criteria(self): form = RegistrationFilterForm({"ucl_registration_complete": True}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, [self.registrations[0]])
def test_get_registrations_by_faculty_criteria(self): form = RegistrationFilterForm({"faculty": self.fac_1_version.id}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(list(results), self.registrations)
def test_get_registrations_by_formation_criteria(self): form = RegistrationFilterForm( {"formation": self.registrations[0].formation.id}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertListEqual(list(results), [self.registrations[0]])
def test_get_registrations_no_criteria(self): form = RegistrationFilterForm({}) self.assertTrue(form.is_valid()) results = form.get_registrations() self.assertCountEqual(results, self.all_registrations_expected)