1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-15 20:50:05 +00:00

add tests for template and trans_w

This commit is contained in:
deadc0de6
2019-02-12 09:54:05 +01:00
parent 2922b8bd72
commit 24e60b3f7f

View File

@@ -10,6 +10,7 @@ import os
from dotdrop.dotdrop import cmd_update from dotdrop.dotdrop import cmd_update
from dotdrop.dotdrop import cmd_importer from dotdrop.dotdrop import cmd_importer
from dotdrop.action import Transform
from tests.helpers import create_dir, get_string, get_tempdir, clean, \ from tests.helpers import create_dir, get_string, get_tempdir, clean, \
create_random_file, create_fake_config, load_options, edit_content create_random_file, create_fake_config, load_options, edit_content
@@ -53,6 +54,7 @@ class TestUpdate(unittest.TestCase):
self.assertTrue(os.path.exists(d2)) self.assertTrue(os.path.exists(d2))
self.addCleanup(clean, d2) self.addCleanup(clean, d2)
# template
d3t, c3t = create_random_file(fold_config) d3t, c3t = create_random_file(fold_config)
self.assertTrue(os.path.exists(d3t)) self.assertTrue(os.path.exists(d3t))
self.addCleanup(clean, d3t) self.addCleanup(clean, d3t)
@@ -82,6 +84,21 @@ class TestUpdate(unittest.TestCase):
# get new config # get new config
o = load_options(confpath, profile) o = load_options(confpath, profile)
o.safe = False
o.debug = True
o.update_showpatch = True
trans = Transform('trans', 'cp -r {0} {1}')
d3tb = os.path.basename(d3t)
for dotfile in o.dotfiles:
if os.path.basename(dotfile.dst) == d3tb:
src = os.path.join(o.dotpath, dotfile.src)
src = os.path.expanduser(src)
edit_content(src, '{{@@ profile @@}}')
dotfile.trans_w = trans
# update template
o.update_path = [d3t]
self.assertFalse(cmd_update(o))
# edit the files # edit the files
edit_content(d1, 'newcontent') edit_content(d1, 'newcontent')
@@ -96,10 +113,7 @@ class TestUpdate(unittest.TestCase):
create_random_file(dpath) create_random_file(dpath)
# update it # update it
o.safe = False
o.debug = True
o.update_path = [d1, dir1] o.update_path = [d1, dir1]
o.update_showpatch = True
cmd_update(o) cmd_update(o)
# test content # test content
@@ -119,8 +133,6 @@ class TestUpdate(unittest.TestCase):
d2key = ds.key d2key = ds.key
break break
self.assertTrue(d2key != '') self.assertTrue(d2key != '')
o.safe = False
o.debug = True
o.update_path = [d2key] o.update_path = [d2key]
o.update_iskey = True o.update_iskey = True
cmd_update(o) cmd_update(o)