summaryrefslogtreecommitdiff
path: root/tests/testutils/repo
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testutils/repo')
-rw-r--r--tests/testutils/repo/__init__.py31
-rw-r--r--tests/testutils/repo/bzr.py2
-rw-r--r--tests/testutils/repo/git.py2
-rw-r--r--tests/testutils/repo/ostree.py2
-rw-r--r--tests/testutils/repo/repo.py90
-rw-r--r--tests/testutils/repo/tar.py2
-rw-r--r--tests/testutils/repo/zip.py2
7 files changed, 5 insertions, 126 deletions
diff --git a/tests/testutils/repo/__init__.py b/tests/testutils/repo/__init__.py
index 1881aa3c4..e69de29bb 100644
--- a/tests/testutils/repo/__init__.py
+++ b/tests/testutils/repo/__init__.py
@@ -1,31 +0,0 @@
-from collections import OrderedDict
-
-from .git import Git
-from .bzr import Bzr
-from .ostree import OSTree
-from .tar import Tar
-from .zip import Zip
-
-ALL_REPO_KINDS = OrderedDict()
-ALL_REPO_KINDS['git'] = Git
-ALL_REPO_KINDS['bzr'] = Bzr
-ALL_REPO_KINDS['ostree'] = OSTree
-ALL_REPO_KINDS['tar'] = Tar
-ALL_REPO_KINDS['zip'] = Zip
-
-
-# create_repo()
-#
-# Convenience for creating a Repo
-#
-# Args:
-# kind (str): The kind of repo to create (a source plugin basename)
-# directory (str): The path where the repo will keep a cache
-#
-def create_repo(kind, directory, subdir='repo'):
- try:
- constructor = ALL_REPO_KINDS[kind]
- except KeyError as e:
- raise AssertionError("Unsupported repo kind {}".format(kind)) from e
-
- return constructor(directory, subdir=subdir)
diff --git a/tests/testutils/repo/bzr.py b/tests/testutils/repo/bzr.py
index 0bedb3aa7..c006c3fce 100644
--- a/tests/testutils/repo/bzr.py
+++ b/tests/testutils/repo/bzr.py
@@ -2,7 +2,7 @@ import os
import subprocess
import pytest
-from .repo import Repo
+from buildstream.plugintestutils import Repo
from .. import site
diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py
index 1455de264..5c27be3ee 100644
--- a/tests/testutils/repo/git.py
+++ b/tests/testutils/repo/git.py
@@ -4,7 +4,7 @@ import subprocess
import pytest
-from .repo import Repo
+from buildstream.plugintestutils import Repo
from .. import site
diff --git a/tests/testutils/repo/ostree.py b/tests/testutils/repo/ostree.py
index 0bb1d8ae3..d0cef8b88 100644
--- a/tests/testutils/repo/ostree.py
+++ b/tests/testutils/repo/ostree.py
@@ -2,7 +2,7 @@ import subprocess
import pytest
-from .repo import Repo
+from buildstream.plugintestutils import Repo
from .. import site
diff --git a/tests/testutils/repo/repo.py b/tests/testutils/repo/repo.py
deleted file mode 100644
index 234aa374c..000000000
--- a/tests/testutils/repo/repo.py
+++ /dev/null
@@ -1,90 +0,0 @@
-import os
-import shutil
-
-
-# Repo()
-#
-# Abstract class providing scaffolding for
-# generating data to be used with various sources
-#
-# Args:
-# directory (str): The base temp directory for the test
-# subdir (str): The subdir for the repo, in case there is more than one
-#
-class Repo():
-
- def __init__(self, directory, subdir='repo'):
-
- # The working directory for the repo object
- #
- self.directory = os.path.abspath(directory)
-
- # The directory the actual repo will be stored in
- self.repo = os.path.join(self.directory, subdir)
-
- os.makedirs(self.repo, exist_ok=True)
-
- # create():
- #
- # Create a repository in self.directory and add the initial content
- #
- # Args:
- # directory: A directory with content to commit
- #
- # Returns:
- # (smth): A new ref corresponding to this commit, which can
- # be passed as the ref in the Repo.source_config() API.
- #
- def create(self, directory):
- pass
-
- # source_config()
- #
- # Args:
- # ref (smth): An optional abstract ref object, usually a string.
- #
- # Returns:
- # (dict): A configuration which can be serialized as a
- # source when generating an element file on the fly
- #
- def source_config(self, ref=None):
- pass
-
- # copy_directory():
- #
- # Copies the content of src to the directory dest
- #
- # Like shutil.copytree(), except dest is expected
- # to exist.
- #
- # Args:
- # src (str): The source directory
- # dest (str): The destination directory
- #
- def copy_directory(self, src, dest):
- for filename in os.listdir(src):
- src_path = os.path.join(src, filename)
- dest_path = os.path.join(dest, filename)
- if os.path.isdir(src_path):
- shutil.copytree(src_path, dest_path)
- else:
- shutil.copy2(src_path, dest_path)
-
- # copy():
- #
- # Creates a copy of this repository in the specified
- # destination.
- #
- # Args:
- # dest (str): The destination directory
- #
- # Returns:
- # (Repo): A Repo object for the new repository.
- def copy(self, dest):
- subdir = self.repo[len(self.directory):].lstrip(os.sep)
- new_dir = os.path.join(dest, subdir)
- os.makedirs(new_dir, exist_ok=True)
- self.copy_directory(self.repo, new_dir)
- repo_type = type(self)
- new_repo = repo_type(dest, subdir)
- return new_repo
diff --git a/tests/testutils/repo/tar.py b/tests/testutils/repo/tar.py
index ee6cb77b3..6fdf58ae0 100644
--- a/tests/testutils/repo/tar.py
+++ b/tests/testutils/repo/tar.py
@@ -3,7 +3,7 @@ import tarfile
from buildstream.utils import sha256sum
-from .repo import Repo
+from buildstream.plugintestutils import Repo
class Tar(Repo):
diff --git a/tests/testutils/repo/zip.py b/tests/testutils/repo/zip.py
index 8133f1236..c57e09e7d 100644
--- a/tests/testutils/repo/zip.py
+++ b/tests/testutils/repo/zip.py
@@ -3,7 +3,7 @@ import zipfile
from buildstream.utils import sha256sum
-from .repo import Repo
+from buildstream.plugintestutils import Repo
class Zip(Repo):