def setup_and_install_dependencies(skip_install): """Run the setup and installation scripts.""" if not skip_install: install_third_party_libs.main() setup.main(args=[]) setup_gae.main(args=[]) if os.getenv('TRAVIS'): install_chrome_on_travis.main(args=[])
def test_main(self): chrome_source_url = ( 'https://github.com/webnicer/chrome-downloads/raw/master/x64.deb' '/google-chrome-stable_77.0.3865.75-1_amd64.deb') def mock_isfile(unused_path): return False def mock_isdir(unused_path): return False def mock_makedirs(unused_path): return def mock_chdir(unused_path): return def mock_url_retrieve(unused_url, filename): # pylint: disable=unused-argument return def mock_check_call(unused_commands): return isdir_swap = self.swap_with_checks(os.path, 'isdir', mock_isdir, expected_args=[(os.path.join( 'HOME', '.cache/TravisChrome/'), )]) makedirs_swap = self.swap_with_checks(os, 'makedirs', mock_makedirs, expected_args=[(os.path.join( 'HOME', '.cache/TravisChrome/'), )]) isfile_swap = self.swap_with_checks( os.path, 'isfile', mock_isfile, expected_args=[(os.path.join( 'HOME', '.cache/TravisChrome/', 'google-chrome-stable_77.0.3865.75-1_amd64.deb'), )]) chdir_swap = self.swap_with_checks(os, 'chdir', mock_chdir, expected_args=[(os.path.join( 'HOME', '.cache/TravisChrome/'), ), (os.getcwd(), )]) url_retrieve_swap = self.swap_with_checks( python_utils, 'url_retrieve', mock_url_retrieve, expected_args=[(chrome_source_url, )], expected_kwargs=[{ 'filename': 'google-chrome-stable_77.0.3865.75-1_amd64.deb' }]) check_call_swap = self.swap_with_checks( subprocess, 'check_call', mock_check_call, expected_args=[([ 'sudo', 'dpkg', '-i', os.path.join('HOME', '.cache/TravisChrome/', 'google-chrome-stable_77.0.3865.75-1_amd64.deb') ], )]) environ_swap = self.swap(os, 'environ', { 'CHROME_SOURCE_URL': chrome_source_url, 'HOME': 'HOME' }) with isdir_swap, isfile_swap, makedirs_swap, chdir_swap: with url_retrieve_swap, check_call_swap, environ_swap: install_chrome_on_travis.main(args=[])