1#!/usr/bin/env python3 2# 3# Copyright 2019, The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17"""Unittests for aidegen_main.""" 18 19from __future__ import print_function 20 21import os 22import sys 23import unittest 24from unittest import mock 25 26from aidegen import aidegen_main 27from aidegen import constant 28from aidegen import unittest_constants 29from aidegen.lib import aidegen_metrics 30from aidegen.lib import common_util 31from aidegen.lib import eclipse_project_file_gen 32from aidegen.lib import errors 33from aidegen.lib import ide_util 34from aidegen.lib import module_info 35from aidegen.lib import native_util 36from aidegen.lib import native_module_info 37from aidegen.lib import native_project_info 38from aidegen.lib import project_config 39from aidegen.lib import project_file_gen 40from aidegen.lib import project_info 41from aidegen.vscode import vscode_workspace_file_gen 42from aidegen.vscode import vscode_native_project_file_gen 43 44 45# pylint: disable=protected-access 46# pylint: disable=invalid-name 47# pylint: disable=too-many-arguments 48# pylint: disable=too-many-function-args 49# pylint: disable=too-many-statements 50class AidegenMainUnittests(unittest.TestCase): 51 """Unit tests for aidegen_main.py""" 52 53 def _init_project_config(self, args): 54 """Initialize project configurations.""" 55 self.assertIsNotNone(args) 56 config = project_config.ProjectConfig(args) 57 config.init_environment() 58 59 def test_parse_args(self): 60 """Test _parse_args with different conditions.""" 61 args = aidegen_main._parse_args([]) 62 self.assertEqual(args.targets, ['']) 63 self.assertEqual(args.ide[0], 'u') 64 target = 'tradefed' 65 args = aidegen_main._parse_args([target]) 66 self.assertEqual(args.targets, [target]) 67 depth = '2' 68 args = aidegen_main._parse_args(['-d', depth]) 69 self.assertEqual(args.depth, int(depth)) 70 args = aidegen_main._parse_args(['-v']) 71 self.assertTrue(args.verbose) 72 args = aidegen_main._parse_args(['-v']) 73 self.assertTrue(args.verbose) 74 args = aidegen_main._parse_args(['-i', 's']) 75 self.assertEqual(args.ide[0], 's') 76 args = aidegen_main._parse_args(['-i', 'e']) 77 self.assertEqual(args.ide[0], 'e') 78 args = aidegen_main._parse_args(['-p', unittest_constants.TEST_MODULE]) 79 self.assertEqual(args.ide_installed_path, 80 unittest_constants.TEST_MODULE) 81 args = aidegen_main._parse_args(['-n']) 82 self.assertTrue(args.no_launch) 83 args = aidegen_main._parse_args(['-r']) 84 self.assertTrue(args.config_reset) 85 args = aidegen_main._parse_args(['-s']) 86 self.assertTrue(args.skip_build) 87 self.assertEqual(args.exclude_paths, None) 88 excludes = 'path/to/a', 'path/to/b' 89 args = aidegen_main._parse_args(['-e', excludes]) 90 self.assertEqual(args.exclude_paths, [excludes]) 91 92 @mock.patch.object(project_config.ProjectConfig, 'init_environment') 93 @mock.patch.object(project_config, 'ProjectConfig') 94 @mock.patch.object(project_file_gen.ProjectFileGenerator, 95 'generate_ide_project_files') 96 @mock.patch.object(eclipse_project_file_gen.EclipseConf, 97 'generate_ide_project_files') 98 def test_generate_project_files(self, mock_eclipse, mock_ide, mock_config, 99 mock_init): 100 """Test _generate_project_files with different conditions.""" 101 projects = ['module_a', 'module_v'] 102 args = aidegen_main._parse_args([projects, '-i', 'e']) 103 mock_init.return_value = None 104 self._init_project_config(args) 105 mock_config.ide_name = constant.IDE_ECLIPSE 106 aidegen_main._generate_project_files(projects) 107 self.assertTrue(mock_eclipse.called_with(projects)) 108 mock_config.ide_name = constant.IDE_ANDROID_STUDIO 109 aidegen_main._generate_project_files(projects) 110 self.assertTrue(mock_ide.called_with(projects)) 111 mock_config.ide_name = constant.IDE_INTELLIJ 112 aidegen_main._generate_project_files(projects) 113 self.assertTrue(mock_ide.called_with(projects)) 114 115 @mock.patch.object(aidegen_main, 'main_with_message') 116 @mock.patch.object(aidegen_main, 'main_without_message') 117 def test_main(self, mock_without, mock_with): 118 """Test main with conditions.""" 119 aidegen_main.main(['-s']) 120 self.assertEqual(mock_without.call_count, 1) 121 aidegen_main.main(['']) 122 self.assertEqual(mock_with.call_count, 1) 123 124 @mock.patch.object(aidegen_metrics, 'starts_asuite_metrics') 125 @mock.patch.object(project_config, 'is_whole_android_tree') 126 @mock.patch.object(aidegen_metrics, 'ends_asuite_metrics') 127 @mock.patch.object(aidegen_main, 'main_with_message') 128 def test_main_with_normal(self, mock_main, mock_ends_metrics, 129 mock_is_whole_tree, mock_starts_metrics): 130 """Test main with normal conditions.""" 131 aidegen_main.main(['-h']) 132 self.assertFalse(mock_main.called) 133 mock_is_whole_tree.return_value = True 134 aidegen_main.main(['']) 135 mock_starts_metrics.assert_called_with([constant.ANDROID_TREE]) 136 self.assertFalse(mock_ends_metrics.called) 137 aidegen_main.main(['-n']) 138 mock_ends_metrics.assert_called_with(constant.EXIT_CODE_NORMAL) 139 140 @mock.patch.object(aidegen_metrics, 'ends_asuite_metrics') 141 @mock.patch.object(aidegen_main, 'main_with_message') 142 def test_main_with_build_fail_errors(self, mock_main, mock_ends_metrics): 143 """Test main with raising build failure error conditions.""" 144 mock_main.side_effect = errors.BuildFailureError 145 with self.assertRaises(errors.BuildFailureError): 146 aidegen_main.main(['']) 147 _, exc_value, exc_traceback = sys.exc_info() 148 msg = str(exc_value) 149 mock_ends_metrics.assert_called_with( 150 constant.EXIT_CODE_AIDEGEN_EXCEPTION, exc_traceback, msg) 151 152 @mock.patch.object(aidegen_metrics, 'ends_asuite_metrics') 153 @mock.patch.object(aidegen_main, 'main_with_message') 154 def test_main_with_io_errors(self, mock_main, mock_ends_metrics): 155 """Test main with raising IO error conditions.""" 156 mock_main.side_effect = IOError 157 with self.assertRaises(IOError): 158 aidegen_main.main(['']) 159 _, exc_value, exc_traceback = sys.exc_info() 160 msg = str(exc_value) 161 mock_ends_metrics.assert_called_with(constant.EXIT_CODE_EXCEPTION, 162 exc_traceback, msg) 163 164 @mock.patch.object(aidegen_main, '_launch_ide') 165 @mock.patch.object(ide_util, 'get_ide_util_instance') 166 def test_launch_native_projects_without_ide_object( 167 self, mock_get_ide, mock_launch_ide): 168 """Test _launch_native_projects function without ide object.""" 169 target = 'libui' 170 args = aidegen_main._parse_args([target, '-i', 'e']) 171 aidegen_main._launch_native_projects(None, args, []) 172 self.assertFalse(mock_get_ide.called) 173 self.assertFalse(mock_launch_ide.called) 174 175 @mock.patch.object(aidegen_main, '_launch_ide') 176 @mock.patch.object(ide_util, 'get_ide_util_instance') 177 def test_launch_native_projects_with_ide_object( 178 self, mock_get_ide, mock_launch_ide): 179 """Test _launch_native_projects function without ide object.""" 180 target = 'libui' 181 args = aidegen_main._parse_args([target, '-i', 'e']) 182 ide_util_obj = 'some_obj' 183 mock_get_ide.return_value = None 184 aidegen_main._launch_native_projects(ide_util_obj, args, []) 185 self.assertTrue(mock_get_ide.called_with('c')) 186 self.assertFalse(mock_launch_ide.called) 187 mock_get_ide.reset_mock() 188 mock_launch_ide.reset_mock() 189 args.ide = ['j'] 190 aidegen_main._launch_native_projects(ide_util_obj, args, []) 191 self.assertTrue(mock_get_ide.called_with('c')) 192 self.assertFalse(mock_launch_ide.called) 193 mock_get_ide.reset_mock() 194 mock_launch_ide.reset_mock() 195 mock_get_ide.return_value = 'some_native_obj' 196 aidegen_main._launch_native_projects(ide_util_obj, args, []) 197 self.assertTrue(mock_get_ide.called_with('c')) 198 self.assertTrue(mock_launch_ide.called) 199 mock_get_ide.reset_mock() 200 mock_launch_ide.reset_mock() 201 args.ide = ['e'] 202 aidegen_main._launch_native_projects(ide_util_obj, args, []) 203 self.assertTrue(mock_get_ide.called_with('c')) 204 self.assertTrue(mock_launch_ide.called) 205 mock_get_ide.reset_mock() 206 mock_launch_ide.reset_mock() 207 args.ide = ['s'] 208 aidegen_main._launch_native_projects(ide_util_obj, args, []) 209 self.assertFalse(mock_get_ide.called) 210 self.assertTrue(mock_launch_ide.called) 211 212 @mock.patch('builtins.print') 213 def test_launch_ide(self, mock_print): 214 """Test _launch_ide function with config parameter.""" 215 mock_ide_util = mock.MagicMock() 216 mock_ide_util.launch_ide.return_value = None 217 mock_ide_util.config_ide.return_value = None 218 launch_path = '/test/launch/ide/method' 219 aidegen_main._launch_ide(mock_ide_util, launch_path) 220 self.assertTrue(mock_ide_util.config_ide.called) 221 self.assertTrue(mock_ide_util.launch_ide.called) 222 mock_print.return_value = None 223 224 @mock.patch.object(project_config.ProjectConfig, 'init_environment') 225 @mock.patch('builtins.print') 226 @mock.patch.object(aidegen_main, '_launch_vscode') 227 @mock.patch.object(aidegen_main, '_launch_native_projects') 228 @mock.patch.object(native_util, 'generate_clion_projects') 229 @mock.patch.object(native_project_info.NativeProjectInfo, 230 'generate_projects') 231 @mock.patch.object(aidegen_main, '_create_and_launch_java_projects') 232 def test_launch_ide_by_module_contents(self, mock_j, mock_c_prj, mock_genc, 233 mock_c, mock_vs, mock_print, 234 mock_init): 235 """Test _launch_ide_by_module_contents with different conditions.""" 236 args = aidegen_main._parse_args(['', '-i', 's']) 237 mock_init.return_value = None 238 self._init_project_config(args) 239 ide_obj = 'ide_obj' 240 test_all = False 241 lang = constant.JAVA 242 aidegen_main._launch_ide_by_module_contents(args, ide_obj, lang, None, 243 None, None, test_all) 244 self.assertFalse(mock_vs.called) 245 self.assertTrue(mock_print.called) 246 self.assertFalse(mock_j.called) 247 self.assertFalse(mock_c_prj.called) 248 self.assertFalse(mock_genc.called) 249 self.assertFalse(mock_c.called) 250 251 test_all = True 252 aidegen_main._launch_ide_by_module_contents(args, ide_obj, lang, None, 253 None, None, test_all) 254 self.assertTrue(mock_vs.called) 255 self.assertFalse(mock_j.called) 256 self.assertFalse(mock_genc.called) 257 self.assertFalse(mock_c.called) 258 mock_vs.reset_mock() 259 260 test_j = ['a', 'b', 'c'] 261 test_c = ['1', '2', '3'] 262 aidegen_main._launch_ide_by_module_contents(args, ide_obj, lang, test_j, 263 test_c) 264 self.assertFalse(mock_vs.called) 265 self.assertTrue(mock_j.called) 266 self.assertFalse(mock_genc.called) 267 self.assertFalse(mock_c.called) 268 269 mock_vs.reset_mock() 270 mock_c.reset_mock() 271 mock_genc.reset_mock() 272 mock_j.reset_mock() 273 args = aidegen_main._parse_args(['', '-l', 'c']) 274 mock_init.return_value = None 275 self._init_project_config(args) 276 lang = constant.C_CPP 277 aidegen_main._launch_ide_by_module_contents(args, ide_obj, lang, test_j, 278 test_c) 279 self.assertTrue(mock_c_prj.called) 280 self.assertFalse(mock_vs.called) 281 self.assertTrue(mock_genc.called) 282 self.assertTrue(mock_c.called) 283 self.assertFalse(mock_j.called) 284 285 mock_vs.reset_mock() 286 mock_c.reset_mock() 287 mock_genc.reset_mock() 288 mock_j.reset_mock() 289 test_none = None 290 aidegen_main._launch_ide_by_module_contents(args, ide_obj, lang, 291 test_none, test_c) 292 self.assertFalse(mock_vs.called) 293 self.assertTrue(mock_genc.called) 294 self.assertTrue(mock_c.called) 295 self.assertFalse(mock_j.called) 296 297 mock_vs.reset_mock() 298 mock_c.reset_mock() 299 mock_genc.reset_mock() 300 mock_j.reset_mock() 301 lang = constant.JAVA 302 aidegen_main._launch_ide_by_module_contents(args, ide_obj, lang, test_j, 303 test_none) 304 self.assertFalse(mock_vs.called) 305 self.assertTrue(mock_j.called) 306 self.assertFalse(mock_c.called) 307 self.assertFalse(mock_genc.called) 308 309 args = aidegen_main._parse_args(['frameworks/base', '-i', 'c']) 310 mock_vs.reset_mock() 311 mock_c.reset_mock() 312 mock_genc.reset_mock() 313 mock_c_prj.reset_mock() 314 mock_j.reset_mock() 315 lang = constant.C_CPP 316 aidegen_main._launch_ide_by_module_contents(args, ide_obj, lang, test_j, 317 test_c) 318 self.assertFalse(mock_vs.called) 319 self.assertFalse(mock_j.called) 320 self.assertTrue(mock_c.called) 321 self.assertTrue(mock_c_prj.called) 322 self.assertTrue(mock_genc.called) 323 324 args = aidegen_main._parse_args(['frameworks/base']) 325 mock_vs.reset_mock() 326 mock_c.reset_mock() 327 mock_genc.reset_mock() 328 mock_c_prj.reset_mock() 329 mock_j.reset_mock() 330 os.environ[constant.AIDEGEN_TEST_MODE] = 'true' 331 lang = constant.JAVA 332 aidegen_main._launch_ide_by_module_contents(args, None, lang, test_j, 333 test_c) 334 self.assertFalse(mock_vs.called) 335 self.assertTrue(mock_j.called) 336 self.assertFalse(mock_c.called) 337 self.assertFalse(mock_c_prj.called) 338 self.assertFalse(mock_genc.called) 339 del os.environ[constant.AIDEGEN_TEST_MODE] 340 341 @mock.patch.object(aidegen_main, '_launch_ide') 342 @mock.patch.object(aidegen_main, '_generate_project_files') 343 @mock.patch.object(project_info.ProjectInfo, 'multi_projects_locate_source') 344 @mock.patch.object(project_info.ProjectInfo, 'generate_projects') 345 def test_create_and_launch_java_projects(self, mock_prj, mock_compile, 346 mock_gen_file, mock_launch): 347 """Test _create_and_launch_java_projects.""" 348 ide_obj = 'test_ide' 349 target = ['a', 'b'] 350 mock_prj_list = mock.MagicMock() 351 mock_prj_list.project_absolute_path = 'test_path' 352 prj = [mock_prj_list] 353 mock_prj.return_value = prj 354 aidegen_main._create_and_launch_java_projects(ide_obj, target) 355 self.assertTrue(mock_prj.called_with(target)) 356 self.assertTrue(mock_compile.called_with(prj)) 357 self.assertTrue(mock_gen_file.called_with(prj)) 358 self.assertTrue(mock_launch.called_with(ide_obj)) 359 mock_launch.reset_mock() 360 361 aidegen_main._create_and_launch_java_projects(None, target) 362 self.assertFalse(mock_launch.called) 363 364 @mock.patch.object(aidegen_main, '_launch_ide') 365 @mock.patch.object(vscode_workspace_file_gen, 366 'generate_code_workspace_file') 367 @mock.patch.object(common_util, 'get_related_paths') 368 def test_launch_vscode_without_ide_object( 369 self, mock_get_rel, mock_gen_code, mock_launch_ide): 370 """Test _launch_vscode function without ide object.""" 371 mock_get_rel.return_value = 'rel', 'abs' 372 aidegen_main._launch_vscode(None, mock.Mock(), ['Settings'], [], []) 373 self.assertTrue(mock_get_rel.called) 374 self.assertTrue(mock_gen_code.called) 375 self.assertFalse(mock_launch_ide.called) 376 377 @mock.patch.object(aidegen_main, '_launch_ide') 378 @mock.patch.object(vscode_workspace_file_gen, 379 'generate_code_workspace_file') 380 @mock.patch.object(common_util, 'get_related_paths') 381 def test_launch_vscode_with_ide_object( 382 self, mock_get_rel, mock_gen_code, mock_get_ide): 383 """Test _launch_vscode function with ide object.""" 384 mock_get_rel.return_value = 'rel', 'abs' 385 aidegen_main._launch_vscode( 386 mock.Mock(), mock.Mock(), ['Settings'], [], []) 387 self.assertTrue(mock_get_rel.called) 388 self.assertTrue(mock_gen_code.called) 389 self.assertTrue(mock_get_ide.called) 390 391 @mock.patch.object(aidegen_main, '_launch_vscode') 392 @mock.patch.object(aidegen_main, '_launch_ide') 393 @mock.patch.object(vscode_workspace_file_gen, 394 'generate_code_workspace_file') 395 @mock.patch.object(common_util, 'get_related_paths') 396 def test_launch_vscode_with_both_languages( 397 self, mock_get_rel, mock_gen_code, mock_get_ide, mock_vscode): 398 """Test _launch_vscode function without ide object.""" 399 mock_get_rel.return_value = 'rel', 'abs' 400 aidegen_main._launch_vscode(None, mock.Mock(), ['Settings'], [], True) 401 self.assertFalse(mock_get_rel.called) 402 self.assertFalse(mock_gen_code.called) 403 self.assertFalse(mock_get_ide.called) 404 self.assertTrue(mock_vscode.called) 405 406 @mock.patch('builtins.print') 407 @mock.patch.object(aidegen_main, '_launch_ide') 408 @mock.patch.object(vscode_workspace_file_gen, 409 'generate_code_workspace_file') 410 @mock.patch.object(common_util, 'get_android_root_dir') 411 @mock.patch.object(aidegen_main, '_get_rust_project_paths') 412 @mock.patch.object(aidegen_main, '_get_cc_project_paths') 413 @mock.patch.object(aidegen_main, '_get_java_project_paths') 414 def test_launch_vscode_with_logic(self, mock_get_java, mock_get_cc, 415 mock_get_rust, mock_get_root, mock_gen, 416 mock_launch, mock_print): 417 """Test _launch_vscode with the logic tests.""" 418 aidegen_main._launch_vscode(None, mock.Mock(), [], [], []) 419 self.assertFalse(mock_get_java.called) 420 self.assertFalse(mock_get_cc.called) 421 self.assertFalse(mock_get_rust.called) 422 self.assertFalse(mock_get_root.called) 423 self.assertFalse(mock_gen.called) 424 self.assertFalse(mock_launch.called) 425 self.assertTrue(mock_print.called) 426 427 mock_get_java.mock_reset() 428 mock_get_cc.mock_reset() 429 mock_get_rust.mock_reset() 430 mock_get_root.mock_reset() 431 mock_gen.mock_reset() 432 mock_launch.mock_reset() 433 mock_print.mock_reset() 434 435 aidegen_main._launch_vscode( 436 mock.Mock(), mock.Mock(), ['Java'], ['CC'], ['Rust']) 437 self.assertTrue(mock_get_java.called) 438 self.assertTrue(mock_get_cc.called) 439 self.assertTrue(mock_get_rust.called) 440 self.assertTrue(mock_get_root.called) 441 self.assertTrue(mock_gen.called) 442 self.assertTrue(mock_launch.called) 443 444 @mock.patch.object(common_util, 'get_related_paths') 445 def test_get_java_project_paths(self, mock_get_related): 446 """Test _get_java_project_paths with conditions.""" 447 abs_path = 'a/b/c/d' 448 rel_path = 'c/d' 449 mock_get_related.return_value = rel_path, abs_path 450 self.assertEqual( 451 [abs_path], aidegen_main._get_java_project_paths( 452 ['Java'], mock.Mock())) 453 mock_get_related.return_value = None, None 454 self.assertEqual( 455 [], aidegen_main._get_java_project_paths(['Java'], mock.Mock())) 456 457 @mock.patch.object( 458 vscode_native_project_file_gen.VSCodeNativeProjectFileGenerator, 459 'generate_c_cpp_properties_json_file') 460 @mock.patch.object( 461 vscode_native_project_file_gen, 'VSCodeNativeProjectFileGenerator') 462 @mock.patch.object(common_util, 'get_related_paths') 463 @mock.patch.object( 464 native_project_info.NativeProjectInfo, 'generate_projects') 465 @mock.patch.object(native_module_info, 'NativeModuleInfo') 466 def test_get_cc_project_paths(self, mock_mod_info, mock_gen, mock_get_rel, 467 mock_gen_vs, mock_gen_vs_file): 468 """Test _get_cc_project_paths with conditions.""" 469 mock_get_rel.return_value = None, None 470 self.assertEqual([], aidegen_main._get_cc_project_paths(['Java'])) 471 self.assertTrue(mock_mod_info.called) 472 self.assertTrue(mock_gen.called) 473 self.assertTrue(mock_get_rel.called) 474 self.assertFalse(mock_gen_vs.called) 475 self.assertFalse(mock_gen_vs_file.called) 476 477 mock_mod_info.mock_reset() 478 mock_gen.mock_reset() 479 mock_get_rel.mock_reset() 480 mock_gen_vs.mock_reset() 481 mock_gen_vs_file.mock_reset() 482 483 abs_path = 'a/b/c/d' 484 rel_path = 'c/d' 485 mock_get_rel.return_value = rel_path, abs_path 486 self.assertEqual([abs_path], aidegen_main._get_cc_project_paths(['CC'])) 487 self.assertTrue(mock_mod_info.called) 488 self.assertTrue(mock_gen.called) 489 self.assertTrue(mock_get_rel.called) 490 self.assertTrue(mock_gen_vs.called) 491 492 def test_get_rust_project_paths(self): 493 """Test _get_rust_project_paths with conditions.""" 494 abs_path = 'a/b/c/d' 495 rel_path = 'c/d' 496 root = 'a/b' 497 self.assertEqual( 498 [abs_path], aidegen_main._get_rust_project_paths([abs_path], root)) 499 self.assertEqual( 500 [abs_path], aidegen_main._get_rust_project_paths([rel_path], root)) 501 502 @mock.patch.object(aidegen_main, '_launch_ide_by_module_contents') 503 @mock.patch.object(native_util, 'get_java_cc_and_rust_projects') 504 @mock.patch.object(native_module_info, 'NativeModuleInfo') 505 @mock.patch.object(module_info, 'AidegenModuleInfo') 506 @mock.patch.object(ide_util, 'get_ide_util_instance') 507 @mock.patch.object(project_config, 'ProjectConfig') 508 def test_aidegen_main(self, mock_config, mock_get_ide, mock_mod_info, 509 mock_native, mock_get_project, mock_launch_ide): 510 """Test aidegen_main function with conditions.""" 511 target = 'Settings' 512 args = aidegen_main._parse_args([target, '-i', 'v']) 513 config = mock.Mock() 514 config.targets = [target] 515 config.ide_name = constant.IDE_VSCODE 516 mock_config.return_value = config 517 ide = mock.Mock() 518 mock_get_ide.return_value = ide 519 mock_get_project.return_value = config.targets, [], [] 520 aidegen_main.aidegen_main(args) 521 self.assertTrue(mock_config.called) 522 self.assertTrue(mock_get_ide.called) 523 self.assertTrue(mock_mod_info.called) 524 self.assertTrue(mock_native.called) 525 self.assertTrue(mock_get_project.called) 526 mock_launch_ide.assert_called_with( 527 args, ide, constant.JAVA, config.targets, [], [], True) 528 529 mock_config.mock_reset() 530 mock_get_ide.mock_reset() 531 mock_mod_info.mock_reset() 532 mock_native.mock_reset() 533 mock_get_project.mock_reset() 534 mock_launch_ide.mock_reset() 535 536 args = aidegen_main._parse_args([target]) 537 config.ide_name = constant.IDE_INTELLIJ 538 aidegen_main.aidegen_main(args) 539 self.assertTrue(mock_config.called) 540 self.assertTrue(mock_get_ide.called) 541 self.assertTrue(mock_mod_info.called) 542 self.assertTrue(mock_native.called) 543 self.assertTrue(mock_get_project.called) 544 mock_launch_ide.assert_called_with( 545 args, ide, constant.JAVA, config.targets, [], [], False) 546 547 548if __name__ == '__main__': 549 unittest.main() 550