mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 15:39:43 +00:00
update tests and improve
This commit is contained in:
@@ -41,7 +41,8 @@ class TestCompare(unittest.TestCase):
|
||||
if not ret:
|
||||
results[path] = False
|
||||
continue
|
||||
diff = comp.compare(insttmp, dotfile.dst)
|
||||
diff = comp.compare(insttmp, dotfile.dst,
|
||||
ignore=['whatever', 'whatelse'])
|
||||
print('XXXX diff for {} and {}:\n{}'.format(dotfile.src,
|
||||
dotfile.dst,
|
||||
diff))
|
||||
@@ -49,13 +50,6 @@ class TestCompare(unittest.TestCase):
|
||||
results[path] = diff == ''
|
||||
return results
|
||||
|
||||
def edit_content(self, path, newcontent, binary=False):
|
||||
mode = 'w'
|
||||
if binary:
|
||||
mode = 'wb'
|
||||
with open(path, mode) as f:
|
||||
f.write(newcontent)
|
||||
|
||||
def test_compare(self):
|
||||
'''Test the compare function'''
|
||||
# setup some directories
|
||||
@@ -118,13 +112,13 @@ class TestCompare(unittest.TestCase):
|
||||
self.assertTrue(results == expected)
|
||||
|
||||
# modify file
|
||||
self.edit_content(d1, get_string(20))
|
||||
edit_content(d1, get_string(20))
|
||||
expected = {d1: False, d2: True, d3: True, d4: True, d5: True}
|
||||
results = self.compare(opts, conf, tmp, len(dfiles))
|
||||
self.assertTrue(results == expected)
|
||||
|
||||
# modify binary file
|
||||
self.edit_content(d4, bytes(get_string(20), 'ascii'), binary=True)
|
||||
edit_content(d4, bytes(get_string(20), 'ascii'), binary=True)
|
||||
expected = {d1: False, d2: True, d3: True, d4: False, d5: True}
|
||||
results = self.compare(opts, conf, tmp, len(dfiles))
|
||||
self.assertTrue(results == expected)
|
||||
@@ -137,8 +131,8 @@ class TestCompare(unittest.TestCase):
|
||||
self.assertTrue(results == expected)
|
||||
|
||||
# modify all files
|
||||
self.edit_content(d2, get_string(20))
|
||||
self.edit_content(d3, get_string(21))
|
||||
edit_content(d2, get_string(20))
|
||||
edit_content(d3, get_string(21))
|
||||
expected = {d1: False, d2: False, d3: False, d4: False, d5: False}
|
||||
results = self.compare(opts, conf, tmp, len(dfiles))
|
||||
self.assertTrue(results == expected)
|
||||
|
||||
Reference in New Issue
Block a user