def test_publish_resource(self): # check status prior to publishing the resource self.assertFalse(self.res.raccess.published, msg='The resource is published') self.assertFalse(self.res.raccess.immutable, msg='The resource is frozen') self.assertFalse(self.res.doi, msg='doi is assigned') # there should not be published date type metadata element self.assertFalse( self.res.metadata.dates.filter(type='published').exists()) # publish resource - this is the api we are testing hydroshare.publish_resource(self.res.short_id) self.pub_res = hydroshare.get_resource_by_shortkey(self.res.short_id) # test publish state self.assertTrue(self.pub_res.raccess.published, msg='The resource is not published') # test frozen state self.assertTrue(self.pub_res.raccess.immutable, msg='The resource is not frozen') # test if doi is assigned self.assertTrue(self.pub_res.doi, msg='No doi is assigned with the published resource.') # there should now published date type metadata element self.assertTrue( self.pub_res.metadata.dates.filter(type='published').exists())
def setUp(self): self.api_client = TestApiClient() user = hydroshare.create_account( '*****@*****.**', username='******', first_name='User0_FirstName', last_name='User0_LastName', ) self.res = hydroshare.create_resource('GenericResource', user, 'myres') hydroshare.publish_resource(self.res.short_id)
def test_publish_resource(self): # check status prior to publishing the resource self.assertFalse( self.res.raccess.published, msg='The resource is published' ) self.assertFalse( self.res.raccess.immutable, msg='The resource is frozen' ) self.assertIsNone( self.res.doi, msg='doi is assigned' ) # there should not be published date type metadata element self.assertFalse(self.res.metadata.dates.filter(type='published').exists()) # publish resource - this is the api we are testing hydroshare.publish_resource(self.res.short_id) self.pub_res = hydroshare.get_resource_by_shortkey(self.res.short_id) # test publish state self.assertTrue( self.pub_res.raccess.published, msg='The resource is not published' ) # test frozen state self.assertTrue( self.pub_res.raccess.immutable, msg='The resource is not frozen' ) # test if doi is assigned self.assertIsNotNone( self.pub_res.doi, msg='No doi is assigned with the published resource.' ) # there should now published date type metadata element self.assertTrue(self.pub_res.metadata.dates.filter(type='published').exists())
def test_publish_resource(self): # publish resource hydroshare.publish_resource(self.res.short_id) self.pub_res = hydroshare.get_resource_by_shortkey(self.res.short_id) # test publish state self.assertTrue( self.pub_res.published_and_frozen, msg='The resoruce is not published and frozen' ) # test frozen state self.assertTrue( self.pub_res.frozen, msg='The resource is not frozen' ) # test if resource has edit users self.assertListEqual( list(self.pub_res.edit_users.all()), [], msg='edit users list is not empty' ) # test if resource has edit groups self.assertListEqual( list(self.pub_res.edit_groups.all()), [], msg='edit groups is not empty' ) # test if doi is assigned self.assertIsNotNone( self.pub_res.doi, msg='No doi is assigned with the published resource.' )
def test_publish_resource(self): # publish resource hydroshare.publish_resource(self.res.short_id) self.pub_res = hydroshare.get_resource_by_shortkey(self.res.short_id) # test publish state self.assertTrue(self.pub_res.published_and_frozen, msg='The resoruce is not published and frozen') # test frozen state self.assertTrue(self.pub_res.frozen, msg='The resource is not frozen') # test if resource has edit users self.assertListEqual(list(self.pub_res.edit_users.all()), [], msg='edit users list is not empty') # test if resource has edit groups self.assertListEqual(list(self.pub_res.edit_groups.all()), [], msg='edit groups is not empty') # test if doi is assigned self.assertIsNotNone( self.pub_res.doi, msg='No doi is assigned with the published resource.')
def publish_resource(self, pk): authorize(self.request, pk, full=True) hydroshare.publish_resource(pk) return HttpResponse(pk, content_type='text/plain')