MCPcopy
hub / github.com/deadc0de6/dotdrop / test_remove

Method test_remove

tests/test_remove.py:25–124  ·  view source on GitHub ↗

test the remove command

(self)

Source from the content-addressed store, hash-verified

23 return yaml_load(path)
24
25 def test_remove(self):
26 """test the remove command"""
27
28 # dotfiles in dotpath
29 dotdrop_home = get_tempdir()
30 self.assertTrue(os.path.exists(dotdrop_home))
31 self.addCleanup(clean, dotdrop_home)
32
33 dotfilespath = os.path.join(dotdrop_home, 'dotfiles')
34 confpath = os.path.join(dotdrop_home, 'config.yaml')
35 create_dir(dotfilespath)
36
37 df1, _ = create_random_file(dotfilespath)
38 df2, _ = create_random_file(dotfilespath)
39 df3, _ = create_random_file(dotfilespath)
40 configdic = {
41 'config': {
42 'dotpath': 'dotfiles',
43 },
44 'dotfiles': {
45 'f_test1': {
46 'src': df1,
47 'dst': '/dev/null'
48 },
49 'f_test2': {
50 'src': df2,
51 'dst': '/dev/null'
52 },
53 'f_test3': {
54 'src': df3,
55 'dst': '/tmp/some-fake-path'
56 },
57 },
58 'profiles': {
59 'host1': {
60 'dotfiles': ['f_test1', 'f_test2', 'f_test3'],
61 },
62 'host2': {
63 'dotfiles': ['f_test1'],
64 },
65 'host3': {
66 'dotfiles': ['f_test2'],
67 },
68 },
69 }
70
71 yaml_dump(configdic, confpath)
72 opt = load_options(confpath, 'host1')
73 opt.remove_path = ['f_test1']
74 opt.remove_iskey = True
75 opt.debug = True
76 opt.safe = False
77 # by key
78 cmd_remove(opt)
79
80 # ensure file is deleted
81 self.assertFalse(os.path.exists(df1))
82 self.assertTrue(os.path.exists(df2))

Callers

nothing calls this directly

Calls 7

get_tempdirFunction · 0.90
create_dirFunction · 0.90
create_random_fileFunction · 0.90
yaml_dumpFunction · 0.90
load_optionsFunction · 0.90
cmd_removeFunction · 0.90
yaml_loadFunction · 0.90

Tested by

no test coverage detected