예제 #1
0
    def test_fail(self):
        def mock_run_cmd(tokens):
            command = ' '.join(tokens)
            raise subprocess.CalledProcessError(1, command, '')

        run_cmd_swap = self.swap_with_checks(
            common, 'run_cmd', mock_run_cmd,
            expected_args=[
                (['sudo', 'apt-get', 'update'],),
            ])

        with run_cmd_swap:
            with self.assertRaisesRegexp(
                subprocess.CalledProcessError,
                'Command \'sudo apt-get update\' returned non-zero exit '
                'status 1'
            ):
                install_chrome_for_ci.install_chrome(DOWNLOAD_VERSION)
예제 #2
0
    def test_success(self):
        def mock_run_cmd(unused_tokens):
            return ''

        run_cmd_swap = self.swap_with_checks(
            common, 'run_cmd', mock_run_cmd,
            expected_args=[
                (['sudo', 'apt-get', 'update'],),
                (['sudo', 'apt-get', 'install', 'libappindicator3-1'],),
                (['curl', '-L', '-o', CHROME_DEB_FILE, URL],),
                ([
                    'sudo', 'sed', '-i',
                    's|HERE/chrome\\"|HERE/chrome\\" '
                    '--disable-setuid-sandbox|g',
                    '/opt/google/chrome/google-chrome'],),
                (['sudo', 'dpkg', '-i', CHROME_DEB_FILE],),
            ])

        with run_cmd_swap:
            install_chrome_for_ci.install_chrome(DOWNLOAD_VERSION)