Esempio n. 1
0
 def test_git_command_exits(self):
     # Given
     unknown_command = 'grrrr'
     expected_exit_code = 1
     # When
     with pytest.raises(SystemExit) as wrapped_exit:
         git_command(unknown_command, CONFIG_REPOSITORIES, ())
     # Then
     self.assertEqual(expected_exit_code, wrapped_exit.value.code)
Esempio n. 2
0
 def test_clone_clones_all(self, mock_run, mock_get_repository_path):
     # Given
     mock_get_repository_path.side_effect = lambda r: r
     args = ('--scary', '--bork')
     expected_calls = [
         self._get_clone_call(REPOSITORY_NAMES[0], args),
         self._get_clone_call(REPOSITORY_NAMES[1], args),
         self._get_clone_call(REPOSITORY_NAMES[2], args)
     ]
     # When
     git_command('clone', CONFIG_REPOSITORIES, args)
     # Then
     mock_run.assert_has_calls(expected_calls)
     self.assertEqual(mock_run.call_count, len(REPOSITORY_NAMES))
Esempio n. 3
0
 def test_git_command(self, mock_run, mock_get_repository_path):
     # Given
     mock_get_repository_path.side_effect = lambda r: r
     common_commands = [
         'add',
         'restore',
         'rm',
         'branch',
         'commit',
         'reset',
         'switch',
         'tag',
         'fetch',
         'pull',
         'push',
         'checkout',
     ]
     args = ('-a', '--woof')
     repository_name = REPOSITORY_NAMES[0]
     selected_repositories = dict(
         {repository_name: CONFIG_REPOSITORIES[repository_name]})
     expected_calls = [
         self._get_common_call(repository_name, common_commands[0], args),
         self._get_common_call(repository_name, common_commands[1], args),
         self._get_common_call(repository_name, common_commands[2], args),
         self._get_common_call(repository_name, common_commands[3], args),
         self._get_common_call(repository_name, common_commands[4], args),
         self._get_common_call(repository_name, common_commands[5], args),
         self._get_common_call(repository_name, common_commands[6], args),
         self._get_common_call(repository_name, common_commands[7], args),
         self._get_common_call(repository_name, common_commands[8], args),
         self._get_common_call(repository_name, common_commands[9], args),
         self._get_common_call(repository_name, common_commands[10], args),
         self._get_common_call(repository_name, common_commands[11], args),
         self._get_clone_call(repository_name, args)
     ]
     # When
     for command in common_commands:
         git_command(command, selected_repositories, args)
     git_command('clone', selected_repositories, args)
     # Then
     mock_run.assert_has_calls(expected_calls)
     self.assertEqual(mock_run.call_count, len(expected_calls))
Esempio n. 4
0
def reset(ctx, git_args):
    git_command('reset', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 5
0
def branch(ctx, git_args):
    git_command('branch', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 6
0
def commit(ctx, git_args):
    git_command('commit', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 7
0
def add(ctx, git_args):
    git_command('add', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 8
0
def rm(ctx, git_args):
    git_command('rm', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 9
0
def clone(ctx, git_args):
    git_command('clone', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 10
0
def checkout(ctx, git_args):
    git_command('checkout', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 11
0
def push(ctx, git_args):
    git_command('push', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 12
0
def tag(ctx, git_args):
    git_command('tag', ctx.obj[SELECTED_REPOSITORIES], git_args)
Esempio n. 13
0
def switch(ctx, git_args):
    git_command('switch', ctx.obj[SELECTED_REPOSITORIES], git_args)