Changeset - 38917ced2519
[Not reviewed]
default
0 6 0
Branko Majic (branko) - 8 years ago 2018-01-31 13:57:52
branko@majic.rs
Grafted from: 72cf8ab299dd
tests: fix TESTS_TMP_PATH naming
6 files changed with 27 insertions and 28 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/vcs/conf.py
Show inline comments
 
@@ -17,30 +17,29 @@ THIS = os.path.abspath(os.path.dirname(_
 

	
 
GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git'
 

	
 
# Note: TEST_TMP_PATH, not TESTS_TMP_PATH
 
TEST_TMP_PATH = os.environ.get('VCS_TEST_ROOT', tempfile.gettempdir())
 
TESTS_TMP_PATH = os.environ.get('VCS_TEST_ROOT', tempfile.gettempdir())
 

	
 
TEST_GIT_REPO = os.environ.get('VCS_TEST_GIT_REPO',
 
                               os.path.join(TEST_TMP_PATH, 'vcs-git'))
 
                               os.path.join(TESTS_TMP_PATH, 'vcs-git'))
 
TEST_GIT_REPO_CLONE = os.environ.get('VCS_TEST_GIT_REPO_CLONE',
 
                                     os.path.join(TEST_TMP_PATH, 'vcs-git-clone'))
 
                                     os.path.join(TESTS_TMP_PATH, 'vcs-git-clone'))
 
TEST_GIT_REPO_PULL = os.environ.get('VCS_TEST_GIT_REPO_PULL',
 
                                    os.path.join(TEST_TMP_PATH, 'vcs-git-pull'))
 
                                    os.path.join(TESTS_TMP_PATH, 'vcs-git-pull'))
 

	
 
HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs'
 
TEST_HG_REPO = os.environ.get('VCS_TEST_HG_REPO',
 
                              os.path.join(TEST_TMP_PATH, 'vcs-hg'))
 
                              os.path.join(TESTS_TMP_PATH, 'vcs-hg'))
 
TEST_HG_REPO_CLONE = os.environ.get('VCS_TEST_HG_REPO_CLONE',
 
                                    os.path.join(TEST_TMP_PATH, 'vcs-hg-clone'))
 
                                    os.path.join(TESTS_TMP_PATH, 'vcs-hg-clone'))
 
TEST_HG_REPO_PULL = os.environ.get('VCS_TEST_HG_REPO_PULL',
 
                                   os.path.join(TEST_TMP_PATH, 'vcs-hg-pull'))
 
                                   os.path.join(TESTS_TMP_PATH, 'vcs-hg-pull'))
 

	
 
TEST_REPO_PREFIX = 'vcs-test'
 

	
 

	
 
