changeset 5181:e3840a1ec58c

git: fix test_git_cmd_injection on windows, add tests for path with spaces
author Matthias Zilk <matthias.zilk@gmail.com>
date Sun, 31 May 2015 21:39:22 +0200
parents ab01e0a5d240
children 0e2d450feb03
files kallithea/tests/vcs/test_git.py
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/vcs/test_git.py	Sun Jun 07 13:13:12 2015 +0200
+++ b/kallithea/tests/vcs/test_git.py	Sun May 31 21:39:22 2015 +0200
@@ -1,6 +1,7 @@
 from __future__ import with_statement
 
 import os
+import sys
 import mock
 import datetime
 import urllib2
@@ -39,12 +40,20 @@
             clone_fail_repo.clone(repo_inject_path, update_after_clone=True,)
 
         # Verify correct quoting of evil characters that should work on posix file systems
-        tricky_path = get_new_dir("tricky-path-repo-$'\"`")
+        if sys.platform == 'win32':
+            # windows does not allow '"' in dir names
+            tricky_path = get_new_dir("tricky-path-repo-$'`")
+        else:
+            tricky_path = get_new_dir("tricky-path-repo-$'\"`")
         successfully_cloned = GitRepository(tricky_path, src_url=TEST_GIT_REPO, update_after_clone=True, create=True)
         # Repo should have been created
         self.assertFalse(successfully_cloned._repo.bare)
 
-        tricky_path_2 = get_new_dir("tricky-path-2-repo-$'\"`")
+        if sys.platform == 'win32':
+            # windows does not allow '"' in dir names
+            tricky_path_2 = get_new_dir("tricky-path-2-repo-$'`")
+        else:
+            tricky_path_2 = get_new_dir("tricky-path-2-repo-$'\"`")
         successfully_cloned2 = GitRepository(tricky_path_2, src_url=tricky_path, bare=True, create=True)
         # Repo should have been created and thus used correct quoting for clone
         self.assertTrue(successfully_cloned2._repo.bare)
@@ -53,6 +62,12 @@
         successfully_cloned.pull(tricky_path_2)
         successfully_cloned2.fetch(tricky_path)
 
+    def test_repo_create_with_spaces_in_path(self):
+        repo_path = get_new_dir("path with spaces")
+        repo = GitRepository(repo_path, src_url=None, bare=True, create=True)
+        # Repo should have been created
+        self.assertTrue(repo._repo.bare)
+
     def test_repo_clone(self):
         self.__check_for_existing_repo()
         repo = GitRepository(TEST_GIT_REPO)
@@ -64,6 +79,15 @@
             raw_id = changeset.raw_id
             self.assertEqual(raw_id, repo_clone.get_changeset(raw_id).raw_id)
 
+    def test_repo_clone_with_spaces_in_path(self):
+        repo_path = get_new_dir("path with spaces")
+        successfully_cloned = GitRepository(repo_path, src_url=TEST_GIT_REPO, update_after_clone=True, create=True)
+        # Repo should have been created
+        self.assertFalse(successfully_cloned._repo.bare)
+
+        successfully_cloned.pull(TEST_GIT_REPO)
+        self.repo.fetch(repo_path)
+
     def test_repo_clone_without_create(self):
         self.assertRaises(RepositoryError, GitRepository,
             TEST_GIT_REPO_CLONE + '_wo_create', src_url=TEST_GIT_REPO)