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

adding ability to update by key or on all keys of a specific profile

This commit is contained in:
deadc0de6
2018-10-08 21:36:12 +02:00
parent b71cbefa10
commit 2b901d5608
5 changed files with 211 additions and 30 deletions

View File

@@ -51,6 +51,10 @@ class TestUpdate(unittest.TestCase):
self.assertTrue(os.path.exists(d1))
self.addCleanup(clean, d1)
d2, c2 = create_random_file(fold_config)
self.assertTrue(os.path.exists(d2))
self.addCleanup(clean, d2)
# create the directory to test
dpath = os.path.join(fold_config, get_string(5))
dir1 = create_dir(dpath)
@@ -65,7 +69,7 @@ class TestUpdate(unittest.TestCase):
create=self.CONFIG_CREATE)
self.assertTrue(os.path.exists(confpath))
conf, opts = load_config(confpath, profile)
dfiles = [d1, dir1]
dfiles = [d1, dir1, d2]
# import the files
cmd_importer(opts, conf, dfiles)
@@ -94,6 +98,25 @@ class TestUpdate(unittest.TestCase):
newcontent = open(dirf1, 'r').read()
self.assertTrue(newcontent == 'newcontent')
edit_content(d2, 'newcontentbykey')
# update it by key
dfiles = conf.get_dotfiles(profile)
d2key = ''
for ds in dfiles:
t = os.path.expanduser(ds.dst)
if t == d2:
d2key = ds.key
break
self.assertTrue(d2key != '')
opts['safe'] = False
opts['debug'] = True
cmd_update(opts, conf, [d2key], iskey=True)
# test content
newcontent = open(d2, 'r').read()
self.assertTrue(newcontent == 'newcontentbykey')
def main():
unittest.main()