def test_run_webpack_compilation_failed(self): def mock_isdir(unused_port): return False def mock_exit(unused_exit_code): return expected_commands = [ self.mock_node_bin_path, self.mock_webpack_bin_path, '--config', 'webpack.dev.config.ts' ] # The webpack compilation processes will be called five times. check_call_swap = self.swap_with_checks( subprocess, 'check_call', self.mock_check_call, expected_args=[(expected_commands, )] * 5) isdir_swap = self.swap(os.path, 'isdir', mock_isdir) exit_swap = self.swap_with_checks(sys, 'exit', mock_exit, expected_args=[(1, )]) with self.node_bin_path_swap, self.webpack_bin_path_swap: with check_call_swap, isdir_swap, exit_swap: run_e2e_tests.run_webpack_compilation()
def test_run_webpack_compilation_success(self): def mock_isdir(unused_dirname): mock_isdir.run_times += 1 if mock_isdir.run_times > 3: return True return False mock_isdir.run_times = 0 expected_commands = [ self.mock_node_bin_path, self.mock_webpack_bin_path, '--config', 'webpack.dev.config.ts' ] isdir_swap = self.swap_with_checks(os.path, 'isdir', mock_isdir) # The webpack compilation processes will be called 4 times as mock_isdir # will return true after 4 calls. check_call_swap = self.swap_with_checks( subprocess, 'check_call', self.mock_check_call, expected_args=[(expected_commands, )] * 4) with self.node_bin_path_swap, self.webpack_bin_path_swap, ( check_call_swap): with isdir_swap: run_e2e_tests.run_webpack_compilation()
def test_run_webpack_compilation_failed(self): old_os_path_isdir = os.path.isdir def mock_os_path_isdir(path): if path == 'webpack_bundles': return False return old_os_path_isdir(path) # The webpack compilation processes will be called five times. self.exit_stack.enter_context(self.swap_with_checks( servers, 'managed_webpack_compiler', mock_managed_process)) self.exit_stack.enter_context(self.swap_with_checks( os.path, 'isdir', mock_os_path_isdir)) self.exit_stack.enter_context(self.swap_with_checks( sys, 'exit', lambda _: None, expected_args=[(1,)])) run_e2e_tests.run_webpack_compilation()
def test_run_webpack_compilation_success(self): old_os_path_isdir = os.path.isdir def mock_os_path_isdir(path): if path == 'webpack_bundles': return True return old_os_path_isdir(path) # The webpack compilation processes will be called 4 times as mock_isdir # will return true after 4 calls. self.exit_stack.enter_context(self.swap_with_checks( servers, 'managed_webpack_compiler', mock_managed_process)) self.exit_stack.enter_context(self.swap_with_checks( sys, 'exit', lambda _: None, called=False)) self.exit_stack.enter_context(self.swap_with_checks( os.path, 'isdir', mock_os_path_isdir)) run_e2e_tests.run_webpack_compilation()