예제 #1
0
    def test_get_contacts_group_by_types_assert_order(self):
        results = business.get_contacts_group_by_types(
            self.education_group_year, settings.LANGUAGE_CODE_FR)

        self.assertIsInstance(results, dict)
        self.assertTrue(results['academic_responsibles'])

        academic_responsibles = results['academic_responsibles']
        self.assertIsInstance(academic_responsibles, list)
        self.assertEqual(len(academic_responsibles), 2)

        self.assertEqual(academic_responsibles[0]['email'],
                         self.academic_responsible_1.email)
        self.assertEqual(academic_responsibles[1]['email'],
                         self.academic_responsible_2.email)

        # Swap result...
        self.academic_responsible_2.up()

        results = business.get_contacts_group_by_types(
            self.education_group_year, settings.LANGUAGE_CODE_FR)
        academic_responsibles = results['academic_responsibles']
        self.assertEqual(academic_responsibles[0]['email'],
                         self.academic_responsible_2.email)
        self.assertEqual(academic_responsibles[1]['email'],
                         self.academic_responsible_1.email)
예제 #2
0
 def test_get_contacts_group_by_types_assert_english_returned(self):
     results = business.get_contacts_group_by_types(
         self.education_group_year, settings.LANGUAGE_CODE_EN)
     academic_responsibles = results['academic_responsibles']
     self.assertEqual(academic_responsibles[0]['role'],
                      self.academic_responsible_1.role_en)
     self.assertEqual(academic_responsibles[1]['role'],
                      self.academic_responsible_2.role_en)
예제 #3
0
    def test_get_contacts_group_by_types_assert_empty_str_as_null(self):
        self.academic_responsible_1.role_fr = ''
        self.academic_responsible_1.description = ''
        self.academic_responsible_1.save()

        results = business.get_contacts_group_by_types(self.education_group_year, settings.LANGUAGE_CODE_FR)
        academic_responsibles = results['academic_responsibles']
        self.assertIsNone(academic_responsibles[0]['role'])
        self.assertIsNone(academic_responsibles[0]['description'])
예제 #4
0
def get_contacts(education_group_year, language_code):
    contacts = business.get_contacts_group_by_types(education_group_year, language_code)
    intro_content = business.get_contacts_intro_text(education_group_year, language_code)
    entity_version = education_group_year.publication_contact_entity_version

    return {
        'id': business.CONTACTS_KEY,
        'label': business.CONTACTS_KEY,
        'content': {
            'text': intro_content,
            'entity': entity_version.acronym if entity_version else None,
            'contacts': contacts
        }
    }
예제 #5
0
 def test_get_contacts_group_by_types_no_data(self):
     education_group_year = EducationGroupYearFactory()
     self.assertDictEqual(
         business.get_contacts_group_by_types(education_group_year, settings.LANGUAGE_CODE_FR),
         {}
     )