def _test_last_commit_ids(self, path): repo = Mock(fs_path=g.tmpdir+'/') repo.name = 'code' repo._id = '5057636b9c1040636b81e4b1' impl = SVNImplementation(repo) impl._svn.info2 = Mock() impl._svn.info2.return_value = [('trunk', Mock()), ('foo', Mock())] impl._svn.info2.return_value[1][1].last_changed_rev.number = '1' commit = Commit() commit._id = '5057636b9c1040636b81e4b1:6' entries = impl.last_commit_ids(commit, [path]) assert_equal(entries, {path.strip('/'): '5057636b9c1040636b81e4b1:1'}) assert_equal(impl._svn.info2.call_args[0][0], 'file://'+g.tmpdir+'/code/trunk')
def _test_compute_tree_new(self, path, tree_get, tree_upsert, lcd_partial): repo = Mock(fs_path=g.tmpdir + '/') repo.name = 'code' impl = SVNImplementation(repo) impl._svn.info2 = Mock() impl._svn.info2.return_value = [('foo', Mock())] tree_get.return_value = None # no existing tree commit = Commit() commit._id = '5057636b9c1040636b81e4b1:6' tree_upsert.return_value = (Mock(), True) tree_id = impl.compute_tree_new(commit, path) assert_equal(impl._svn.info2.call_args[0][0], 'file://' + g.tmpdir + '/code/trunk/foo') assert lcd_partial.called
def _test_compute_tree_new(self, path, tree_get, tree_upsert, lcd_partial): repo = Mock(fs_path=g.tmpdir + '/') repo.name = 'code' impl = SVNImplementation(repo) impl._svn.info2 = Mock() impl._svn.info2.return_value = [('foo', Mock())] tree_get.return_value = None # no existing tree commit = Commit() commit._id = '5057636b9c1040636b81e4b1:6' tree_upsert.return_value = (Mock(), True) tree_id = impl.compute_tree_new(commit, path) assert_equal(impl._svn.info2.call_args[0] [0], 'file://' + g.tmpdir + '/code/trunk/foo') assert lcd_partial.called
def test__tarball_path_clean(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._tarball_path_clean(None), '') assert_equal(impl._tarball_path_clean(''), '') # common assert_equal(impl._tarball_path_clean('/some/path/'), 'some/path') assert_equal(impl._tarball_path_clean('some/path'), 'some/path') assert_equal(impl._tarball_path_clean('/some/path/tags/1.0/some/dir'), 'some/path/tags/1.0/some/dir') # with fallback to trunk path_exists.return_value = True assert_equal(impl._tarball_path_clean(None), 'trunk') assert_equal(impl._tarball_path_clean(''), 'trunk')
def test_update_checkout_url(self, svn_path_exists): impl = SVNImplementation(Mock()) opts = impl._repo.app.config.options = {} svn_path_exists.side_effect = lambda path: False opts['checkout_url'] = 'invalid' impl.update_checkout_url() assert_equal(opts['checkout_url'], '') svn_path_exists.side_effect = lambda path: path.endswith('trunk') opts['checkout_url'] = 'invalid' impl.update_checkout_url() assert_equal(opts['checkout_url'], 'trunk') svn_path_exists.side_effect = lambda path: path.endswith('trunk') opts['checkout_url'] = '' impl.update_checkout_url() assert_equal(opts['checkout_url'], 'trunk')
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')