def test_210_tns_run_ios_add_remove_files_and_folders(self): """ New files and folders should be synced properly. """ log = Tns.run_ios(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 = 'app2.css' source_file = os.path.join(self.app_name, 'app', 'app.css') destination_file = os.path.join(self.app_name, 'app', new_file_name) File.copy(source_file, destination_file) strings = ['Successfully transferred', new_file_name, 'Refreshing application'] Tns.wait_for_log(log_file=log, string_list=strings) # Revert changes(rename file and delete file) # File.copy(destination_file, source_file) # File.remove(destination_file) # strings = ['Successfully transferred', new_file_name] # Tns.wait_for_log(log_file=log, string_list=strings) # Add folder new_folder_name = 'test2' source_file = os.path.join(self.app_name, 'app', 'test') destination_file = os.path.join(self.app_name, 'app', new_folder_name) Folder.copy(source_file, destination_file) strings = ['Successfully transferred test.txt', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings)
def get_screen(device_id, file_path): """ Save screen of mobile device. :param device_id: Device identifier (example: `emulator-5554`). :param file_path: Path to image that will be saved. """ File.remove(file_path) base_path, file_name = os.path.split(file_path) Folder.create(base_path) device_type = Device.__get_device_type(device_id) if (device_type == DeviceType.EMULATOR) or (device_type == DeviceType.ANDROID): Adb.get_screen(device_id=device_id, file_path=file_path) if device_type == DeviceType.SIMULATOR: Simulator.get_screen(device_id=device_id, file_path=file_path) if device_type == DeviceType.IOS: IDevice.get_screen(device_id=device_id, file_path=file_path) image_saved = False if File.exists(file_path): size = os.path.getsize(file_path) if size > 10: image_saved = True return image_saved
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 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_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 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 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 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_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 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_301_build_project_with_space_release(self): Tns.create_app(self.app_name_space) Tns.platform_add_android( attributes={"--path": "\"" + self.app_name_space + "\"", "--frameworkPath": ANDROID_PACKAGE}) # Ensure ANDROID_KEYSTORE_PATH contain spaces (verification for CLI issue 2650) Folder.create("with space") base_path, file_name = os.path.split(ANDROID_KEYSTORE_PATH) cert_with_space_path = os.path.join("with space", file_name) File.copy(src=ANDROID_KEYSTORE_PATH, dest=cert_with_space_path) # Verify project builds Tns.build_android(attributes={"--path": "\"" + self.app_name_space + "\"", "--keyStorePath": "\"" + cert_with_space_path + "\"", "--keyStorePassword": ANDROID_KEYSTORE_PASS, "--keyStoreAlias": ANDROID_KEYSTORE_ALIAS, "--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS, "--release": "" }) output = File.read(self.app_name_space + os.sep + "package.json") assert app_identifier in output.lower() output = File.read( self.app_name_space + "/" + TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH + "AndroidManifest.xml") assert app_identifier in output.lower()
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 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_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 __run_yarn_command(command, folder=None, log_level=CommandLogLevel.FULL): if folder is not None: Folder.navigate_to(folder=folder, relative_from_current_folder=True) output = run('yarn {0}'.format(command), log_level=log_level) if folder is not None: Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) return 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 test_301_build_project_with_space_release(self): Tns.create_app(self.app_name_space) Tns.platform_add_android( attributes={ "--path": "\"" + self.app_name_space + "\"", "--frameworkPath": ANDROID_PACKAGE }) # Ensure ANDROID_KEYSTORE_PATH contain spaces (verification for CLI issue 2650) Folder.create("with space") base_path, file_name = os.path.split(ANDROID_KEYSTORE_PATH) cert_with_space_path = os.path.join("with space", file_name) File.copy(src=ANDROID_KEYSTORE_PATH, dest=cert_with_space_path) # Verify project builds Tns.build_android( attributes={ "--path": "\"" + self.app_name_space + "\"", "--keyStorePath": "\"" + cert_with_space_path + "\"", "--keyStorePassword": ANDROID_KEYSTORE_PASS, "--keyStoreAlias": ANDROID_KEYSTORE_ALIAS, "--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS, "--release": "" }) output = File.read(self.app_name_space + os.sep + "package.json") assert app_identifier in output.lower() output = File.read(self.app_name_space + "/" + TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH + "AndroidManifest.xml") assert app_identifier in output.lower()
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 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 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_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 ensure_app_resources(path): app_resources_path = os.path.join(path, "app", "App_Resources") if File.exists(app_resources_path): pass else: print "AppResources not found. Will copy from default template..." src = os.path.join(TEST_RUN_HOME, "sut", "template-hello-world", "app", "App_Resources") dest = os.path.join(TEST_RUN_HOME, path, "app", "App_Resources") Folder.copy(src, dest)
def test_200_build_android_inside_project_folder(self): Folder.navigate_to(self.app_name) output = Tns.build_android(tns_path=os.path.join("..", TNS_PATH), attributes={"--path": self.app_name}, assert_success=False, log_trace=True) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) assert successfully_prepared in output assert build_successful in output assert successfully_built in output assert File.exists(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, self.debug_apk))
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) if CURRENT_OS != OSType.OSX: raise NameError("Can not run iOS tests on non OSX OS.") else: Simulator.stop() Tns.create_app(cls.app_name) Tns.platform_add_ios(attributes={"--path": cls.app_name, "--frameworkPath": IOS_PACKAGE}) Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
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_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 pack(folder, output_file): try: Folder.navigate_to(folder) run('npm pack', log_level=CommandLogLevel.SILENT) src_file = File.find_by_extension('tgz')[0] File.copy(src=src_file, dest=output_file) File.remove(src_file) except: print 'Failed to pack {0}'.format(folder) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False)
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 test_120_platform_add_android_inside_project(self): """ Add platform inside project folder (not using --path)""" Folder.navigate_to(self.app_name) output = Tns.platform_add_android(tns_path=os.path.join( "..", TNS_PATH), assert_success=False) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) TnsAsserts.platform_added(self.app_name, platform=Platform.ANDROID, output=output)
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 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 test_210_platform_not_need_remove_after_bitcode_error(self): # https://github.com/NativeScript/nativescript-cli/issues/3741 Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False) Folder.navigate_to(self.app_name + "/app") path = os.path.join(self.app_name + "/app") run("touch a") run("ln -s a b") run("rm a") Folder.navigate_to(folder=TEST_RUN_HOME, relative_from_current_folder=False) output = Tns.prepare_android(attributes={"--path": self.app_name}) assert "Project successfully prepared" in output
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)
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_200_build_ios_inside_project(self): Folder.navigate_to(self.app_name) output = Tns.build_ios(tns_path=os.path.join("..", TNS_PATH), attributes={"--path": self.app_name}, assert_success=False, log_trace=True) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) assert "build/Debug-iphonesimulator/TestApp.app" in output assert File.exists( self.app_name + "/platforms/ios/build/Debug-iphonesimulator/TestApp.app")
def setUp(self): BaseClass.setUp(self) Folder.cleanup(self.source_app) if CURRENT_OS != OSType.WINDOWS: Folder.copy(self.temp_app, self.source_app) else: Tns.create_app(self.app_name, attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')}, update_modules=True) Tns.platform_add_android(attributes={'--path': self.app_name, '--frameworkPath': ANDROID_PACKAGE}) Emulator.ensure_available()
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_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 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 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 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 install_npm(package='', option='', folder=None, log_level=CommandLogLevel.FULL): cmd = UPDATE_WEBPACK_PATH + " --configs --deps" Npm.install(package=package, option=option, folder=folder, log_level=log_level) if folder is not None: Folder.navigate_to(folder=folder, relative_from_current_folder=True) print cmd output = run(command=cmd) if folder is not None: Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) return output
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): BaseClass.setUpClass(cls.__name__) if CURRENT_OS != OSType.OSX: raise NameError("Can not run iOS tests on non OSX OS.") else: Simulator.stop() Tns.create_app(cls.app_name) Tns.platform_add_ios(attributes={ "--path": cls.app_name, "--frameworkPath": IOS_PACKAGE }) Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")