You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/06/03 17:32:08 UTC

[15/31] git commit: [#6235] ticket:366 Test for SVNImplementation._path_to_root()

[#6235] ticket:366 Test for SVNImplementation._path_to_root()


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/85fbe7d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/85fbe7d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/85fbe7d9

Branch: refs/heads/cj/merge-request-4
Commit: 85fbe7d9990bdb82e3e729af41ee42e5416cfcfd
Parents: 6a77c65
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 29 06:34:37 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri May 31 22:14:09 2013 +0000

----------------------------------------------------------------------
 .../forgesvn/tests/model/test_svnimplementation.py |   32 +++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/85fbe7d9/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py b/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
index 9b78c0c..c23c6b3 100644
--- a/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
+++ b/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
@@ -74,3 +74,35 @@ class TestSVNImplementation(object):
 
         assert_equal(entries, {path.strip('/'): '5057636b9c1040636b81e4b1:1'})
         assert_equal(impl._svn.info2.call_args[0][0], 'file://'+g.tmpdir+'/code/trunk')
+
+    @patch('forgesvn.model.svn.svn_path_exists')
+    def test__path_to_root(self, path_exists):
+        repo = Mock(fs_path=g.tmpdir+'/')
+        repo.name = 'code'
+        repo._id = '5057636b9c1040636b81e4b1'
+        impl = SVNImplementation(repo)
+        path_exists.return_value = False
+        # edge cases
+        assert_equal(impl._path_to_root(None), '')
+        assert_equal(impl._path_to_root(''), '')
+        assert_equal(impl._path_to_root('/some/path/'), '')
+        assert_equal(impl._path_to_root('some/path'), '')
+        # tags
+        assert_equal(impl._path_to_root('/some/path/tags/1.0/some/dir'), 'some/path/tags/1.0')
+        assert_equal(impl._path_to_root('/some/path/tags/1.0/'), 'some/path/tags/1.0')
+        assert_equal(impl._path_to_root('/some/path/tags/'), '')
+        # branches
+        assert_equal(impl._path_to_root('/some/path/branches/b1/dir'), 'some/path/branches/b1')
+        assert_equal(impl._path_to_root('/some/path/branches/b1/'), 'some/path/branches/b1')
+        assert_equal(impl._path_to_root('/some/path/branches/'), '')
+        # trunk
+        assert_equal(impl._path_to_root('/some/path/trunk/some/dir/'), 'some/path/trunk')
+        assert_equal(impl._path_to_root('/some/path/trunk'), 'some/path/trunk')
+        # with fallback to trunk
+        path_exists.return_value = True
+        assert_equal(impl._path_to_root(''), 'trunk')
+        assert_equal(impl._path_to_root('/some/path/'), 'trunk')
+        assert_equal(impl._path_to_root('/tags/'), 'trunk')
+        assert_equal(impl._path_to_root('/branches/'), 'trunk')
+        assert_equal(impl._path_to_root('/tags/1.0'), 'tags/1.0')
+        assert_equal(impl._path_to_root('/branches/branch'), 'branches/branch')