def tearDown(self): # Logic executed only on test failure test_name = self._testMethodName artifacts_folder = os.path.join( OUTPUT_FOLDER, self.__class__.__name__ + "_" + test_name) outcome = "PASSED" if self.IsFailed(self._resultForDoCleanups) is True: outcome = "FAILED" # Ensure `artifacts_folder` exists and it is clean if File.exists(artifacts_folder): Folder.cleanup(artifacts_folder) else: Folder.create(artifacts_folder) # Collect artifacts on test failure self.__copy_images(artifacts_folder=artifacts_folder) self.__copy_project_folder(artifacts_folder=artifacts_folder) self.__save_host_screen(artifacts_folder=artifacts_folder, test_method_name=test_name) print "" print "Test Method: {0}".format(self._testMethodName) print "End Time: {0}".format(time.strftime("%X")) print "Outcome: {0}".format(outcome) print "_________________________________TEST END_______________________________________" print ""
def test_451_resources_update(self): target_app = os.path.join(TEST_RUN_HOME, BaseClass.app_name) source_app = os.path.join(TEST_RUN_HOME, 'data', 'apps', 'test-app-js-41') Folder.cleanup(target_app) Folder.copy(source_app, target_app) output = Tns.run_tns_command("resources update", attributes={"--path": self.app_name}) assert "Successfully updated your project's application resources '/Android' directory structure" in output assert "The previous version of your Android application resources has been renamed to '/Android-Pre-v4'" in output assert File.exists(self.app_name + "/app/App_Resources/Android-Pre-v4/app.gradle") assert File.exists(self.app_name + "/app/App_Resources/Android/app.gradle") assert File.exists( self.app_name + "/app/App_Resources/Android/src/main/AndroidManifest.xml") assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/assets") assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/java") assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/res/values") Tns.build_android(attributes={"--path": self.app_name})
def create_app(app_name, attributes={}, log_trace=False, assert_success=True, update_modules=True, force_clean=True, measureTime=False): if force_clean: if File.exists(app_name): Folder.cleanup(app_name) path = app_name attributes_to_string = "" for k, v in attributes.iteritems(): if "--path" in k: path = v attributes_to_string = "".join("{0} {1}".format(k, v)) attr = {} if not any(s in attributes_to_string for s in ("--ng", "--template", "--tsc", "--vue")): if BRANCH == "master": attr = {"--template": SUT_FOLDER + os.path.sep + "tns-template-hello-world.tgz"} else: attr = {"--template": "tns-template-hello-world"} attr.update(attributes) if app_name is None: output = Tns.run_tns_command("create ", attributes=attr, log_trace=log_trace, measureTime=measureTime) else: output = Tns.run_tns_command("create \"" + app_name + "\"", attributes=attr, log_trace=log_trace, measureTime=measureTime) if assert_success: TnsAsserts.created(app_name=app_name, output=output) if update_modules: Tns.update_modules(path) # Tns.ensure_app_resources(path) return output
def update_webpack(path): """ Update modules for {N} project :param path: Path to {N} project :return: Output of command that update nativescript-dev-webpack plugin. """ # Escape path with spaces if " " in path: path = "\"" + path + "\"" if USE_YARN == "True": Npm.uninstall(package="nativescript-dev-webpack", option="--dev", folder=path) output = Npm.install(package=WEBPACK_PACKAGE, option="--dev", folder=path) else: Npm.uninstall(package="nativescript-dev-webpack", option="--save-dev", folder=path) output = Npm.install(package=WEBPACK_PACKAGE, option="--save-dev", folder=path) if Npm.version() > 3: assert "ERR" not in output, "Something went wrong when webpack are installed." # Update webpack dependencies update_script = os.path.join(TEST_RUN_HOME, path, "node_modules", ".bin", "update-ns-webpack --deps --configs") run(update_script) if USE_YARN == "True": Folder.cleanup(folder=os.path.join(TEST_RUN_HOME, path, "node_modules")) Npm.yarn_install(folder=path) else: Npm.install(folder=path) return output
def test_390_LSApplicationQueriesSchemes_merged(self): # https: // github.com / NativeScript / nativescript - cli / issues / 3108 Folder.cleanup( os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'Info.plist')) info_c = os.path.join('data', 'issues', 'info-plist', 'app', 'Info.plist') info_p = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS') Folder.copy(info_c, info_p) Tns.plugin_add("nativescript-geolocation", attributes={"--path": self.app_name}) Folder.cleanup( os.path.join(self.app_name, 'node_modules', 'nativescript-geolocation', 'platforms', 'ios', 'Info.plist')) info_plugin_c = os.path.join('data', 'issues', 'info-plist', 'plugin', 'Info.plist') info_plugin_p = os.path.join(self.app_name, 'node_modules', 'nativescript-geolocation', 'platforms', 'ios') Folder.copy(info_plugin_c, info_plugin_p) Tns.build_ios(attributes={"--path": self.app_name}) output = File.read( os.path.join(self.app_name, 'platforms', 'ios', 'TestApp', 'TestApp-Info.plist')) assert 'itms' in output assert "itms-apps" in output assert "LSApplicationQueriesSchemes" in output
def test_280_tns_run_android_console_time(self): # Copy the app folder (app is modified in order to get some console logs on loaded) source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src') target = os.path.join(self.app_name, 'src') Folder.cleanup(target) Folder.copy(src=source, dst=target) # Replace app.component.ts to use console.time() and console.timeEnd() source = os.path.join('data', 'issues', 'ios-runtime-843', 'app.component.ts') target = os.path.join(self.app_name, 'src', 'app', 'app.component.ts') File.copy(src=source, dest=target) # `tns run android` and wait until app is deployed log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False, assert_success=False) # Verify the app is running strings = ['Successfully synced application', 'Application loaded!', 'Home page loaded!'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False) # Verify initial state of the app Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image='ng-hello-world-home-white', tolerance=5.0) # Verify console.time() works console_time = ['JS: startup:'] Tns.wait_for_log(log_file=log, string_list=console_time)
def tearDown(self): # Logic executed only on test failure test_name = self._testMethodName artifacts_folder = os.path.join(OUTPUT_FOLDER, self.__class__.__name__ + "_" + test_name) outcome = "PASSED" if self.IsFailed(self._resultForDoCleanups) is True: outcome = "FAILED" # Ensure `artifacts_folder` exists and it is clean if File.exists(artifacts_folder): Folder.cleanup(artifacts_folder) else: Folder.create(artifacts_folder) # Collect artifacts on test failure self.__copy_images(artifacts_folder=artifacts_folder) self.__copy_project_folder(artifacts_folder=artifacts_folder) self.__save_host_screen(artifacts_folder=artifacts_folder, test_method_name=test_name) print "" print "Test Method: {0}".format(self._testMethodName) print "End Time: {0}".format(time.strftime("%X")) print "Outcome: {0}".format(outcome) print "_________________________________TEST END_______________________________________" print ""
def test_200_tns_run_android_extending_class_inside_file_containing_dots(self): """Test for https://github.com/NativeScript/android-runtime/issues/761""" # Copy the app folder (app is modified in order to get some console logs on loaded) source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src') target = os.path.join(self.app_name, 'src') Folder.cleanup(target) Folder.copy(src=source, dst=target) source_html = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.html') target_html = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.html') File.copy(src=source_html, dest=target_html) source_ts = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.ts') target_ts = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.ts') File.copy(src=source_ts, dest=target_ts) source_xml = os.path.join('data', 'issues', 'android-runtime-761', 'AndroidManifest.xml') target_xml = os.path.join(self.app_name, 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') File.copy(src=source_xml, dest=target_xml) # Verify the app is running log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False, assert_success=False) strings = ['Project successfully built', 'Successfully installed on device with identifier', EMULATOR_ID, 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
def setUp(self): print "" print "_________________________________TEST START_______________________________________" print "Test Method: {0}".format(self._testMethodName) print "Start Time: {0}".format(time.strftime("%X")) print "" Folder.cleanup(os.path.join(TEST_RUN_HOME, 'out', 'images'))
def setUpClass(cls, class_name): print "" print "_________________________________CLASS START_______________________________________" print "Class Name: {0}".format(class_name) print "Start Time: {0}".format(time.strftime("%X")) print "" Tns.kill() Gradle.kill() Process.kill('node') Process.kill('adb') if CURRENT_OS == OSType.OSX: Process.kill('NativeScript Inspector') Process.kill('Safari') Process.kill('Xcode') if class_name is not None: logfile = os.path.join('out', class_name + '.txt') else: logfile = os.path.join(OUTPUT_FOLDER, cls.__name__ + ".txt") File.remove(logfile) sys.stdout = sys.stderr = Logger.Logger(logfile) Folder.cleanup(cls.app_name)
def setUp(self): print "" print "_________________________________TEST START_______________________________________" print "Test Method: {0}".format(self._testMethodName) print "Start Time: {0}".format(time.strftime("%X")) print "" Folder.cleanup(os.path.join(TEST_RUN_HOME, 'out', 'images'))
def test_401_prepare_project_with_many_dependencies(self): """ Test for https://github.com/NativeScript/nativescript-cli/issues/2561 """ Folder.cleanup(self.app_name) Tns.create_app_ng(app_name=self.app_name, template_version="4", update_modules=False) if USE_YARN == "True": Npm.install(package="lodash", folder=self.app_name) Npm.install(package="moment", folder=self.app_name) Npm.install(package="nativescript-cardview", folder=self.app_name) Npm.install(package="nativescript-sqlite", folder=self.app_name) Npm.install(package="nativescript-statusbar", folder=self.app_name) Npm.install(package="nativescript-websockets", folder=self.app_name) Npm.install(package="number-generator", folder=self.app_name) Npm.install(package="eslint", folder=self.app_name) Npm.install(package="eslint-plugin-compat", folder=self.app_name) else: Npm.install(package="lodash", option="--save", folder=self.app_name) Npm.install(package="moment", option="--save", folder=self.app_name) Npm.install(package="nativescript-cardview", option="--save", folder=self.app_name) Npm.install(package="nativescript-sqlite", option="--save", folder=self.app_name) Npm.install(package="nativescript-statusbar", option="--save", folder=self.app_name) Npm.install(package="nativescript-websockets", option="--save", folder=self.app_name) Npm.install(package="number-generator", option="--save", folder=self.app_name) Npm.install(package="eslint", option="--save", folder=self.app_name) Npm.install(package="eslint-plugin-compat", option="--save", folder=self.app_name) Tns.platform_add_android(version="4", attributes={"--path": self.app_name}) Tns.prepare_android(attributes={"--path": self.app_name}, log_trace=True)
def test_311_build_android_with_custom_compile_sdk_old(self): #https://github.com/NativeScript/nativescript-cli/issues/4052 # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE}) Tns.build_android(attributes={"--compileSdk": "27", "--path": self.app_name})
def setUpClass(cls, class_name): print "" print "_________________________________CLASS START_______________________________________" print "Class Name: {0}".format(class_name) print "Start Time: {0}".format(time.strftime("%X")) print "" Tns.kill() Gradle.kill() Process.kill('node') Process.kill('adb') if CURRENT_OS == OSType.OSX: Process.kill('NativeScript Inspector') Process.kill('Safari') Process.kill('Xcode') if class_name is not None: logfile = os.path.join('out', class_name + '.txt') else: logfile = os.path.join(OUTPUT_FOLDER, cls.__name__ + ".txt") File.remove(logfile) sys.stdout = sys.stderr = Logger.Logger(logfile) Folder.cleanup(cls.app_name)
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Process.kill('Safari') Process.kill('NativeScript Inspector') Emulator.stop() Simulator.stop() cls.SIMULATOR_ID = Simulator.ensure_available( simulator_name=SIMULATOR_NAME) Folder.cleanup(cls.INSPECTOR_GLOBAL_PATH) Tns.create_app(cls.app_name, attributes={ '--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz') }, update_modules=True) Tns.platform_add_ios(attributes={ '--path': cls.app_name, '--frameworkPath': IOS_PACKAGE }) if USE_YARN == "True": Npm.install(package=IOS_INSPECTOR_PACKAGE, option='--dev', folder=cls.app_name) else: Npm.install(package=IOS_INSPECTOR_PACKAGE, option='--save-dev', folder=cls.app_name) Tns.build_ios(attributes={"--path": cls.app_name})
def test_391_platform_list(self): """Platform list command should list installed platforms and if app is prepared for those platforms""" Folder.cleanup(self.app_name) Tns.create_app(self.app_name, update_modules=False) # `tns platform list` on brand new project output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.NONE, added=Platform.NONE) # `tns platform list` when iOS is added Tns.platform_add_ios(attributes={"--path": self.app_name, "--frameworkPath": IOS_PACKAGE}) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.NONE, added=Platform.IOS) # `tns platform list` when iOS is prepared Tns.prepare_ios(attributes={"--path": self.app_name}) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.IOS, added=Platform.IOS) # `tns platform list` when android is added (iOS already prepared) Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE}) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.IOS, added=Platform.BOTH) # `tns platform list` when android is prepared (iOS already prepared) Tns.prepare_android(attributes={"--path": self.app_name}) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.BOTH, added=Platform.BOTH) # Verify build both platforms is not allowed # Test for https://github.com/NativeScript/nativescript-cli/pull/3425 output = Tns.run_tns_command(command="build", attributes={"--path": self.app_name}) assert "The input is not valid sub-command for 'build' command" in output assert "<Platform> is the target mobile platform for which you want to build your project" in output
def tearDownClass(cls): Folder.cleanup("TestApp.app") File.remove("TestApp.ipa") Folder.cleanup(cls.app_name) Folder.cleanup(cls.app_name_no_platform) Folder.cleanup(cls.app_name_dash) Folder.cleanup(cls.app_name_space)
def setUp(self): BaseClass.setUp(self) # Ensure app is in initial state Folder.navigate_to(folder=TEST_RUN_HOME, relative_from_current_folder=False) Folder.cleanup(self.app_name) Folder.copy(TEST_RUN_HOME + "/data/TestApp", TEST_RUN_HOME + "/TestApp")
def setUp(self): BaseClass.setUp(self) Tns.kill() # Replace app folder between tests. app_folder = os.path.join(self.app_name, 'app') Folder.cleanup(app_folder) Folder.copy(src=self.TEMP_FOLDER, dst=app_folder)
def setUp(self): BaseClass.setUp(self) Tns.kill() # Replace app folder between tests. app_folder = os.path.join(self.app_name, 'app') Folder.cleanup(app_folder) Folder.copy(src=self.TEMP_FOLDER, dst=app_folder)
def test_310_prepare_should_flatten_scoped_dependencies(self): Folder.cleanup(self.app_name) Tns.create_app_ng(self.app_name) Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE}) Tns.prepare_android(attributes={"--path": self.app_name}) # Verify scoped dependencies are flattened (verify #1783 is fixed) ng_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_NPM_MODULES_PATH, '@angular', 'core') assert File.exists(ng_path), "Scoped dependencies are flattened, please see #1783!"
def test_210_tns_run_android_add_remove_files_and_folders(self): """ New files and folders should be synced properly. """ log = Tns.run_android(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False, assert_success=False) strings = ['Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) # Add new files new_file_name = 'main-page2.xml' source_file = os.path.join(self.app_name, 'app', 'main-page.xml') destination_file = os.path.join(self.app_name, 'app', new_file_name) File.copy(source_file, destination_file) strings = ['Successfully transferred main-page2.xml', 'Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new file is synced and available on device. error_message = 'Newly created file {0} not found on {1}'.format(new_file_name, self.DEVICE_ID) app_id = Tns.get_app_id(app_name=self.app_name) path = 'app/{0}'.format(new_file_name) assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message # Revert changes(rename file and delete file) File.copy(destination_file, source_file) File.remove(destination_file) strings = ['Successfully transferred main-page.xml', 'Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new file is synced and available on device. error_message = '{0} was deleted, but still available on {1}'.format(new_file_name, self.DEVICE_ID) assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message # Add folder new_folder_name = 'feature2' source_file = os.path.join(self.app_name, 'app', 'feature1') destination_file = os.path.join(self.app_name, 'app', new_folder_name) Folder.copy(source_file, destination_file) strings = ['Successfully transferred', 'Successfully transferred', 'feature1.js', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new folder is synced and available on device. error_message = 'Newly created folder {0} not found on {1}'.format(new_folder_name, self.DEVICE_ID) path = 'app/{0}'.format(new_folder_name) assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message path = 'app/{0}/{1}'.format(new_folder_name, 'feature1.js') assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message # Delete folder Folder.cleanup(destination_file) strings = ['Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new folder is deleted from device. error_message = 'Deleted folder {0} is still available on {1}'.format(new_folder_name, self.DEVICE_ID) assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message
def test_330_prepare_android_next(self): Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False) Tns.platform_add_android(attributes={"--path": self.app_name}, version="next") Folder.cleanup(os.path.join(self.app_name, "node_modules")) Folder.cleanup(os.path.join(self.app_name, "platforms")) android_version = Npm.get_version("tns-android@next") File.replace(file_path=os.path.join(self.app_name, "package.json"), str1=android_version, str2="next") output = Tns.prepare_android(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FIRST_TIME)
def test_313_build_android_with_invalid_compile_sdk(self): # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE}) output = Tns.build_android(attributes={"--compileSdk": "99", "--path": self.app_name}, assert_success=False) assert "You have specified '99' for compile sdk, but it is not installed on your system." in output
def test_450_resources_update_ios(self): target_app = os.path.join(TEST_RUN_HOME, BaseClass.app_name) source_app = os.path.join(TEST_RUN_HOME, 'data', 'apps', 'test-app-js-34') Folder.cleanup(target_app) Folder.copy(source_app, target_app) output = Tns.run_tns_command("resources update ios", attributes={"--path": self.app_name}) assert "The ios does not need to have its resources updated." in output
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Tns.create_app(cls.app_name) Tns.platform_add_android(attributes={ "--path": cls.app_name, "--frameworkPath": ANDROID_PACKAGE }) Folder.cleanup(TEST_RUN_HOME + "/data/TestApp") Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) Emulator.ensure_available() Folder.cleanup(cls.app_name) # Create default NG app (to get right dependencies from package.json) Tns.create_app_ng(cls.app_name) Tns.platform_add_android(attributes={'--path': cls.app_name, '--frameworkPath': ANDROID_PACKAGE})
def tearDown(self): # Verify application state at the end of the test is correct if File.exists(self.app_name): data = TnsAsserts.get_package_json(self.app_name) assert "tns-android" in data[ "nativescript"], "'tns-android' not found under `nativescript` in package.json" assert "tns-android" not in data[ "dependencies"], "'tns-android' found under `dependencies` in package.json" BaseClass.tearDown(self) Folder.cleanup(self.platforms_android + '/build/outputs') Folder.cleanup("with space")
def test_310_build_android_with_custom_compile_sdk_new(self): # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) Tns.build_android(attributes={ "--compileSdk": "28", "--path": self.app_name })
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Tns.create_app(cls.app_name) Tns.platform_add_ios(attributes={ "--path": cls.app_name, "--frameworkPath": IOS_PACKAGE }) Folder.cleanup("TestApp.app") File.remove("TestApp.ipa") Xcode.cleanup_cache()
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Simulator.stop() cls.SIMULATOR_ID = Simulator.ensure_available(simulator_name=SIMULATOR_NAME) Folder.cleanup(cls.app_name) Tns.create_app(cls.app_name, attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')}, update_modules=True) Tns.platform_add_ios(attributes={'--path': cls.app_name, '--frameworkPath': IOS_PACKAGE}) Folder.cleanup(TEST_RUN_HOME + "/data/TestApp") Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
def setUp(self): BaseClass.setUp(self) Simulator.stop() Folder.cleanup(self.app_name_dash) Folder.cleanup(self.app_name_space) Folder.cleanup(self.app_name_ios) Folder.cleanup(self.app_name_no_platform) Folder.cleanup(self.app_name_no_platform + '/platforms/ios/build') Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name}, assert_success=False)
def clone_repo(repo_url, local_folder, branch=None): """Clone GitHub repo to local folder :param repo_url: GitHub repo URL :param branch: Branch :param local_folder: Local folder """ Folder.cleanup(folder=local_folder) command = 'git clone ' + repo_url + ' ' + local_folder if branch is not None: command = command + ' -b ' + branch output = run(command, log_level=CommandLogLevel.COMMAND_ONLY) assert not ("fatal" in output), "Failed to clone {0}".format(repo_url)
def test_311_build_android_with_custom_compile_sdk_old(self): #https://github.com/NativeScript/nativescript-cli/issues/4052 # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) Tns.build_android(attributes={ "--compileSdk": "27", "--path": self.app_name })
def test_391_platform_list(self): """Platform list command should list installed platforms and if app is prepared for those platforms""" Folder.cleanup(self.app_name) Tns.create_app(self.app_name, update_modules=False) # `tns platform list` on brand new project output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.NONE, added=Platform.NONE) # `tns platform list` when iOS is added Tns.platform_add_ios(attributes={ "--path": self.app_name, "--frameworkPath": IOS_PACKAGE }) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.NONE, added=Platform.IOS) # `tns platform list` when iOS is prepared Tns.prepare_ios(attributes={"--path": self.app_name}) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.IOS, added=Platform.IOS) # `tns platform list` when android is added (iOS already prepared) Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.IOS, added=Platform.BOTH) # `tns platform list` when android is prepared (iOS already prepared) Tns.prepare_android(attributes={"--path": self.app_name}) output = Tns.platform_list(attributes={"--path": self.app_name}) TnsAsserts.platform_list_status(output=output, prepared=Platform.BOTH, added=Platform.BOTH) # Verify build both platforms is not allowed # Test for https://github.com/NativeScript/nativescript-cli/pull/3425 output = Tns.run_tns_command(command="build", attributes={"--path": self.app_name}) assert "The input is not valid sub-command for 'build' command" in output assert "<Platform> is the target mobile platform for which you want to build your project" in output
def plugin_create(name, attributes={}, log_trace=False, assert_success=True, tns_path=None, force_clean=True): # Detect folder where plugin should be created path = attributes.get("--path") # noinspection PyUnusedLocal folder = path if path is None: path = name folder = name else: folder = path + os.sep + name # Clean target location if force_clean: Folder.cleanup(folder=path) # Execute plugin create command output = Tns.run_tns_command( "plugin create --includeTypeScriptDemo=y " + name, attributes=attributes, log_trace=log_trace, tns_path=tns_path) if assert_success: # Verify command output assert "Will now rename some files" in output, "Post clone script not executed." assert "Screenshots removed" in output, "Post clone script not executed." assert "Solution for {0}".format( name ) + " was successfully created" in output, 'Missing message in output.' assert "https://docs.nativescript.org/plugins/building-plugins" in output, 'Link to docs is missing.' # Verify created files and folders plugin_root = os.path.join(TEST_RUN_HOME, folder) readme = os.path.join(plugin_root, "README.md") src = os.path.join(plugin_root, "src") demo = os.path.join(plugin_root, "demo") post_clone_script = os.path.join(src, "scripts", "postclone.js") assert File.exists(readme), 'README.md do not exists.' assert not Folder.is_empty( src), 'src folder should exists and should not be empty.' assert not Folder.is_empty( demo), 'demo folder should exists and should not be empty.' assert not File.exists( post_clone_script ), 'Post clone script should not exists in plugin src folder.' return output
def __copy_images(cls, artifacts_folder): """ Archive test app (without platforms and node_modules) :param artifacts_folder: Base folder where artifacts from failed tests are stored. """ src = os.path.join(TEST_RUN_HOME, 'out', 'images') dest = os.path.join(artifacts_folder, 'artifacts') if os.path.isdir(src): try: shutil.copytree(src, dest) Folder.cleanup(src) except: print "Failed to backup images and logs." else: print "No images and logs data."
def test_313_build_android_with_invalid_compile_sdk(self): # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) output = Tns.build_android(attributes={ "--compileSdk": "99", "--path": self.app_name }, assert_success=False) assert "You have specified '99' for compile sdk, but it is not installed on your system." in output
def test_399_build_project_with_gz_file(self): # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) # Create zip run("tar -czf " + self.app_name + "/app/app.tar.gz " + self.app_name + "/app/app.js") assert File.exists(self.app_name + "/app/app.tar.gz") # Build the project Tns.build_android(attributes={"--path": self.app_name})
def test_321_build_with_copy_to_option(self): # TODO: Remove those lines after https://github.com/NativeScript/nativescript-cli/issues/2547 is fixed. # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) File.remove(self.debug_apk) Tns.build_android(attributes={ "--path": self.app_name, "--copy-to": "./" }) assert File.exists(self.debug_apk) File.remove(self.debug_apk)