1import py 2from py._path.svnurl import InfoSvnCommand 3import datetime 4import time 5from svntestbase import CommonSvnTests 6 7def pytest_funcarg__path1(request): 8 repo, repourl, wc = request.getfuncargvalue("repowc1") 9 return py.path.svnurl(repourl) 10 11class TestSvnURLCommandPath(CommonSvnTests): 12 @py.test.mark.xfail 13 def test_load(self, path1): 14 super(TestSvnURLCommandPath, self).test_load(path1) 15 16 # the following two work on jython but not in local/svnwc 17 def test_listdir(self, path1): 18 super(TestSvnURLCommandPath, self).test_listdir(path1) 19 def test_visit_ignore(self, path1): 20 super(TestSvnURLCommandPath, self).test_visit_ignore(path1) 21 22 def test_svnurl_needs_arg(self, path1): 23 py.test.raises(TypeError, "py.path.svnurl()") 24 25 def test_svnurl_does_not_accept_None_either(self, path1): 26 py.test.raises(Exception, "py.path.svnurl(None)") 27 28 def test_svnurl_characters_simple(self, path1): 29 py.path.svnurl("svn+ssh://hello/world") 30 31 def test_svnurl_characters_at_user(self, path1): 32 py.path.svnurl("http://user@host.com/some/dir") 33 34 def test_svnurl_characters_at_path(self, path1): 35 py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo@bar")') 36 37 def test_svnurl_characters_colon_port(self, path1): 38 py.path.svnurl("http://host.com:8080/some/dir") 39 40 def test_svnurl_characters_tilde_end(self, path1): 41 py.path.svnurl("http://host.com/some/file~") 42 43 @py.test.mark.xfail("sys.platform == 'win32'") 44 def test_svnurl_characters_colon_path(self, path1): 45 # colons are allowed on win32, because they're part of the drive 46 # part of an absolute path... however, they shouldn't be allowed in 47 # other parts, I think 48 py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo:bar")') 49 50 def test_export(self, path1, tmpdir): 51 tmpdir = tmpdir.join("empty") 52 p = path1.export(tmpdir) 53 assert p == tmpdir # XXX should return None 54 n1 = [x.basename for x in tmpdir.listdir()] 55 n2 = [x.basename for x in path1.listdir()] 56 n1.sort() 57 n2.sort() 58 assert n1 == n2 59 assert not p.join('.svn').check() 60 rev = path1.mkdir("newdir") 61 tmpdir.remove() 62 assert not tmpdir.check() 63 path1.new(rev=1).export(tmpdir) 64 for p in tmpdir.listdir(): 65 assert p.basename in n2 66 67class TestSvnInfoCommand: 68 69 def test_svn_1_2(self): 70 line = " 2256 hpk 165 Nov 24 17:55 __init__.py" 71 info = InfoSvnCommand(line) 72 now = datetime.datetime.now() 73 assert info.last_author == 'hpk' 74 assert info.created_rev == 2256 75 assert info.kind == 'file' 76 # we don't check for the year (2006), because that depends 77 # on the clock correctly being setup 78 assert time.gmtime(info.mtime)[1:6] == (11, 24, 17, 55, 0) 79 assert info.size == 165 80 assert info.time == info.mtime * 1000000 81 82 def test_svn_1_3(self): 83 line =" 4784 hpk 2 Jun 01 2004 __init__.py" 84 info = InfoSvnCommand(line) 85 assert info.last_author == 'hpk' 86 assert info.kind == 'file' 87 88 def test_svn_1_3_b(self): 89 line =" 74 autoadmi Oct 06 23:59 plonesolutions.com/" 90 info = InfoSvnCommand(line) 91 assert info.last_author == 'autoadmi' 92 assert info.kind == 'dir' 93 94def test_badchars(): 95 py.test.raises(ValueError, "py.path.svnurl('http://host/tmp/@@@:')") 96