changeset 5752:8568a1d4f100

tests: don't use the TESTS_TMP_PATH string it differs each time you run the test and therefore doesn't work if you use a separat kallithea test instance (KALLITHEA_NO_TMP_PATH=1) instead get the 'real' path from the DB FIXME: breaks kallithea/tests/functional/test_admin_repos.py
author domruf <dominikruf@gmail.com>
date Thu, 28 Jan 2016 20:40:32 +0100
parents 1883a4e4c390
children 1a7611b9730e
files kallithea/tests/api/api_base.py kallithea/tests/functional/test_admin_repos.py kallithea/tests/other/test_validators.py kallithea/tests/scripts/manual_test_concurrency.py
diffstat 4 files changed, 18 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/api/api_base.py	Mon Feb 29 22:06:40 2016 +0100
+++ b/kallithea/tests/api/api_base.py	Thu Jan 28 20:40:32 2016 +0100
@@ -33,7 +33,7 @@
 from kallithea.model.meta import Session
 from kallithea.model.scm import ScmModel
 from kallithea.model.gist import GistModel
-from kallithea.model.db import Repository, User, Setting
+from kallithea.model.db import Repository, User, Setting, Ui
 from kallithea.lib.utils2 import time_to_datetime
 
 
@@ -280,7 +280,7 @@
     def test_api_pull(self):
         repo_name = u'test_pull'
         r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
-        r.clone_uri = os.path.join(TESTS_TMP_PATH, self.REPO)
+        r.clone_uri = os.path.join(Ui.get_by_key('paths', '/').ui_value, self.REPO)
         Session.add(r)
         Session.commit()
 
--- a/kallithea/tests/functional/test_admin_repos.py	Mon Feb 29 22:06:40 2016 +0100
+++ b/kallithea/tests/functional/test_admin_repos.py	Thu Jan 28 20:40:32 2016 +0100
@@ -7,7 +7,7 @@
 from kallithea.lib import vcs
 from kallithea.lib.utils2 import safe_str, safe_unicode
 from kallithea.model.db import Repository, RepoGroup, UserRepoToPerm, User, \
-    Permission
+    Permission, Ui
 from kallithea.model.user import UserModel
 from kallithea.tests import *
 from kallithea.model.repo_group import RepoGroupModel
@@ -80,7 +80,7 @@
 
         # test if the repository was created on filesystem
         try:
-            vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name)))
+            vcs.get_repo(safe_str(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)))
         except vcs.exceptions.VCSError:
             pytest.fail('no repo %s in filesystem' % repo_name)
 
@@ -132,7 +132,7 @@
 
         # test if the repository was created on filesystem
         try:
-            vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name_full)))
+            vcs.get_repo(safe_str(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_full)))
         except vcs.exceptions.VCSError:
             RepoGroupModel().delete(group_name)
             Session().commit()
@@ -224,7 +224,7 @@
 
         # test if the repository was created on filesystem
         try:
-            vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name_full)))
+            vcs.get_repo(safe_str(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_full)))
         except vcs.exceptions.VCSError:
             RepoGroupModel().delete(group_name)
             Session().commit()
@@ -281,7 +281,7 @@
 
         # test if the repository was created on filesystem
         try:
-            vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name_full)))
+            vcs.get_repo(safe_str(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_full)))
         except vcs.exceptions.VCSError:
             RepoGroupModel().delete(group_name)
             Session().commit()
@@ -358,7 +358,7 @@
 
         # test if the repository was created on filesystem
         try:
-            vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name)))
+            vcs.get_repo(safe_str(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)))
         except vcs.exceptions.VCSError:
             pytest.fail('no repo %s in filesystem' % repo_name)
 
@@ -375,7 +375,7 @@
 
         self.assertEqual(deleted_repo, None)
 
-        self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)),
+        self.assertEqual(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)),
                                   False)
 
     def test_delete_non_ascii(self):
@@ -411,7 +411,7 @@
 
         # test if the repository was created on filesystem
         try:
-            vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name)))
+            vcs.get_repo(safe_str(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_unicode)))
         except vcs.exceptions.VCSError:
             pytest.fail('no repo %s in filesystem' % repo_name)
 
@@ -426,7 +426,7 @@
 
         self.assertEqual(deleted_repo, None)
 
-        self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)),
+        self.assertEqual(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_unicode)),
                                   False)
 
     def test_delete_repo_with_group(self):
@@ -602,7 +602,7 @@
         self.assertEqual(repo, None)
 
         # repo must not be in filesystem !
-        self.assertFalse(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)))
+        self.assertFalse(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)))
 
 class TestAdminReposControllerGIT(TestController, _BaseTest):
     REPO = GIT_REPO
--- a/kallithea/tests/other/test_validators.py	Mon Feb 29 22:06:40 2016 +0100
+++ b/kallithea/tests/other/test_validators.py	Thu Jan 28 20:40:32 2016 +0100
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 import formencode
+import tempfile
 
 from kallithea.tests import *
 
@@ -197,8 +198,8 @@
 
     def test_ValidPath(self):
             validator = v.ValidPath()
-            self.assertEqual(TESTS_TMP_PATH,
-                             validator.to_python(TESTS_TMP_PATH))
+            self.assertEqual(tempfile.gettempdir(),
+                             validator.to_python(tempfile.gettempdir()))
             self.assertRaises(formencode.Invalid, validator.to_python,
                               '/no_such_dir')
 
--- a/kallithea/tests/scripts/manual_test_concurrency.py	Mon Feb 29 22:06:40 2016 +0100
+++ b/kallithea/tests/scripts/manual_test_concurrency.py	Thu Jan 28 20:40:32 2016 +0100
@@ -42,10 +42,10 @@
 from kallithea.lib.utils import add_cache
 from kallithea.model import init_model
 from kallithea.model import meta
-from kallithea.model.db import User, Repository
+from kallithea.model.db import User, Repository, Ui
 from kallithea.lib.auth import get_crypt_password
 
-from kallithea.tests import TESTS_TMP_PATH, HG_REPO
+from kallithea.tests import HG_REPO
 from kallithea.config.environment import load_environment
 
 rel_path = dn(dn(dn(dn(os.path.abspath(__file__)))))
@@ -161,7 +161,7 @@
 #==============================================================================
 def test_clone_with_credentials(no_errors=False, repo=HG_REPO, method=METHOD,
                                 seq=None, backend='hg'):
-    cwd = path = jn(TESTS_TMP_PATH, repo)
+    cwd = path = jn(Ui.get_by_key('paths', '/').ui_value, repo)
 
     if seq is None:
         seq = _RandomNameSequence().next()