def test_save_qualifications_duplicate(self): """ It should not save a duplicate qualification. """ saqas = [ ModelFactories.get_saqa_qualification_test_object(), SAQAQualification.objects.create( name='Hello World', nqf_level='42', saqa_id=42, sub_field_of_study=( ModelFactories.get_sub_field_of_study_test_object( new_id=42)), ) ] # build form data form_data = {'saqa_ids': '{}'.format(saqas[0].id)} # save two times with same saqa_ids self.campus.save_qualifications(form_data, self.user) self.campus.save_qualifications(form_data, self.user) self.assertEqual(len(self.campus.qualifications), 1) form_data = {'saqa_ids': '{} {}'.format(saqas[0].id, saqas[1].id)} # save with a new saqa_id self.campus.save_qualifications(form_data, self.user) self.assertEqual(len(self.campus.qualifications), 2)
def test_save_qualifications(self): # create two SAQA Qualifications saqas = [ ModelFactories.get_saqa_qualification_test_object(), SAQAQualification.objects.create( name='Hello World', nqf_level='42', saqa_id=42, sub_field_of_study=( ModelFactories.get_sub_field_of_study_test_object( new_id=42)), ) ] # build form data form_data = {'saqa_ids': '{} {}'.format(saqas[0].id, saqas[1].id)} # campus should not have qualifications yet. self.assertQuerysetEqual(self.campus.qualifications, []) # save qualifications self.campus.save_qualifications(form_data, self.user) # campus should have 2 qualifications. self.assertEqual(len(self.campus.qualifications), 2)
def test_delete_qualifications(self): saqas = [ ModelFactories.get_saqa_qualification_test_object(), SAQAQualification.objects.create( name='Hello World', nqf_level='42', saqa_id=42, sub_field_of_study=( ModelFactories.get_sub_field_of_study_test_object( new_id=42)), ) ] # build form data form_data = {'saqa_ids': '{} {}'.format(saqas[0].id, saqas[1].id)} self.campus.save_qualifications(form_data, self.user) self.assertEqual(len(self.campus.qualifications), 2) # add those two qualifications to another campus self.other_campus = ModelFactories.get_campus_test_object(new_id=421) self.other_campus.save_qualifications(form_data, self.user) form_data = {'saqa_ids': '{}'.format(saqas[1].id)} # it should remove the first saqa for the first campus. self.campus.delete_qualifications(form_data) self.assertEqual(len(self.campus.qualifications), 1) self.assertEqual( self.campus.qualifications[0]['saqa_qualification__saqa_id'], 42) # it should not remove qualifications for the second campus. self.assertEqual(len(self.other_campus.qualifications), 2)
def test_create_non_accredited_saqa_qualification_with_subfield(self): self.assertEqual(len(SAQAQualification.objects.all()), 0) sfos = ModelFactories.get_sub_field_of_study_test_object() self.data['fos_id'] = sfos.field_of_study.id self.data['sfos_id'] = sfos.id saqa_qualif = SAQAQualification.create_non_accredited(self.data) self.assertFalse(saqa_qualif.accredited) self.assertEqual(saqa_qualif.creator_provider_id, self.provider.id) self.assertEqual(saqa_qualif.field_of_study_id, sfos.field_of_study.id) self.assertEqual(saqa_qualif.sub_field_of_study_id, sfos.id) self.assertEqual(len(SAQAQualification.objects.all()), 1)
def test_sub_field_of_study_description(self): new_sub_f_study = ModelFactories.get_sub_field_of_study_test_object() self.assertEqual(new_sub_f_study.__str__(), 'Object Test Name')
def setUp(self): self.sfos = ModelFactories.get_sub_field_of_study_test_object() self.url = reverse('list-sfos', args=[str(self.sfos.field_of_study.id)])