commit 87161b0d2b25b9cfd9af1aa8d448494703c8de09
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date: Mon Nov 5 14:51:06 2018 +0100
Remove testrepo.zip.
diff --git a/requirements-swh.txt b/requirements-swh.txt
index dbe81b0..c62d405 100644
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,5 +1,5 @@
swh.core >= 0.0.7
-swh.loader.core >= 0.0.36
+swh.loader.core >= 0.0.32
swh.model >= 0.0.27
swh.scheduler >= 0.0.14
swh.storage >= 0.0.108
diff --git a/swh/loader/git/tests/resources/testrepo.zip b/swh/loader/git/tests/resources/testrepo.zip
deleted file mode 100644
index ac9bc3e..0000000
Binary files a/swh/loader/git/tests/resources/testrepo.zip and /dev/null differ
diff --git a/swh/loader/git/tests/test_loader.py b/swh/loader/git/tests/test_loader.py
index b6d5716..55380bc 100644
--- a/swh/loader/git/tests/test_loader.py
+++ b/swh/loader/git/tests/test_loader.py
@@ -4,6 +4,8 @@
# See top-level LICENSE file for more information
import os.path
+import zipfile
+import tempfile
import subprocess
from swh.loader.git.loader import GitLoader, GitLoaderFromArchive
@@ -159,7 +161,7 @@ class BaseDirGitLoaderTest(BaseGitLoaderTest):
directory=self.destination_path)
-class BaseTarGitLoaderTest(BaseGitLoaderTest):
+class BaseZipGitLoaderTest(BaseGitLoaderTest):
"""Mixin base loader test to prepare the git
repository to uncompress, load and test the results.
@@ -167,9 +169,28 @@ class BaseTarGitLoaderTest(BaseGitLoaderTest):
"""
def setUp(self):
- super().setUp('testrepo.zip', False)
+ super().setUp('testrepo.tgz', True)
+ self._zip_file = tempfile.NamedTemporaryFile('ab', suffix='.zip')
+ dest_dir = os.path.normpath(self.destination_path) + '/'
+ with zipfile.ZipFile(self._zip_file, 'a') as zip_writer:
+ for root, dirs, files in os.walk(dest_dir):
+ assert root.startswith(dest_dir)
+ relative_root = os.path.join(
+ 'testrepo',
+ root[len(dest_dir):])
+ for file_ in files:
+ zip_writer.write(
+ filename=os.path.join(root, file_),
+ arcname=os.path.join(relative_root, file_))
+ self.destination_path = self._zip_file.name
+ self.tmp_root_path = None
+ self.repo_url = 'file://' + self.destination_path
self.loader = GitLoaderFromArchiveNoStorage()
+ def tearDown(self):
+ self._zip_file.close()
+ super().tearDown()
+
def load(self):
return self.loader.load(
origin_url=self.repo_url,
@@ -220,6 +241,9 @@ class DirGitLoaderTest(BaseDirGitLoaderTest, GitLoaderTests):
res = self.load()
self.assertEqual(res['status'], 'eventful')
+ self._git('config', '--local', 'user.email', 'you@example.com')
+ self._git('config', '--local', 'user.name', 'Your Name')
+
# Load with a new file + revision
with open(os.path.join(self.destination_path, 'hello.py'), 'a') as fd:
fd.write("print('Hello world')\n")
@@ -274,5 +298,5 @@ class DirGitLoaderTest(BaseDirGitLoaderTest, GitLoaderTests):
self.assertEqual(self.loader.visit_status(), 'full')
-class TarGitLoaderTest(BaseTarGitLoaderTest, GitLoaderTests):
+class ZipGitLoaderTest(BaseZipGitLoaderTest, GitLoaderTests):
pass