예제 #1
0
파일: test_views.py 프로젝트: adlius/osf.io
    def test_reindex_registration_share(self):
        count = AdminLogEntry.objects.count()
        view = NodeReindexShare()
        view = setup_log_view(view, self.request, guid=self.registration._id)
        view.delete(self.request)

        nt.assert_false(self.mock_reindex_node.called)
        nt.assert_true(self.mock_reindex_registration.called)
        nt.assert_equal(AdminLogEntry.objects.count(), count + 1)
예제 #2
0
    def test_reindex_registration_share(self, mock_update_share, mock_format_registration, mock_format_node):
        count = AdminLogEntry.objects.count()
        view = NodeReindexShare()
        view = setup_log_view(view, self.request, guid=self.registration._id)
        view.delete(self.request)

        nt.assert_true(mock_update_share.called)
        nt.assert_false(mock_format_node.called)
        nt.assert_true(mock_format_registration.called)
        nt.assert_equal(AdminLogEntry.objects.count(), count + 1)
예제 #3
0
    def test_reindex_node_share(self):
        count = AdminLogEntry.objects.count()
        view = NodeReindexShare()
        view = setup_log_view(view, self.request, guid=self.node._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.delete(self.request)
                    data = json.loads(rsps.calls[-1].request.body.decode())

                    assert data['data']['attributes']['data']['@graph'][0]['creative_work']['@type'] == 'project'
                    nt.assert_equal(AdminLogEntry.objects.count(), count + 1)