Esempio n. 1
0
    def test_ReportingOrganisationSerializer(self):
        pub = PublisherFactory()

        org = pub.organisation
        serializer = serializers.ReportingOrganisationSerializer(
            org, context={'request': self.request_dummy})

        desired_url = reverse(
            'organisations:organisation-detail',
            kwargs={'pk': org.organisation_identifier},
        )

        self.assertEqual(
            serializer.data, {
                'id':
                org.id,
                'ref':
                org.organisation_identifier,
                'url':
                'http://testserver{0}'.format(desired_url),
                'type':
                OrderedDict([('code', org.type.code),
                             ('name', org.type.name)]),
                'narratives': []
            })
Esempio n. 2
0
    def test_ReportingOrganisationSerializer(self):
        reporting_organisation = iati_factory.ReportingOrganisationFactory.build(
        )

        data = serializers.ReportingOrganisationSerializer(
            reporting_organisation).data
        assert data['secondary_reporter'] == reporting_organisation.secondary_reporter,\
            """
            reporting_organisation.seconary_reporter should be serialized to a field
            called 'secondary_reporter' by the ReportingOrganisationSerializer
            """
        # assert 'organisation' in data, \
        #     """
        #     serializer.data should contain an object called 'organisation'
        #     """
        assert 'ref' and 'type' in data, \
            """