2007-01-24 22:24:01 +08:00
|
|
|
import py
|
2010-01-14 00:15:54 +08:00
|
|
|
from py._path.svnurl import InfoSvnCommand
|
2007-01-24 22:24:01 +08:00
|
|
|
import datetime
|
|
|
|
import time
|
2010-06-04 06:39:58 +08:00
|
|
|
from svntestbase import CommonSvnTests
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def pytest_funcarg__path1(request):
|
2009-12-25 17:47:43 +08:00
|
|
|
repo, repourl, wc = request.getfuncargvalue("repowc1")
|
|
|
|
return py.path.svnurl(repourl)
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
class TestSvnURLCommandPath(CommonSvnTests):
|
|
|
|
@py.test.mark.xfail
|
|
|
|
def test_load(self, path1):
|
|
|
|
super(TestSvnURLCommandPath, self).test_load(path1)
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2010-04-24 01:05:22 +08:00
|
|
|
# the following two work on jython but not in local/svnwc
|
|
|
|
def test_listdir(self, path1):
|
|
|
|
super(TestSvnURLCommandPath, self).test_listdir(path1)
|
|
|
|
def test_visit_ignore(self, path1):
|
|
|
|
super(TestSvnURLCommandPath, self).test_visit_ignore(path1)
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_needs_arg(self, path1):
|
2007-01-24 22:24:01 +08:00
|
|
|
py.test.raises(TypeError, "py.path.svnurl()")
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_does_not_accept_None_either(self, path1):
|
2007-01-24 22:24:01 +08:00
|
|
|
py.test.raises(Exception, "py.path.svnurl(None)")
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_characters_simple(self, path1):
|
2007-01-24 22:24:01 +08:00
|
|
|
py.path.svnurl("svn+ssh://hello/world")
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_characters_at_user(self, path1):
|
2007-01-24 22:24:01 +08:00
|
|
|
py.path.svnurl("http://user@host.com/some/dir")
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_characters_at_path(self, path1):
|
2007-01-24 22:24:01 +08:00
|
|
|
py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo@bar")')
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_characters_colon_port(self, path1):
|
2007-01-24 22:24:01 +08:00
|
|
|
py.path.svnurl("http://host.com:8080/some/dir")
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_characters_tilde_end(self, path1):
|
2007-01-29 00:56:42 +08:00
|
|
|
py.path.svnurl("http://host.com/some/file~")
|
|
|
|
|
2009-10-15 22:18:57 +08:00
|
|
|
@py.test.mark.xfail("sys.platform == 'win32'")
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_characters_colon_path(self, path1):
|
2009-10-15 22:18:57 +08:00
|
|
|
# colons are allowed on win32, because they're part of the drive
|
|
|
|
# part of an absolute path... however, they shouldn't be allowed in
|
|
|
|
# other parts, I think
|
2007-01-24 22:24:01 +08:00
|
|
|
py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo:bar")')
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_export(self, path1, tmpdir):
|
|
|
|
tmpdir = tmpdir.join("empty")
|
|
|
|
p = path1.export(tmpdir)
|
|
|
|
assert p == tmpdir # XXX should return None
|
|
|
|
n1 = [x.basename for x in tmpdir.listdir()]
|
|
|
|
n2 = [x.basename for x in path1.listdir()]
|
|
|
|
n1.sort()
|
|
|
|
n2.sort()
|
2010-07-27 03:15:15 +08:00
|
|
|
assert n1 == n2
|
2009-09-01 01:51:25 +08:00
|
|
|
assert not p.join('.svn').check()
|
|
|
|
rev = path1.mkdir("newdir")
|
|
|
|
tmpdir.remove()
|
|
|
|
assert not tmpdir.check()
|
|
|
|
path1.new(rev=1).export(tmpdir)
|
|
|
|
for p in tmpdir.listdir():
|
|
|
|
assert p.basename in n2
|
2007-09-17 20:22:39 +08:00
|
|
|
|
2007-01-24 22:24:01 +08:00
|
|
|
class TestSvnInfoCommand:
|
|
|
|
|
|
|
|
def test_svn_1_2(self):
|
|
|
|
line = " 2256 hpk 165 Nov 24 17:55 __init__.py"
|
|
|
|
info = InfoSvnCommand(line)
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
assert info.last_author == 'hpk'
|
|
|
|
assert info.created_rev == 2256
|
|
|
|
assert info.kind == 'file'
|
2007-02-08 04:40:37 +08:00
|
|
|
# we don't check for the year (2006), because that depends
|
|
|
|
# on the clock correctly being setup
|
|
|
|
assert time.gmtime(info.mtime)[1:6] == (11, 24, 17, 55, 0)
|
2007-01-24 22:24:01 +08:00
|
|
|
assert info.size == 165
|
|
|
|
assert info.time == info.mtime * 1000000
|
|
|
|
|
|
|
|
def test_svn_1_3(self):
|
|
|
|
line =" 4784 hpk 2 Jun 01 2004 __init__.py"
|
|
|
|
info = InfoSvnCommand(line)
|
|
|
|
assert info.last_author == 'hpk'
|
|
|
|
assert info.kind == 'file'
|
|
|
|
|
|
|
|
def test_svn_1_3_b(self):
|
|
|
|
line =" 74 autoadmi Oct 06 23:59 plonesolutions.com/"
|
|
|
|
info = InfoSvnCommand(line)
|
|
|
|
assert info.last_author == 'autoadmi'
|
|
|
|
assert info.kind == 'dir'
|
|
|
|
|
|
|
|
def test_badchars():
|
2009-05-08 03:04:56 +08:00
|
|
|
py.test.raises(ValueError, "py.path.svnurl('http://host/tmp/@@@:')")
|