Пример #1
0
 def test_common_and_host_file_collision(self):
     '''
     What happens if a file with the same name exists in the common dir and
     in the "hostname" dir?
     Desired behavior is that common is linked first and hostname overwrites
     it, so that common can have a config that applies to all machines, but
     it gets overwritten on a machine by machine basis.
     '''
     real_bothfile = path.join(self.indir, gethostname(), 'bothfile')
     real_bothfile_back = path.join(self.indir, 'common', 'bothfile')
     self.touch(real_bothfile)
     self.touch(real_bothfile_back)
     linker = Linker(self.indir, self.outdir)
     linker.make_links()
     bothfile=path.join(self.outdir, 'bothfile')
     bothfile_back=path.join(self.outdir, 'bothfile.back')
     try:
         self.assertTrue(path.exists(bothfile))
         self.assertTrue(path.exists(bothfile_back))
         self.assertTrue(path.islink(bothfile))
         self.assertTrue(path.islink(bothfile_back))
         self.assertEqual(real_bothfile, path.realpath(bothfile))
         self.assertEqual(real_bothfile_back, path.realpath(bothfile_back))
     finally:
         remove(real_bothfile)
         remove(real_bothfile_back)
Пример #2
0
 def test_exclude_common(self):
     linker = Linker(target=self.indir, destination=self.outdir,
                     exclude_common=True)
     want = ['hostnamefile1']
     linker.make_links()
     have = listdir(self.outdir)
     self.assertEqual(want, have)
Пример #3
0
 def test_relative_paths(self):
     linker = Linker(target='./tests/input', destination='./tests/output')
     want = ['commonfile1', '.commonfile3', 'common_file5', 'hostnamefile1',
             '/tmp/commonfile4']
     linker.make_links()
     have = listdir(path.abspath(path.expanduser('./tests/output')))
     if path.exists(want[-1]): have.append(want[-1])
     want.sort()
     have.sort()
     self.assertEqual(want, have)
Пример #4
0
 def test_move_existing(self):
     want = ['commonfile1', '.commonfile3', 'common_file5', 'hostnamefile1',
             'common_file5.back']
     self.touch(self.outdir, 'common_file5')
     linker = Linker(self.indir, self.outdir)
     linker.make_links()
     have = listdir(self.outdir)
     want.sort()
     have.sort()
     self.assertEqual(want, have)
Пример #5
0
 def test_vanilla(self):
     linker = Linker(target=self.indir, destination=self.outdir)
     want = ['commonfile1', '.commonfile3', 'common_file5', 'hostnamefile1',
             '/tmp/commonfile4']
     linker.make_links()
     have = listdir(self.outdir)
     if path.exists(want[-1]): have.append(want[-1])
     want.sort()
     have.sort()
     self.assertEqual(want, have)
Пример #6
0
 def test_delete_existing(self):
     want = ['commonfile1', '.commonfile3', 'common_file5', 'hostnamefile1']
     self.touch(self.outdir, 'common_file5')
     self.assertTrue(not path.islink(path.join(self.outdir, 'common_file5')))
     linker = Linker(self.indir, self.outdir, delete_existing=True)
     linker.make_links()
     have = listdir(self.outdir)
     want.sort()
     have.sort()
     self.assertEqual(want, have)
     self.assertTrue(path.islink(path.join(self.outdir, 'common_file5')))
Пример #7
0
 def test_dry_run(self):
     linker = Linker(self.indir, self.outdir, dry_run=True)
     want = []
     linker.make_links()
     have = listdir(self.outdir)
     self.assertEqual(want, have)