示例#1
0
    def test_version_mismatch(self):
        def mock_install_chrome(unused_version):
            return

        def mock_get_chrome_version():
            return '123.0.12.45'

        install_chrome_swap = self.swap_with_checks(install_chrome_for_ci,
                                                    'install_chrome',
                                                    mock_install_chrome,
                                                    expected_args=[
                                                        (DOWNLOAD_VERSION, ),
                                                    ])
        get_version_swap = self.swap_with_checks(install_chrome_for_ci,
                                                 'get_chrome_version',
                                                 mock_get_chrome_version,
                                                 expected_args=[tuple()])

        with install_chrome_swap, get_version_swap:
            with self.assertRaisesRegexp(
                    RuntimeError,
                ('Chrome version {} should have been installed. '
                 'Version 123.0.12.45 was found instead.'
                 ).format(DOWNLOAD_VERSION)):
                install_chrome_for_ci.main()
示例#2
0
    def test_success(self):
        def mock_install_chrome(unused_version):
            return

        def mock_get_chrome_version():
            return INSTALLED_VERSION

        def mock_print(unused_string):
            return

        install_chrome_swap = self.swap_with_checks(install_chrome_for_ci,
                                                    'install_chrome',
                                                    mock_install_chrome,
                                                    expected_args=[
                                                        (DOWNLOAD_VERSION, ),
                                                    ])
        get_version_swap = self.swap_with_checks(install_chrome_for_ci,
                                                 'get_chrome_version',
                                                 mock_get_chrome_version,
                                                 expected_args=[tuple()])
        print_swap = self.swap_with_checks(
            python_utils,
            'PRINT',
            mock_print,
            expected_args=[
                ('Chrome version {} installed.'.format(INSTALLED_VERSION), )
            ])

        with install_chrome_swap, get_version_swap, print_swap:
            install_chrome_for_ci.main()