Exemple #1
0
    def test_execute_git_remote_command_doesnt_auto_add_known_host_if_no_prompt(self):
        def expect_side_effect(*args, **kwargs):
            if args[0] == ['^User.*: ', '^Pass.*: ', '.*Are you sure you want to continue connecting.*']:
                raise pexpect.TIMEOUT('some_msg')
            return None

        self.mock_pexpect_child.expect.side_effect = expect_side_effect
        git = Git("some_remote_value", 'origin', 'ref/to/some/branch')
        git._execute_git_remote_command('some_command')
        self.assertEquals(self.mock_pexpect_child.sendline.call_count, 0)
Exemple #2
0
    def test_execute_git_remote_command_auto_adds_known_host_if_prompted(self):
        prompted = False

        def expect_side_effect(*args, **kwargs):
            nonlocal prompted

            if args[0] == ['^User.*: ', '^Pass.*: ', '.*Are you sure you want to continue connecting.*'] \
                    and not prompted:
                prompted = True
                return 2
            elif args[0] == pexpect.EOF:
                return 0

            raise pexpect.TIMEOUT('some_msg')

        self.mock_pexpect_child.expect.side_effect = expect_side_effect
        Configuration['git_strict_host_key_checking'] = False
        git = Git("some_remote_value", 'origin', 'ref/to/some/branch')
        git._execute_git_remote_command('some_command')
        self.mock_pexpect_child.sendline.assert_called_with("yes")
Exemple #3
0
    def test_setup_build_when_existing_repo_is_shallow_deletes_repo(self):
        url = 'url'
        repo_path = 'repo_path'
        git = Git(url)
        git._execute_and_raise_on_failure = Mock()
        git._repo_directory = repo_path
        git.execute_command_in_project = Mock(side_effect=[('', 0), ('', 0)])
        self.patch('os.path.exists').return_value = True
        self.patch('os.path.isfile').return_value = True
        mock_fs = self.patch('app.project_type.git.fs')
        mock_rmtree = self.patch('shutil.rmtree')
        git._execute_git_remote_command = Mock()
        mock_fs.create_dir.call_count = 0  # only measure calls made in _setup_build
        mock_rmtree.call_count = 0

        git._setup_build()

        self.assertEqual(mock_fs.create_dir.call_count, 1)
        self.assertEqual(mock_rmtree.call_count, 1)