Ejemplo n.º 1
0
    def test_check_args(self):
        args = stowage.parse_args([])
        with pytest.raises(ValueError):
            stowage.check_args(args)
        args = stowage.parse_args(['-s', '~/stuff', '-v', 'pkg'])
        stowage.check_args(args)
        assert stowage._is_verbose

        # ensure expands home
        assert ('home' in args.source or  # linux
                'Users' in args.source  # macOS
                )
Ejemplo n.º 2
0
 def test_parse_args_default(self):
     args = stowage.parse_args([])
     assert args.packages == []
     assert args.source == '~/dotfiles'
     assert args.destination == '~'
     assert args.backup == '~/.config/stowage/backup/'
     assert not args.dryrun
     assert not args.verbose
     assert not args.skip_backup
Ejemplo n.º 3
0
 def test_arg_source_directories(self):
     args = stowage.parse_args([
         '--source',
         'src',
         '--dest',
         'dest',
         'pkg1',
         'pkg2',
     ])
     dirs = list(stowage.source_directories(args))
     assert dirs == ['src/pkg1', 'src/pkg2']
Ejemplo n.º 4
0
 def test_environ_defaults(self):
     os.environ['STOWAGE_SOURCE'] = 'src'
     os.environ['STOWAGE_DESTINATION'] = 'dest'
     os.environ['STOWAGE_BACKUP'] = 'bup'
     args = stowage.parse_args([])
     assert args.source == 'src'
     assert args.destination == 'dest'
     assert args.backup == 'bup'
     del os.environ['STOWAGE_SOURCE']
     del os.environ['STOWAGE_DESTINATION']
     del os.environ['STOWAGE_BACKUP']
Ejemplo n.º 5
0
 def test_main(self):
     args = stowage.parse_args([
         '--source',
         self.dir,
         '--destination',
         self.out_dir,
         '--backup',
         join(self.dir, 'path/to/bup'),
         'vim',
     ])
     stowage.main(args)
     assert exists(join(self.out_dir, '.vimrc'))
     assert exists(join(self.out_dir, '.config', 'openbox', 'openbox.xml'))
     contents = open(join(self.out_dir, '.vimrc')).read()
     assert contents == '%s contents' % join(self.dir, 'vim', '_vimrc')
Ejemplo n.º 6
0
 def test_parse_args_all(self):
     args = stowage.parse_args([
         '-d',
         'dest',
         '-s',
         'src',
         '-b',
         'backup',
         '--dryrun',
         '--verbose',
         '--skip-backup',
         'pkg1',
         'pkg2',
         'pkg3',
     ])
     assert args.packages == ['pkg1', 'pkg2', 'pkg3']
     assert args.source == 'src'
     assert args.destination == 'dest'
     assert args.backup == 'backup'
     assert args.dryrun
     assert args.verbose
     assert args.skip_backup
Ejemplo n.º 7
0
 def test_needed_symlink_walk(self):
     args = stowage.parse_args([])
     results = list(stowage.needed_symlink_walk(self.dir, 'test_out'))
     results_set = set(results)
     assert len(results_set) == len(results)  # ensure no dupes
     assert results_set == self.results