def get_new_dir(title=None):
 
    """
 
    Calculates a path for a new, non-existant, unique sub-directory in TEST_TMP_PATH.
 
    Calculates a path for a new, non-existant, unique sub-directory in TESTS_TMP_PATH.
 

	
 
    Resulting directory name will have format:
 

	
 
@@ -64,7 +63,7 @@ def get_new_dir(title=None):
 
    else:
 
        name = TEST_REPO_PREFIX
 

	
 
    path = os.path.join(TEST_TMP_PATH, name)
 
    path = os.path.join(TESTS_TMP_PATH, name)
 

	
 
    # Generate new hexes until we get a unique name (just in case).
 
    hex_uuid = uuid.uuid4().hex
 
@@ -76,7 +75,7 @@ def get_new_dir(title=None):
 

	
 
PACKAGE_DIR = os.path.abspath(os.path.join(
 
    os.path.dirname(__file__), '..'))
 
_dest = os.path.join(TEST_TMP_PATH, 'aconfig')
 
_dest = os.path.join(TESTS_TMP_PATH, 'aconfig')
 
shutil.copy(os.path.join(THIS, 'aconfig'), _dest)
 
TEST_USER_CONFIG_FILE = _dest
 

	
kallithea/tests/vcs/test_archives.py
Show inline comments
 
@@ -6,7 +6,7 @@ import tempfile
 
import StringIO
 

	
 
from kallithea.tests.vcs.base import _BackendTestMixin
 
from kallithea.tests.vcs.conf import SCM_TESTS, TEST_TMP_PATH
 
from kallithea.tests.vcs.conf import SCM_TESTS, TESTS_TMP_PATH
 
from kallithea.lib.vcs.exceptions import VCSError
 
from kallithea.lib.vcs.nodes import FileNode
 
from kallithea.lib.vcs.utils.compat import unittest
 
@@ -29,7 +29,7 @@ class ArchivesTestCaseMixin(_BackendTest
 
            }
 

	
 
    def test_archive_zip(self):
 
        path = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_zip-')[1]
 
        path = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_zip-')[1]
 
        with open(path, 'wb') as f:
 
            self.tip.fill_archive(stream=f, kind='zip', prefix='repo')
 
        out = zipfile.ZipFile(path)
 
@@ -43,10 +43,10 @@ class ArchivesTestCaseMixin(_BackendTest
 
                self.tip.get_node(node_path).content)
 

	
 
    def test_archive_tgz(self):
 
        path = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_tgz-')[1]
 
        path = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_tgz-')[1]
 
        with open(path, 'wb') as f:
 
            self.tip.fill_archive(stream=f, kind='tgz', prefix='repo')
 
        outdir = tempfile.mkdtemp(dir=TEST_TMP_PATH, prefix='test_archive_tgz-', suffix='-outdir')
 
        outdir = tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix='test_archive_tgz-', suffix='-outdir')
 

	
 
        outfile = tarfile.open(path, 'r|gz')
 
        outfile.extractall(outdir)
 
@@ -58,10 +58,10 @@ class ArchivesTestCaseMixin(_BackendTest
 
                self.tip.get_node(node_path).content)
 

	
 
    def test_archive_tbz2(self):
 
        path = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_tbz2-')[1]
 
        path = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_tbz2-')[1]
 
        with open(path, 'w+b') as f:
 
            self.tip.fill_archive(stream=f, kind='tbz2', prefix='repo')
 
        outdir = tempfile.mkdtemp(dir=TEST_TMP_PATH, prefix='test_archive_tbz2-', suffix='-outdir')
 
        outdir = tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix='test_archive_tbz2-', suffix='-outdir')
 

	
 
        outfile = tarfile.open(path, 'r|bz2')
 
        outfile.extractall(outdir)
 
@@ -73,7 +73,7 @@ class ArchivesTestCaseMixin(_BackendTest
 
                self.tip.get_node(node_path).content)
 

	
 
    def test_archive_default_stream(self):
 
        tmppath = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_default_stream-')[1]
 
        tmppath = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_default_stream-')[1]
 
        with open(tmppath, 'wb') as stream:
 
            self.tip.fill_archive(stream=stream)
 
        mystream = StringIO.StringIO()
kallithea/tests/vcs/test_git.py
Show inline comments
 
@@ -12,7 +12,7 @@ from kallithea.lib.vcs.nodes import Node
 
from kallithea.lib.vcs.utils.compat import unittest
 
from kallithea.model.scm import ScmModel
 
from kallithea.tests.vcs.base import _BackendTestMixin
 
from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TEST_TMP_PATH, get_new_dir
 
from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir
 

	
 

	
 
class GitRepositoryTest(unittest.TestCase):
 
@@ -27,7 +27,7 @@ class GitRepositoryTest(unittest.TestCas
 
        self.repo = GitRepository(TEST_GIT_REPO)
 

	
 
    def test_wrong_repo_path(self):
 
        wrong_repo_path = os.path.join(TEST_TMP_PATH, 'errorrepo')
 
        wrong_repo_path = os.path.join(TESTS_TMP_PATH, 'errorrepo')
 
        self.assertRaises(RepositoryError, GitRepository, wrong_repo_path)
 

	
 
    def test_git_cmd_injection(self):
kallithea/tests/vcs/test_hg.py
Show inline comments
 
@@ -7,7 +7,7 @@ from kallithea.lib.vcs.backends.hg impor
 
from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
 
from kallithea.lib.vcs.nodes import NodeKind, NodeState
 
from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \
 
    TEST_HG_REPO_PULL, TEST_TMP_PATH
 
    TEST_HG_REPO_PULL, TESTS_TMP_PATH
 
from kallithea.lib.vcs.utils.compat import unittest
 

	
 

	
 
@@ -23,7 +23,7 @@ class MercurialRepositoryTest(unittest.T
 
        self.repo = MercurialRepository(safe_str(TEST_HG_REPO))
 

	
 
    def test_wrong_repo_path(self):
 
        wrong_repo_path = os.path.join(TEST_TMP_PATH, 'errorrepo')
 
        wrong_repo_path = os.path.join(TESTS_TMP_PATH, 'errorrepo')
 
        self.assertRaises(RepositoryError, MercurialRepository, wrong_repo_path)
 

	
 
    def test_unicode_path_repo(self):
kallithea/tests/vcs/test_utils.py
Show inline comments
 
@@ -18,7 +18,7 @@ from kallithea.lib.vcs.utils import auth
 
from kallithea.lib.vcs.utils.paths import get_user_home
 
from kallithea.lib.vcs.exceptions import VCSError
 

	
 
from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TEST_TMP_PATH
 
from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
 

	
 

	
 
class PathsTest(unittest.TestCase):
 
@@ -48,7 +48,7 @@ class PathsTest(unittest.TestCase):
 
        self.assertEqual(('git', TEST_GIT_REPO), get_scm(TEST_GIT_REPO))
 

	
 
    def test_get_two_scms_for_path(self):
 
        multialias_repo_path = os.path.join(TEST_TMP_PATH, 'hg-git-repo-2')
 
        multialias_repo_path = os.path.join(TESTS_TMP_PATH, 'hg-git-repo-2')
 
        if os.path.isdir(multialias_repo_path):
 
            shutil.rmtree(multialias_repo_path)
 

	
 
@@ -60,7 +60,7 @@ class PathsTest(unittest.TestCase):
 
        self.assertRaises(VCSError, get_scm, 'err')
 

	
 
    def test_get_scms_for_path(self):
 
        new = os.path.join(TEST_TMP_PATH, 'vcs-scms-for-path-%s' % time.time())
 
        new = os.path.join(TESTS_TMP_PATH, 'vcs-scms-for-path-%s' % time.time())
 
        os.mkdir(new)
 
        self.assertEqual(get_scms_for_path(new), [])
 

	
kallithea/tests/vcs/test_vcs.py
Show inline comments
 
@@ -5,7 +5,7 @@ from kallithea.lib.utils2 import safe_st
 
from kallithea.lib.vcs import VCSError, get_repo, get_backend
 
from kallithea.lib.vcs.backends.hg import MercurialRepository
 
from kallithea.lib.vcs.utils.compat import unittest
 
from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TEST_TMP_PATH
 
from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
 

	
 

	
 
class VCSTest(unittest.TestCase):
 
@@ -63,7 +63,7 @@ class VCSTest(unittest.TestCase):
 
        self.assertEqual(repo.path, get_repo(safe_str(path)).path)
 

	
 
    def test_get_repo_err(self):
 
        blank_repo_path = os.path.join(TEST_TMP_PATH, 'blank-error-repo')
 
        blank_repo_path = os.path.join(TESTS_TMP_PATH, 'blank-error-repo')
 
        if os.path.isdir(blank_repo_path):
 
            shutil.rmtree(blank_repo_path)
 

	
 
@@ -72,7 +72,7 @@ class VCSTest(unittest.TestCase):
 
        self.assertRaises(VCSError, get_repo, blank_repo_path + 'non_existing')
 

	
 
    def test_get_repo_multialias(self):
 
        multialias_repo_path = os.path.join(TEST_TMP_PATH, 'hg-git-repo')
 
        multialias_repo_path = os.path.join(TESTS_TMP_PATH, 'hg-git-repo')
 
        if os.path.isdir(multialias_repo_path):
 
            shutil.rmtree(multialias_repo_path)
 

	
0 comments (0 inline, 0 general)