2007-01-24 22:24:01 +08:00
|
|
|
import py
|
2009-10-03 07:47:39 +08:00
|
|
|
from _py.path.svnurl import InfoSvnCommand
|
2007-01-24 22:24:01 +08:00
|
|
|
import datetime
|
|
|
|
import time
|
2009-09-06 22:59:39 +08:00
|
|
|
from testing.path.svntestbase import CommonSvnTests
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def pytest_funcarg__path1(request):
|
|
|
|
repo, wc = request.getfuncargvalue("repowc1")
|
|
|
|
return py.path.svnurl(repo)
|
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
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_move_file(self, path1): # overrides base class
|
|
|
|
p = path1.ensure('origfile')
|
2007-02-08 04:40:37 +08:00
|
|
|
newp = p.dirpath('newfile')
|
|
|
|
p.move(newp)
|
|
|
|
assert newp.check(file=1)
|
|
|
|
newp.remove()
|
|
|
|
assert not p.check()
|
|
|
|
|
2009-09-01 01:51:25 +08:00
|
|
|
def test_move_dir(self, path1): # overrides base class
|
|
|
|
p = path1.ensure('origdir', dir=1)
|
2007-02-08 04:40:37 +08:00
|
|
|
newp = p.dirpath('newdir')
|
|
|
|
p.move(newp)
|
|
|
|
assert newp.check(dir=1)
|
|
|
|
newp.remove()
|
|
|
|
assert not p.check()
|
|
|
|
|
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-09-01 01:51:25 +08:00
|
|
|
def test_svnurl_characters_colon_path(self, path1):
|
2007-01-24 22:24:01 +08:00
|
|
|
if py.std.sys.platform == 'win32':
|
|
|
|
# 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
|
|
|
|
py.test.skip('XXX fixme win32')
|
|
|
|
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()
|
|
|
|
assert n1 == n2
|
|
|
|
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/@@@:')")
|