def test_resolve_doi(self):
        self.user_creator = hydroshare.create_account(
            '*****@*****.**',
            username='******',
            first_name='Creator_FirstName',
            last_name='Creator_LastName',
            superuser=False,
            groups=[]
        )

        new_resource = hydroshare.create_resource(
            'GenericResource',
            self.user_creator,
            'My Test Resource'
        )

        # assign doi to the resource
        new_resource.doi = 'xyz'
        new_resource.save()
        # test that the api call resolve_doi() returns the short_id of the resource when we pass the
        # resource doi in this api call
        self.assertEqual(new_resource.short_id, hydroshare.resolve_doi(new_resource.doi))

        # test the exception 'Http404' is raised when we make the api call
        # passing a random doi ( e.g., '123') that does not exist
        with self.assertRaises(Http404):
            hydroshare.resolve_doi("123")
    def test_resolve_doi(self):
        self.user_creator = hydroshare.create_account(
            '*****@*****.**',
            username='******',
            first_name='Creator_FirstName',
            last_name='Creator_LastName',
            superuser=False,
            groups=[])

        new_resource = hydroshare.create_resource('GenericResource',
                                                  self.user_creator,
                                                  'My Test Resource')

        # assign doi to the resource
        new_resource.doi = 'xyz'
        new_resource.save()
        # test that the api call resolve_doi() returns the short_id of the resource when we pass the
        # resource doi in this api call
        self.assertEqual(new_resource.short_id,
                         hydroshare.resolve_doi(new_resource.doi))

        # test the exception 'Http404' is raised when we make the api call
        # passing a random doi ( e.g., '123') that does not exist
        with self.assertRaises(Http404):
            hydroshare.resolve_doi("123")
Example #3
0
    def test_resolve_doi(self):
        # create a user to be used for creating the resource
        user_creator = hydroshare.create_account(
            "*****@*****.**",
            username="******",
            first_name="Creator_FirstName",
            last_name="Creator_LastName",
            superuser=False,
            groups=[],
        )

        # create a resource
        new_resource = hydroshare.create_resource("GenericResource", user_creator, "My Test Resource")

        # test that the api call resolve_doi() returns the short_id of the resource when we pass the
        # resource doi in this api call
        self.assertEqual(new_resource.short_id, hydroshare.resolve_doi(new_resource.doi))

        # test the exception 'ObjectDoesNotExit' is raised when we make the api call
        # passing a random doi ( e.g., '123') that does not exist
        self.assertRaises(ObjectDoesNotExist, lambda: hydroshare.resolve_doi("123"))
    def test_resolve_doi(self):
        # create a user to be used for creating the resource
        user_creator = hydroshare.create_account(
            '*****@*****.**',
            username='******',
            first_name='Creator_FirstName',
            last_name='Creator_LastName',
            superuser=False,
            groups=[])

        # create a resource
        new_resource = hydroshare.create_resource('GenericResource',
                                                  user_creator,
                                                  'My Test Resource')

        # test that the api call resolve_doi() returns the short_id of the resource when we pass the
        # resource doi in this api call
        self.assertEqual(new_resource.short_id,
                         hydroshare.resolve_doi(new_resource.doi))

        # test the exception 'ObjectDoesNotExit' is raised when we make the api call
        # passing a random doi ( e.g., '123') that does not exist
        self.assertRaises(ObjectDoesNotExist,
                          lambda: hydroshare.resolve_doi("123"))
Example #5
0
 def resolve_doi(self, doi):
     return HttpResponse(hydroshare.resolve_doi(doi), content_type='text/plain')
Example #6
0
 def resolve_doi(self, doi):
     return HttpResponse(hydroshare.resolve_doi(doi),
                         content_type='text/plain')