def test_already_created(self): """ Will raise an exception when it's already created the templates. """ create_auto_init_templates(self.user_home_directory) with self.assertRaises(GitHomeTemplatesExists): create_auto_init_templates(self.user_home_directory)
def test_raises_exception_if_no_templates(self): """ If no Git templates can be found raise an exception. """ with patch(self.git_templates) as gtsl: gtsl.return_value = None with self.assertRaises(GitTemplatesMissing): create_auto_init_templates(self.user_home_directory)
def test_raises_exception_other_os_error(self): """ Raise if some other kind of OSError is found. """ with patch('jig.gitutils.hooking.makedirs') as makedirs: makedirs.side_effect = OSError(99, 'Flooglehorn is blocked') with self.assertRaises(JigUserDirectoryError) as ec: create_auto_init_templates(self.user_home_directory) self.assertEqual( u'[Errno 99] Flooglehorn is blocked', unicode(ec.exception) )
def test_raises_exception_permission_denied(self): """ Raise if the .jig directory can't be created due to permissions. """ with patch('jig.gitutils.hooking.makedirs') as makedirs: makedirs.side_effect = OSError(13, 'Permission denied') with self.assertRaises(JigUserDirectoryError) as ec: create_auto_init_templates(self.user_home_directory) self.assertEqual( u'Cannot create {0}/.jig Jig user directory'.format( self.user_home_directory), unicode(ec.exception) )
def process(self, argv): with self.out() as out: templates_directory = create_auto_init_templates(expanduser('~')) set_templates_directory(templates_directory) out.append('Jig has been setup to run everytime you clone.')
def test_creates_the_templates_directory(self): """ The templates are copied from the Git shared directory. """ home_templates_directory = create_auto_init_templates( self.user_home_directory ) self.assertTrue(isdir(home_templates_directory))
def test_pre_commit_hook_is_executable(self): """ Once created it can be executed. """ templates_directory = create_auto_init_templates( self.user_home_directory ) self.assertTrue( access(join(templates_directory, 'hooks', 'pre-commit'), X_OK) )
def test_creates_pre_commit_hook(self): """ Creates the pre-commit hook for auto-initialization. """ templates_directory = create_auto_init_templates( self.user_home_directory ) self.assertTrue( isfile(join(templates_directory, 'hooks', 'pre-commit')) )
def test_continues_if_jig_user_directory_created(self): """ An existing ~/.jig directory doesn't cause failure. """ with patch('jig.gitutils.hooking.makedirs') as makedirs: makedirs.side_effect = OSError(17, 'Directory exists') self.assertEqual( '{0}/.jig/git/templates'.format(self.user_home_directory), create_auto_init_templates(self.user_home_directory) )
def setUp(self): super(TestSetTemplatesDirectory, self).setUp() self.templates_directory = create_auto_init_templates(mkdtemp()) self._clear_gitconfig()