def test_data_is_loaded_if_all_goes_fine(self):
        modelfactories.CollectionMetaFactory.create(**{
                'resource_uri': u'/api/v1/collections/1/',
                'name': u'Saúde Pública',
                'name_slug': u'saude-publica',
                'is_member': True,
            })

        mocker_scieloapi = self.mocker.mock()

        mocker_scieloapi(settings=mocker.ANY)
        self.mocker.result(mocker_scieloapi)

        mocker_scieloapi.get_all_journals(u'saude-publica')
        self.mocker.result([
            {
                'resource_uri': u'/api/v1/journals/1/',
                'title': u"Annali dell'Istituto Superiore di Sanit\xe0",
                'collections': u'/api/v1/collections/1/',
            }
        ])

        self.mocker.replay()

        sync_journals_meta(managerapi_dep=mocker_scieloapi)

        self.assertEqual(models.JournalMeta.objects.count(), 1)
Beispiel #2
0
    def sync_journalsmeta(self, request):
        sync_journals_meta()

        messages.info(request, 'The list of journals is now up-to-date.')
        return HttpResponseRedirect(
            urlresolvers.reverse('admin:catalog_journalmeta_changelist')
        )
    def test_bypass_journals_with_non_member_collections(self):
        modelfactories.CollectionMetaFactory.create(**{
                'resource_uri': u'/api/v1/collections/1/',
                'name': u'Saúde Pública',
                'name_slug': u'saude-publica',
                'is_member': False,
            })

        mocker_scieloapi = self.mocker.mock()

        mocker_scieloapi(settings=mocker.ANY)
        self.mocker.result(mocker_scieloapi)

        mocker_scieloapi.get_all_journals()
        self.mocker.result([])

        self.mocker.replay()

        sync_journals_meta(managerapi_dep=mocker_scieloapi)

        self.assertEqual(models.JournalMeta.objects.count(), 0)