コード例 #1
0
 def test_get_resource(self):
     # function to test: hydroshare.get_resource() which returns a Bags object (not the actual bag file)
     # TODO: Don't see any useful way of using the hydroshare.get_resource() function
     # One can't do much with a Bags object. For downloading a bag we are using resource.bag_url.
     # So it is better that we delete the get_resource() function and remove this test
     
     res_bag = resource.get_resource(self.res.short_id)
     self.assertTrue(res_bag is not None)
コード例 #2
0
    def test_delete_resource(self):
        new_res = resource.create_resource('GenericResource', self.user,
                                           'My Test Resource')
        self.pid = new_res.short_id

        # get the resource by pid
        try:
            resource.get_resource(self.pid)
        except Http404:
            self.fail('just created resource doesnt exist for some reason')

        # delete the resource
        resource.delete_resource(self.pid)

        # try to get the resource again
        try:
            resource.get_resource(self.pid), Http404
        except Http404:
            pass
        else:
            self.fail('resource continues to persist')
コード例 #3
0
    def test_get_resource(self):

        # get the resource by pid
        res = resource.get_resource(self.pid).content_object

        self.assertTrue(res is not None)
        self.assertTrue(type(res) == GenericResource, type(res))
        self.assertTrue(res.title == "My Test Resource")
        self.assertTrue(res.created.strftime("%m/%d/%Y %H:%M") == res.updated.strftime("%m/%d/%Y %H:%M"))
        self.assertTrue(res.created.strftime("%m/%d/%Y") == dt.datetime.today().strftime("%m/%d/%Y"))
        self.assertTrue(res.user == self.user)
        self.assertTrue(res.short_id is not None, "Short ID has not been created!")
コード例 #4
0
    def test_delete_resource(self):
        new_res = resource.create_resource(
            'GenericResource',
            self.user,
            'My Test Resource'
            )
        self.pid = new_res.short_id

        # get the resource by pid
        try:
            resource.get_resource(self.pid)
        except Http404:
            self.fail('just created resource doesnt exist for some reason')

        # delete the resource
        resource.delete_resource(self.pid)

        # try to get the resource again
        try:
            resource.get_resource(self.pid), Http404
        except Http404:
            pass
        else:
            self.fail('resource continues to persist')
コード例 #5
0
    def test_get_resource(self):

        # get the resource by pid
        res = resource.get_resource(self.pid).content_object

        self.assertTrue(res is not None)
        self.assertTrue(type(res) == GenericResource, type(res))
        self.assertTrue(res.title == 'My Test Resource')
        self.assertTrue(
            res.created.strftime('%m/%d/%Y %H:%M') == res.updated.strftime(
                '%m/%d/%Y %H:%M'))
        self.assertTrue(
            res.created.strftime('%m/%d/%Y') == dt.datetime.today().strftime(
                '%m/%d/%Y'))
        self.assertTrue(res.user == self.user)
        self.assertTrue(res.short_id is not None,
                        'Short ID has not been created!')