summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing/destructive_steppingtest.py
blob: 96754481330ccf93a323169b0eb5da5f826068e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import generators
import unittest
from commontest import *
from rdiff_backup import rpath, selection, Globals, destructive_stepping

Log.setverbosity(4)

class DSTest(unittest.TestCase):
	def setUp(self):
		self.lc = Globals.local_connection
		self.noperms = rpath.RPath(self.lc, "testfiles/noperms")
		Globals.change_source_perms = 1
		self.iteration_dir = rpath.RPath(self.lc, "testfiles/iteration-test")

	def testDSIter(self):
		"""Testing destructive stepping iterator from baserp"""
		for i in range(2):
			sel = selection.Select(destructive_stepping.
								        DSRPath(1, self.noperms)).set_iter()
			ds_iter = sel.iterate_with_finalizer()
			noperms = ds_iter.next()
			assert noperms.isdir() and noperms.getperms() == 0, \
				   (noperms.isdir(), noperms.getperms())

			bar = ds_iter.next()
			assert bar.isreg() and bar.getperms() == 0, \
				   "%s %s" % (bar.isreg(), bar.getperms())
			barbuf = bar.open("rb").read()
			assert len(barbuf) > 0
			
			foo = ds_iter.next()
			assert foo.isreg() and foo.getperms() == 0
			assert foo.getmtime() < 1000300000

			fuz = ds_iter.next()
			assert fuz.isreg() and fuz.getperms() == 0200
			fuzbuf = fuz.open("rb").read()
			assert len(fuzbuf) > 0

			self.assertRaises(StopIteration, ds_iter.next)

if __name__ == "__main__": unittest.main()