summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing/FilenameMappingtest.py
blob: 66ab7861099356b7de30c2708ac0d1452850b5fd (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
import unittest
from commontest import *
from rdiff_backup import FilenameMapping

class FilenameMappingTest(unittest.TestCase):
	"""Test the FilenameMapping class, for quoting filenames"""
	def setUp(self):
		"""Just initialize quoting - assume windows mode"""
		FilenameMapping.set_init_quote_vals()

	def testBasicQuote(self):
		"""Test basic quoting and unquoting"""
		filenames = ["hello", "HeLLo", "EUOeu/EUOeu", ":", "::::EU", "/:/:"]
		for filename in filenames:
			quoted = FilenameMapping.quote(filename)
			assert FilenameMapping.unquote(quoted) == filename, filename

	def testQuotedRPath(self):
		"""Test the QuotedRPath class"""

	def testQuotedSepBase(self):
		"""Test get_quoted_sep_base function"""
		path = ("/usr/local/mirror_metadata"
				".1969-12-31;08421;05833;05820-07;05800.data.gz")
		qrp = FilenameMapping.get_quoted_sep_base(path)
		assert qrp.base == "/usr/local", qrp.base
		assert len(qrp.index) == 1, qrp.index
		assert (qrp.index[0] ==
				"mirror_metadata.1969-12-31T21:33:20-07:00.data.gz")

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