using shutil for creating zip file in tests
# -*- coding: utf-8 -*-
import os
-import zipfile
+import shutil
from unittest import TestCase
from django.contrib.auth.models import Group
@@ -10,7 +10,6 @@ from django.core.management import call_command
from hs_composite_resource.models import CompositeResource
from hs_core import hydroshare
from hs_core.testing import MockIRODSTestCaseMixin
-from hs_core.tests.api.utils import zip_up
class TestIngestBag(MockIRODSTestCaseMixin, TestCase):
@@ -33,8 +32,9 @@ class TestIngestBag(MockIRODSTestCaseMixin, TestCase):
CompositeResource.objects.all().delete()
# zip up the test bag
- zipf = zipfile.ZipFile('hs_core/tests/data/d6c7a5744920404f8aceaf3c7774596e.zip', 'w')
- zip_up(zipf, 'hs_core/tests/data/d6c7a5744920404f8aceaf3c7774596e')
+ dir_to_zip = 'hs_core/tests/data/d6c7a5744920404f8aceaf3c7774596e'
+ self.zip_to_file_path = 'hs_core/tests/data/d6c7a5744920404f8aceaf3c7774596e'
+ shutil.make_archive(self.zip_to_file_path, 'zip', dir_to_zip)
def tearDown(self):
super(TestIngestBag, self).tearDown()
@@ -42,7 +42,7 @@ class TestIngestBag(MockIRODSTestCaseMixin, TestCase):
res.delete()
self.user.delete()
self.hs_group.delete()
- os.remove('hs_core/tests/data/d6c7a5744920404f8aceaf3c7774596e.zip')
+ os.remove(f"{self.zip_to_file_path}.zip")
def test_bag_ingestion_command(self):
assert CompositeResource.objects.all().count() == 0
