Show More
@@ -17,30 +17,29 b' THIS = os.path.abspath(os.path.dirname(_' | |||||
17 |
|
17 | |||
18 | GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git' |
|
18 | GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git' | |
19 |
|
19 | |||
20 | # Note: TEST_TMP_PATH, not TESTS_TMP_PATH |
|
20 | TESTS_TMP_PATH = os.environ.get('VCS_TEST_ROOT', tempfile.gettempdir()) | |
21 | TEST_TMP_PATH = os.environ.get('VCS_TEST_ROOT', tempfile.gettempdir()) |
|
|||
22 |
|
21 | |||
23 | TEST_GIT_REPO = os.environ.get('VCS_TEST_GIT_REPO', |
|
22 | TEST_GIT_REPO = os.environ.get('VCS_TEST_GIT_REPO', | |
24 | os.path.join(TEST_TMP_PATH, 'vcs-git')) |
|
23 | os.path.join(TESTS_TMP_PATH, 'vcs-git')) | |
25 | TEST_GIT_REPO_CLONE = os.environ.get('VCS_TEST_GIT_REPO_CLONE', |
|
24 | TEST_GIT_REPO_CLONE = os.environ.get('VCS_TEST_GIT_REPO_CLONE', | |
26 | os.path.join(TEST_TMP_PATH, 'vcs-git-clone')) |
|
25 | os.path.join(TESTS_TMP_PATH, 'vcs-git-clone')) | |
27 | TEST_GIT_REPO_PULL = os.environ.get('VCS_TEST_GIT_REPO_PULL', |
|
26 | TEST_GIT_REPO_PULL = os.environ.get('VCS_TEST_GIT_REPO_PULL', | |
28 | os.path.join(TEST_TMP_PATH, 'vcs-git-pull')) |
|
27 | os.path.join(TESTS_TMP_PATH, 'vcs-git-pull')) | |
29 |
|
28 | |||
30 | HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs' |
|
29 | HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs' | |
31 | TEST_HG_REPO = os.environ.get('VCS_TEST_HG_REPO', |
|
30 | TEST_HG_REPO = os.environ.get('VCS_TEST_HG_REPO', | |
32 | os.path.join(TEST_TMP_PATH, 'vcs-hg')) |
|
31 | os.path.join(TESTS_TMP_PATH, 'vcs-hg')) | |
33 | TEST_HG_REPO_CLONE = os.environ.get('VCS_TEST_HG_REPO_CLONE', |
|
32 | TEST_HG_REPO_CLONE = os.environ.get('VCS_TEST_HG_REPO_CLONE', | |
34 | os.path.join(TEST_TMP_PATH, 'vcs-hg-clone')) |
|
33 | os.path.join(TESTS_TMP_PATH, 'vcs-hg-clone')) | |
35 | TEST_HG_REPO_PULL = os.environ.get('VCS_TEST_HG_REPO_PULL', |
|
34 | TEST_HG_REPO_PULL = os.environ.get('VCS_TEST_HG_REPO_PULL', | |
36 | os.path.join(TEST_TMP_PATH, 'vcs-hg-pull')) |
|
35 | os.path.join(TESTS_TMP_PATH, 'vcs-hg-pull')) | |
37 |
|
36 | |||
38 | TEST_REPO_PREFIX = 'vcs-test' |
|
37 | TEST_REPO_PREFIX = 'vcs-test' | |
39 |
|
38 | |||
40 |
|
39 | |||
41 | def get_new_dir(title=None): |
|
40 | def get_new_dir(title=None): | |
42 | """ |
|
41 | """ | |
43 | Calculates a path for a new, non-existant, unique sub-directory in TEST_TMP_PATH. |
|
42 | Calculates a path for a new, non-existant, unique sub-directory in TESTS_TMP_PATH. | |
44 |
|
43 | |||
45 | Resulting directory name will have format: |
|
44 | Resulting directory name will have format: | |
46 |
|
45 | |||
@@ -64,7 +63,7 b' def get_new_dir(title=None):' | |||||
64 | else: |
|
63 | else: | |
65 | name = TEST_REPO_PREFIX |
|
64 | name = TEST_REPO_PREFIX | |
66 |
|
65 | |||
67 | path = os.path.join(TEST_TMP_PATH, name) |
|
66 | path = os.path.join(TESTS_TMP_PATH, name) | |
68 |
|
67 | |||
69 | # Generate new hexes until we get a unique name (just in case). |
|
68 | # Generate new hexes until we get a unique name (just in case). | |
70 | hex_uuid = uuid.uuid4().hex |
|
69 | hex_uuid = uuid.uuid4().hex | |
@@ -76,7 +75,7 b' def get_new_dir(title=None):' | |||||
76 |
|
75 | |||
77 | PACKAGE_DIR = os.path.abspath(os.path.join( |
|
76 | PACKAGE_DIR = os.path.abspath(os.path.join( | |
78 | os.path.dirname(__file__), '..')) |
|
77 | os.path.dirname(__file__), '..')) | |
79 | _dest = os.path.join(TEST_TMP_PATH, 'aconfig') |
|
78 | _dest = os.path.join(TESTS_TMP_PATH, 'aconfig') | |
80 | shutil.copy(os.path.join(THIS, 'aconfig'), _dest) |
|
79 | shutil.copy(os.path.join(THIS, 'aconfig'), _dest) | |
81 | TEST_USER_CONFIG_FILE = _dest |
|
80 | TEST_USER_CONFIG_FILE = _dest | |
82 |
|
81 |
@@ -6,7 +6,7 b' import tempfile' | |||||
6 | import StringIO |
|
6 | import StringIO | |
7 |
|
7 | |||
8 | from kallithea.tests.vcs.base import _BackendTestMixin |
|
8 | from kallithea.tests.vcs.base import _BackendTestMixin | |
9 | from kallithea.tests.vcs.conf import SCM_TESTS, TEST_TMP_PATH |
|
9 | from kallithea.tests.vcs.conf import SCM_TESTS, TESTS_TMP_PATH | |
10 | from kallithea.lib.vcs.exceptions import VCSError |
|
10 | from kallithea.lib.vcs.exceptions import VCSError | |
11 | from kallithea.lib.vcs.nodes import FileNode |
|
11 | from kallithea.lib.vcs.nodes import FileNode | |
12 | from kallithea.lib.vcs.utils.compat import unittest |
|
12 | from kallithea.lib.vcs.utils.compat import unittest | |
@@ -29,7 +29,7 b' class ArchivesTestCaseMixin(_BackendTest' | |||||
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | def test_archive_zip(self): |
|
31 | def test_archive_zip(self): | |
32 | path = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_zip-')[1] |
|
32 | path = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_zip-')[1] | |
33 | with open(path, 'wb') as f: |
|
33 | with open(path, 'wb') as f: | |
34 | self.tip.fill_archive(stream=f, kind='zip', prefix='repo') |
|
34 | self.tip.fill_archive(stream=f, kind='zip', prefix='repo') | |
35 | out = zipfile.ZipFile(path) |
|
35 | out = zipfile.ZipFile(path) | |
@@ -43,10 +43,10 b' class ArchivesTestCaseMixin(_BackendTest' | |||||
43 | self.tip.get_node(node_path).content) |
|
43 | self.tip.get_node(node_path).content) | |
44 |
|
44 | |||
45 | def test_archive_tgz(self): |
|
45 | def test_archive_tgz(self): | |
46 | path = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_tgz-')[1] |
|
46 | path = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_tgz-')[1] | |
47 | with open(path, 'wb') as f: |
|
47 | with open(path, 'wb') as f: | |
48 | self.tip.fill_archive(stream=f, kind='tgz', prefix='repo') |
|
48 | self.tip.fill_archive(stream=f, kind='tgz', prefix='repo') | |
49 | outdir = tempfile.mkdtemp(dir=TEST_TMP_PATH, prefix='test_archive_tgz-', suffix='-outdir') |
|
49 | outdir = tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix='test_archive_tgz-', suffix='-outdir') | |
50 |
|
50 | |||
51 | outfile = tarfile.open(path, 'r|gz') |
|
51 | outfile = tarfile.open(path, 'r|gz') | |
52 | outfile.extractall(outdir) |
|
52 | outfile.extractall(outdir) | |
@@ -58,10 +58,10 b' class ArchivesTestCaseMixin(_BackendTest' | |||||
58 | self.tip.get_node(node_path).content) |
|
58 | self.tip.get_node(node_path).content) | |
59 |
|
59 | |||
60 | def test_archive_tbz2(self): |
|
60 | def test_archive_tbz2(self): | |
61 | path = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_tbz2-')[1] |
|
61 | path = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_tbz2-')[1] | |
62 | with open(path, 'w+b') as f: |
|
62 | with open(path, 'w+b') as f: | |
63 | self.tip.fill_archive(stream=f, kind='tbz2', prefix='repo') |
|
63 | self.tip.fill_archive(stream=f, kind='tbz2', prefix='repo') | |
64 | outdir = tempfile.mkdtemp(dir=TEST_TMP_PATH, prefix='test_archive_tbz2-', suffix='-outdir') |
|
64 | outdir = tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix='test_archive_tbz2-', suffix='-outdir') | |
65 |
|
65 | |||
66 | outfile = tarfile.open(path, 'r|bz2') |
|
66 | outfile = tarfile.open(path, 'r|bz2') | |
67 | outfile.extractall(outdir) |
|
67 | outfile.extractall(outdir) | |
@@ -73,7 +73,7 b' class ArchivesTestCaseMixin(_BackendTest' | |||||
73 | self.tip.get_node(node_path).content) |
|
73 | self.tip.get_node(node_path).content) | |
74 |
|
74 | |||
75 | def test_archive_default_stream(self): |
|
75 | def test_archive_default_stream(self): | |
76 | tmppath = tempfile.mkstemp(dir=TEST_TMP_PATH, prefix='test_archive_default_stream-')[1] |
|
76 | tmppath = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_default_stream-')[1] | |
77 | with open(tmppath, 'wb') as stream: |
|
77 | with open(tmppath, 'wb') as stream: | |
78 | self.tip.fill_archive(stream=stream) |
|
78 | self.tip.fill_archive(stream=stream) | |
79 | mystream = StringIO.StringIO() |
|
79 | mystream = StringIO.StringIO() |
@@ -12,7 +12,7 b' from kallithea.lib.vcs.nodes import Node' | |||||
12 | from kallithea.lib.vcs.utils.compat import unittest |
|
12 | from kallithea.lib.vcs.utils.compat import unittest | |
13 | from kallithea.model.scm import ScmModel |
|
13 | from kallithea.model.scm import ScmModel | |
14 | from kallithea.tests.vcs.base import _BackendTestMixin |
|
14 | from kallithea.tests.vcs.base import _BackendTestMixin | |
15 | from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TEST_TMP_PATH, get_new_dir |
|
15 | from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | class GitRepositoryTest(unittest.TestCase): |
|
18 | class GitRepositoryTest(unittest.TestCase): | |
@@ -27,7 +27,7 b' class GitRepositoryTest(unittest.TestCas' | |||||
27 | self.repo = GitRepository(TEST_GIT_REPO) |
|
27 | self.repo = GitRepository(TEST_GIT_REPO) | |
28 |
|
28 | |||
29 | def test_wrong_repo_path(self): |
|
29 | def test_wrong_repo_path(self): | |
30 | wrong_repo_path = os.path.join(TEST_TMP_PATH, 'errorrepo') |
|
30 | wrong_repo_path = os.path.join(TESTS_TMP_PATH, 'errorrepo') | |
31 | self.assertRaises(RepositoryError, GitRepository, wrong_repo_path) |
|
31 | self.assertRaises(RepositoryError, GitRepository, wrong_repo_path) | |
32 |
|
32 | |||
33 | def test_git_cmd_injection(self): |
|
33 | def test_git_cmd_injection(self): |
@@ -7,7 +7,7 b' from kallithea.lib.vcs.backends.hg impor' | |||||
7 | from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError |
|
7 | from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError | |
8 | from kallithea.lib.vcs.nodes import NodeKind, NodeState |
|
8 | from kallithea.lib.vcs.nodes import NodeKind, NodeState | |
9 | from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \ |
|
9 | from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \ | |
10 | TEST_HG_REPO_PULL, TEST_TMP_PATH |
|
10 | TEST_HG_REPO_PULL, TESTS_TMP_PATH | |
11 | from kallithea.lib.vcs.utils.compat import unittest |
|
11 | from kallithea.lib.vcs.utils.compat import unittest | |
12 |
|
12 | |||
13 |
|
13 | |||
@@ -23,7 +23,7 b' class MercurialRepositoryTest(unittest.T' | |||||
23 | self.repo = MercurialRepository(safe_str(TEST_HG_REPO)) |
|
23 | self.repo = MercurialRepository(safe_str(TEST_HG_REPO)) | |
24 |
|
24 | |||
25 | def test_wrong_repo_path(self): |
|
25 | def test_wrong_repo_path(self): | |
26 | wrong_repo_path = os.path.join(TEST_TMP_PATH, 'errorrepo') |
|
26 | wrong_repo_path = os.path.join(TESTS_TMP_PATH, 'errorrepo') | |
27 | self.assertRaises(RepositoryError, MercurialRepository, wrong_repo_path) |
|
27 | self.assertRaises(RepositoryError, MercurialRepository, wrong_repo_path) | |
28 |
|
28 | |||
29 | def test_unicode_path_repo(self): |
|
29 | def test_unicode_path_repo(self): |
@@ -18,7 +18,7 b' from kallithea.lib.vcs.utils import auth' | |||||
18 | from kallithea.lib.vcs.utils.paths import get_user_home |
|
18 | from kallithea.lib.vcs.utils.paths import get_user_home | |
19 | from kallithea.lib.vcs.exceptions import VCSError |
|
19 | from kallithea.lib.vcs.exceptions import VCSError | |
20 |
|
20 | |||
21 | from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TEST_TMP_PATH |
|
21 | from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | class PathsTest(unittest.TestCase): |
|
24 | class PathsTest(unittest.TestCase): | |
@@ -48,7 +48,7 b' class PathsTest(unittest.TestCase):' | |||||
48 | self.assertEqual(('git', TEST_GIT_REPO), get_scm(TEST_GIT_REPO)) |
|
48 | self.assertEqual(('git', TEST_GIT_REPO), get_scm(TEST_GIT_REPO)) | |
49 |
|
49 | |||
50 | def test_get_two_scms_for_path(self): |
|
50 | def test_get_two_scms_for_path(self): | |
51 | multialias_repo_path = os.path.join(TEST_TMP_PATH, 'hg-git-repo-2') |
|
51 | multialias_repo_path = os.path.join(TESTS_TMP_PATH, 'hg-git-repo-2') | |
52 | if os.path.isdir(multialias_repo_path): |
|
52 | if os.path.isdir(multialias_repo_path): | |
53 | shutil.rmtree(multialias_repo_path) |
|
53 | shutil.rmtree(multialias_repo_path) | |
54 |
|
54 | |||
@@ -60,7 +60,7 b' class PathsTest(unittest.TestCase):' | |||||
60 | self.assertRaises(VCSError, get_scm, 'err') |
|
60 | self.assertRaises(VCSError, get_scm, 'err') | |
61 |
|
61 | |||
62 | def test_get_scms_for_path(self): |
|
62 | def test_get_scms_for_path(self): | |
63 | new = os.path.join(TEST_TMP_PATH, 'vcs-scms-for-path-%s' % time.time()) |
|
63 | new = os.path.join(TESTS_TMP_PATH, 'vcs-scms-for-path-%s' % time.time()) | |
64 | os.mkdir(new) |
|
64 | os.mkdir(new) | |
65 | self.assertEqual(get_scms_for_path(new), []) |
|
65 | self.assertEqual(get_scms_for_path(new), []) | |
66 |
|
66 |
@@ -5,7 +5,7 b' from kallithea.lib.utils2 import safe_st' | |||||
5 | from kallithea.lib.vcs import VCSError, get_repo, get_backend |
|
5 | from kallithea.lib.vcs import VCSError, get_repo, get_backend | |
6 | from kallithea.lib.vcs.backends.hg import MercurialRepository |
|
6 | from kallithea.lib.vcs.backends.hg import MercurialRepository | |
7 | from kallithea.lib.vcs.utils.compat import unittest |
|
7 | from kallithea.lib.vcs.utils.compat import unittest | |
8 | from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TEST_TMP_PATH |
|
8 | from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | class VCSTest(unittest.TestCase): |
|
11 | class VCSTest(unittest.TestCase): | |
@@ -63,7 +63,7 b' class VCSTest(unittest.TestCase):' | |||||
63 | self.assertEqual(repo.path, get_repo(safe_str(path)).path) |
|
63 | self.assertEqual(repo.path, get_repo(safe_str(path)).path) | |
64 |
|
64 | |||
65 | def test_get_repo_err(self): |
|
65 | def test_get_repo_err(self): | |
66 | blank_repo_path = os.path.join(TEST_TMP_PATH, 'blank-error-repo') |
|
66 | blank_repo_path = os.path.join(TESTS_TMP_PATH, 'blank-error-repo') | |
67 | if os.path.isdir(blank_repo_path): |
|
67 | if os.path.isdir(blank_repo_path): | |
68 | shutil.rmtree(blank_repo_path) |
|
68 | shutil.rmtree(blank_repo_path) | |
69 |
|
69 | |||
@@ -72,7 +72,7 b' class VCSTest(unittest.TestCase):' | |||||
72 | self.assertRaises(VCSError, get_repo, blank_repo_path + 'non_existing') |
|
72 | self.assertRaises(VCSError, get_repo, blank_repo_path + 'non_existing') | |
73 |
|
73 | |||
74 | def test_get_repo_multialias(self): |
|
74 | def test_get_repo_multialias(self): | |
75 | multialias_repo_path = os.path.join(TEST_TMP_PATH, 'hg-git-repo') |
|
75 | multialias_repo_path = os.path.join(TESTS_TMP_PATH, 'hg-git-repo') | |
76 | if os.path.isdir(multialias_repo_path): |
|
76 | if os.path.isdir(multialias_repo_path): | |
77 | shutil.rmtree(multialias_repo_path) |
|
77 | shutil.rmtree(multialias_repo_path) | |
78 |
|
78 |
General Comments 0
You need to be logged in to leave comments.
Login now