예제 #1
0
 def test_save_with_no_pathname(self):
     """Tests saving config file without an explicit pathname."""
     config = Config(testing.configuration_file())
     config.excludes = []
     config.save()
     config = Config(testing.configuration_file())
     self.assertEquals(config.excludes, [])
예제 #2
0
 def test_configuration_file(self):
     """Tests creating a Config object with a filename."""
     config = Config(testing.configuration_file())
     self.assertEquals(config.base, self.defaults['base'])
     self.assertEquals(config.excludes, self.defaults['excludes'])
     self.assertEquals(config.override, self.defaults['override'])
     self.assertEquals(config.directory, self.defaults['directory'])
예제 #3
0
파일: test.py 프로젝트: sdejean/homekeeper
 def _configure(self):
     self.config = config.Config()
     self.config.base = testing.base_directory()
     self.config.directory = testing.main_directory()
     self.config.override = True
     self.config.save(testing.configuration_file())
     self.homekeeper = homekeeper.Homekeeper()
예제 #4
0
 def test_dotfiles_directory_key_overrides(self):
     """Tests that the old 'dotfiles_directory' key should override the
     'directory' key if present."""
     self.defaults['dotfiles_directory'] = testing.dotfiles_directory()
     self.create_config_file()
     config = Config(testing.configuration_file())
     self.assertNotEquals(config.directory, self.defaults['directory'])
     self.assertEquals(config.directory, self.defaults['dotfiles_directory'])
예제 #5
0
 def test_save(self):
     """Tests saving a config file."""
     pathname = os.path.join(os.getenv('HOME'), 'saved.json')
     config = Config(testing.configuration_file())
     config.excludes = []
     config.override = True
     config.save(pathname)
     config = Config(pathname)
     self.assertEquals(config.excludes, [])
     self.assertEquals(config.override, True)
예제 #6
0
파일: test.py 프로젝트: sdejean/homekeeper
 def test_link_with_cherrypicks(self, cleanup_symlinks, create_symlinks):
     self.config.cherrypicks = [os.path.join('.foo', 'bar', 'baz')]
     self.config.save(testing.configuration_file())
     self.homekeeper = homekeeper.Homekeeper()
     self.homekeeper.link()
     create_symlinks.assert_called_with(self.config.directory,
                                        self.home,
                                        excludes=self.config.excludes,
                                        cherrypicks=self.config.cherrypicks)
     cleanup_symlinks.assert_called_with(os.getenv('HOME'))
예제 #7
0
파일: test.py 프로젝트: sdejean/homekeeper
 def test_link_with_excludes(self, cleanup_symlinks, create_symlinks):
     self.config.excludes = ['.bashrc']
     self.config.save(testing.configuration_file())
     self.homekeeper = homekeeper.Homekeeper()
     self.filesystem.CreateFile(os.path.join(self.config.base, '.bashrc'))
     self.filesystem.CreateFile(os.path.join(self.home, '.bashrc'))
     self.homekeeper.link()
     create_symlinks.assert_called_with(self.config.directory,
                                        self.home,
                                        excludes=self.config.excludes,
                                        cherrypicks=self.config.cherrypicks)
     cleanup_symlinks.assert_called_with(os.getenv('HOME'))
예제 #8
0
 def test_home_directory_not_allowed(self):
     """Tests that using the home directory as a base is not allowed."""
     self.defaults['directory'] = os.getenv('HOME')
     self.create_config_file()
     config = Config(testing.configuration_file())
     self.assertEquals(config.directory, Config.DEFAULTS['directory'])
예제 #9
0
 def create_config_file(self):
     if os.path.exists(testing.configuration_file()):
         self.filesystem.RemoveObject(testing.configuration_file())
     contents = json.dumps(self.defaults)
     self.filesystem.CreateFile(testing.configuration_file(),
                                contents=contents)
예제 #10
0
파일: test.py 프로젝트: sdejean/homekeeper
 def test_init(self):
     os.unlink(testing.configuration_file())
     self.assertFalse(os.path.exists(testing.configuration_file()))
     self.homekeeper = homekeeper.Homekeeper(testing.configuration_file())
     self.homekeeper.init()
     self.assertTrue(os.path.exists(testing.configuration_file()))