2
from py.__.path.svn.testing.svntestbase import CommonSvnTests, getrepowc
3
from py.__.path.svn.wccommand import InfoSvnWCCommand
4
from py.__.path.svn.wccommand import parse_wcinfotime
5
from py.__.path.svn import svncommon
8
if py.path.local.sysfind('svn') is None:
9
py.test.skip("cannot test py.path.svn, 'svn' binary not found")
12
class TestWCSvnCommandPath(CommonSvnTests):
15
repo, cls.root = getrepowc()
17
def test_move_file(self): # overrides base class
19
super(TestWCSvnCommandPath, self).test_move_file()
21
self.root.revert(rec=1)
23
def test_move_directory(self): # overrides base class
25
super(TestWCSvnCommandPath, self).test_move_directory()
27
self.root.revert(rec=1)
29
def test_status_attributes_simple(self):
30
def assert_nochange(p):
33
assert not s.prop_modified
37
dpath = self.root.join('sampledir')
38
assert_nochange(self.root.join('sampledir'))
39
assert_nochange(self.root.join('samplefile'))
41
def test_status_added(self):
42
nf = self.root.join('newfile')
49
assert not s.prop_modified
53
def test_status_change(self):
54
nf = self.root.join('samplefile')
56
nf.write(nf.read() + 'change')
60
assert not s.prop_modified
64
def test_status_added_ondirectory(self):
65
sampledir = self.root.join('sampledir')
67
t2 = sampledir.mkdir('t2')
71
s = sampledir.status(rec=1)
72
# Comparing just the file names, because paths are unpredictable
73
# on Windows. (long vs. 8.3 paths)
74
assert t1.basename in [item.basename for item in s.added]
75
assert t2.basename in [item.basename for item in s.added]
78
t2.localpath.remove(rec=1)
80
def test_status_unknown(self):
81
t1 = self.root.join('un1')
84
s = self.root.status()
85
# Comparing just the file names, because paths are unpredictable
86
# on Windows. (long vs. 8.3 paths)
87
assert t1.basename in [item.basename for item in s.unknown]
91
def test_status_unchanged(self):
93
s = self.root.status(rec=1)
94
# Comparing just the file names, because paths are unpredictable
95
# on Windows. (long vs. 8.3 paths)
96
assert r.join('samplefile').basename in [item.basename
97
for item in s.unchanged]
98
assert r.join('sampledir').basename in [item.basename
99
for item in s.unchanged]
100
assert r.join('sampledir/otherfile').basename in [item.basename
101
for item in s.unchanged]
103
def test_status_update(self):
107
s = r.status(updates=1, rec=1)
108
# Comparing just the file names, because paths are unpredictable
109
# on Windows. (long vs. 8.3 paths)
110
assert r.join('anotherfile').basename in [item.basename for
111
item in s.update_available]
112
#assert len(s.update_available) == 1
117
p = self.root / 'anotherfile'
119
assert out.find('hello') != -1
121
def test_blame(self):
122
p = self.root.join('samplepickle')
124
assert sum([l[0] for l in lines]) == len(lines)
125
for l1, l2 in zip(p.readlines(), [l[2] for l in lines]):
127
assert [l[1] for l in lines] == ['hpk'] * len(lines)
128
p = self.root.join('samplefile')
130
assert sum([l[0] for l in lines]) == len(lines)
131
for l1, l2 in zip(p.readlines(), [l[2] for l in lines]):
133
assert [l[1] for l in lines] == ['hpk'] * len(lines)
135
def test_join_abs(self):
136
s = str(self.root.localpath)
137
n = self.root.join(s, abs=1)
138
assert self.root == n
140
def test_join_abs2(self):
141
assert self.root.join('samplefile', abs=1) == self.root.join('samplefile')
143
def test_str_gives_localpath(self):
144
assert str(self.root) == str(self.root.localpath)
146
def test_versioned(self):
147
assert self.root.check(versioned=1)
148
# TODO: Why does my copy of svn think .svn is versioned?
149
#assert self.root.join('.svn').check(versioned=0)
150
assert self.root.join('samplefile').check(versioned=1)
151
assert not self.root.join('notexisting').check(versioned=1)
152
notexisting = self.root.join('hello').localpath
154
notexisting.write("")
155
assert self.root.join('hello').check(versioned=0)
159
def test_properties(self):
161
self.root.propset('gaga', 'this')
162
assert self.root.propget('gaga') == 'this'
163
# Comparing just the file names, because paths are unpredictable
164
# on Windows. (long vs. 8.3 paths)
165
assert self.root.basename in [item.basename for item in
166
self.root.status().prop_modified]
167
assert 'gaga' in self.root.proplist()
168
assert self.root.proplist()['gaga'] == 'this'
171
self.root.propdel('gaga')
173
def test_proplist_recursive(self):
174
s = self.root.join('samplefile')
175
s.propset('gugu', 'that')
177
p = self.root.proplist(rec=1)
178
# Comparing just the file names, because paths are unpredictable
179
# on Windows. (long vs. 8.3 paths)
180
assert (self.root / 'samplefile').basename in [item.basename
185
def test_long_properties(self):
187
vadm:posix : root root 0100755
188
Properties on 'chroot/dns/var/bind/db.net.xots':
191
self.root.propset('gaga', value)
192
backvalue = self.root.propget('gaga')
193
assert backvalue == value
194
#assert len(backvalue.split('\n')) == 1
196
self.root.propdel('gaga')
199
def test_ensure(self):
200
newpath = self.root.ensure('a', 'b', 'c')
202
assert newpath.check(exists=1, versioned=1)
203
newpath.write("hello")
205
assert newpath.read() == "hello"
207
self.root.join('a').remove(force=1)
209
def test_not_versioned(self):
210
p = self.root.localpath.mkdir('whatever')
211
f = self.root.localpath.ensure('testcreatedfile')
213
assert self.root.join('whatever').check(versioned=0)
214
assert self.root.join('testcreatedfile').check(versioned=0)
215
assert not self.root.join('testcreatedfile').check(versioned=1)
221
# l = self.root.log()
222
# assert len(l) == 3 # might need to be upped if more tests are added
224
class XTestWCSvnCommandPathSpecial:
226
rooturl = 'http://codespeak.net/svn/py.path/trunk/dist/py.path/test/data'
227
#def test_update_none_rev(self):
228
# path = tmpdir.join('checkouttest')
229
# wcpath = newpath(xsvnwc=str(path), url=self.rooturl)
231
# wcpath.checkout(rev=2100)
233
# assert wcpath.info().rev > 2100
235
# wcpath.localpath.remove(rec=1)
237
def test_parse_wcinfotime():
238
assert (parse_wcinfotime('2006-05-30 20:45:26 +0200 (Tue, 30 May 2006)') ==
240
assert (parse_wcinfotime('2003-10-27 20:43:14 +0100 (Mon, 27 Oct 2003)') ==
243
class TestInfoSvnWCCommand:
245
def test_svn_1_2(self):
247
Path: test_wccommand.py
248
Name: test_wccommand.py
249
URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py
250
Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada
254
Last Changed Author: jan
255
Last Changed Rev: 27939
256
Last Changed Date: 2006-05-30 20:45:26 +0200 (Tue, 30 May 2006)
257
Text Last Updated: 2006-06-01 00:42:53 +0200 (Thu, 01 Jun 2006)
258
Properties Last Updated: 2006-05-23 11:54:59 +0200 (Tue, 23 May 2006)
259
Checksum: 357e44880e5d80157cc5fbc3ce9822e3
261
path = py.magic.autopath().dirpath().chdir()
262
info = InfoSvnWCCommand(output)
264
assert info.last_author == 'jan'
265
assert info.kind == 'file'
266
assert info.mtime == 1149021926.0
267
assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py'
268
assert info.time == 1149021926000000.0
269
assert info.rev == 28137
272
def test_svn_1_3(self):
274
Path: test_wccommand.py
275
Name: test_wccommand.py
276
URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py
277
Repository Root: http://codespeak.net/svn
278
Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada
282
Last Changed Author: jan
283
Last Changed Rev: 27939
284
Last Changed Date: 2006-05-30 20:45:26 +0200 (Tue, 30 May 2006)
285
Text Last Updated: 2006-06-02 23:46:11 +0200 (Fri, 02 Jun 2006)
286
Properties Last Updated: 2006-06-02 23:45:28 +0200 (Fri, 02 Jun 2006)
287
Checksum: 357e44880e5d80157cc5fbc3ce9822e3
289
path = py.magic.autopath().dirpath().chdir()
290
info = InfoSvnWCCommand(output)
292
assert info.last_author == 'jan'
293
assert info.kind == 'file'
294
assert info.mtime == 1149021926.0
295
assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py'
296
assert info.rev == 28124
297
assert info.time == 1149021926000000.0
299
class TestWCSvnCommandPathEmptyRepo(object):
301
def setup_class(cls):
302
repo = py.test.ensuretemp("emptyrepo")
303
wcdir = py.test.ensuretemp("emptywc")
304
py.process.cmdexec('svnadmin create "%s"' %
305
svncommon._escape_helper(repo))
306
wc = py.path.svnwc(wcdir)
307
repopath = repo.strpath
308
if py.std.sys.platform.startswith('win32'):
309
# strange win problem, paths become something like file:///c:\\foo
310
repourl = 'file:///%s' % (repopath.replace('\\', '/'),)
312
repourl = 'file://%s' % (repopath,)
313
wc.checkout(url=repourl)
317
self.wc.info().rev = 0
319
def test_characters_at():
320
py.test.raises(ValueError, "py.path.svnwc('/tmp/@@@:')")
322
def test_characters_tilde():
323
py.path.svnwc('/tmp/test~')