incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [20/38] git commit: [#6235] ticket:366 Test for SVNImplementation._path_to_root()
Date Mon, 03 Jun 2013 19:19:19 GMT
[#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/6218
Commit: 85fbe7d9990bdb82e3e729af41ee42e5416cfcfd
Parents: 6a77c65
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed May 29 06:34:37 2013 +0000
Committer: Dave Brondsema <dbrondsema@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')


Mime
View raw message