コード例 #1
0
ファイル: test_views.py プロジェクト: sergiy-neurohub/osf.io
    def test_reindex_preprint_share(self, mock_reindex_preprint, preprint, req):
        preprint.provider.access_token = 'totally real access token I bought from a guy wearing a trenchcoat in the summer'
        preprint.provider.save()

        count = AdminLogEntry.objects.count()
        view = views.PreprintReindexShare()
        view = setup_log_view(view, req, guid=preprint._id)
        view.delete(req)

        assert mock_reindex_preprint.called
        assert AdminLogEntry.objects.count() == count + 1
コード例 #2
0
    def test_reindex_preprint_share(self, mock_reindex_preprint):
        self.preprint.provider.access_token = 'totally real access token I bought from a guy wearing a trenchcoat in the summer'
        self.preprint.provider.save()

        count = AdminLogEntry.objects.count()
        view = views.PreprintReindexShare()
        view = setup_log_view(view, self.request, guid=self.preprint._id)
        view.delete(self.request)

        nt.assert_true(mock_reindex_preprint.called)
        nt.assert_equal(AdminLogEntry.objects.count(), count + 1)
コード例 #3
0
ファイル: test_views.py プロジェクト: jwalz/osf.io
    def test_reindex_preprint_share(self, preprint, req):
        preprint.provider.access_token = 'totally real access token I bought from a guy wearing a trenchcoat in the summer'
        preprint.provider.save()

        count = AdminLogEntry.objects.count()
        view = views.PreprintReindexShare()
        view = setup_log_view(view, req, guid=preprint._id)

        with mock.patch('api.share.utils.settings.SHARE_ENABLED', True):
            with mock.patch('api.share.utils.settings.SHARE_API_TOKEN',
                            'mock-api-token'):
                with responses.RequestsMock(
                        assert_all_requests_are_fired=True) as rsps:
                    rsps.add(responses.POST,
                             'https://share.osf.io/api/v2/normalizeddata/')
                    view.post(req)
                    data = json.loads(rsps.calls[0].request.body.decode())
                    assert data['data']['type'] == 'NormalizedData'
                    assert AdminLogEntry.objects.count() == count + 1