fixed the new test
@@ -3,6 +3,7 @@ from django.test import TestCase
from hs_core import hydroshare
from hs_core.hydroshare import hs_bagit
+from hs_core.hydroshare.utils import get_resource_by_shortkey
from hs_core.tasks import create_bag_by_irods
from hs_core.models import GenericResource
from django_irods.storage import IrodsStorage
@@ -45,13 +46,15 @@ class TestBagIt(TestCase):
self.assertTrue(status)
# test checksum will be computed for published resource
self.test_res.raccess.published = True
- self.test_res.save()
+ self.test_res.raccess.save()
status = create_bag_by_irods(self.test_res.short_id)
self.assertTrue(status)
- extra_data = self.test_res.extra_data
- self.assertIn('bag_checksum', extra_data, msg='bag_checksum key is not found in extra_data')
+ res = get_resource_by_shortkey(self.test_res.short_id)
+ extra_data = res.extra_data
self.assertIsNotNone(extra_data['bag_checksum'], msg='bag_checksum value in extra_data is None')
+ self.test_res.raccess.published = False
+ self.test_res.raccess.save()
hs_bagit.delete_files_and_bag(self.test_res)
# resource should not have any bags
istorage = self.test_res.get_irods_storage()
