def test_400_plugin_create_with_wrong_template(self): plugin_url = "https://github.com/NativeScript/nativescript-plugin-seed/" output = Tns.plugin_create(name=self.plugin_name, attributes={"--template": plugin_url}, assert_success=False) assert "successfully created" not in output, "It is expected plugin create to fail in this test case." assert not Folder.exists( self.plugin_name ), "Plugin folder should not exists if create operation fails."
def build_android(attributes={}, assert_success=True, tns_path=None, log_trace=False, measureTime=False): output = Tns.run_tns_command("build android", attributes=attributes, tns_path=tns_path, log_trace=log_trace, measureTime=measureTime) if assert_success: # Verify output of build command assert "Project successfully built" in output, "Build failed!" + os.linesep + output assert "FAILURE" not in output assert "NOT FOUND" not in output # Test for https://github.com/NativeScript/android-runtime/issues/390 if log_trace: assert "BUILD SUCCESSFUL" in output, "Build failed!" + os.linesep + output else: assert "BUILD SUCCESSFUL" not in output, "Native build out is displayed even without --log trace" # Verify apk packages app_name = Tns.__get_app_name_from_attributes(attributes=attributes) Tns.__get_platform_string(platform=Platform.ANDROID) android_version_string = str(TnsAsserts.get_platform_version(app_name=app_name, platform='android')) android_major_version = int(android_version_string.split('-')[0].split('.')[0]) if android_major_version > 3: apk_name = "app" debug_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, apk_name) release_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_RELEASE_PATH, apk_name) else: apk_name = Tns.__get_final_package_name(app_name, platform=Platform.ANDROID) debug_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, apk_name) release_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, apk_name) if "--release" in attributes.keys(): apk_path = release_app_path + "-release.apk" else: apk_path = debug_app_path + "-debug.apk" apk_path = apk_path.replace("\"", "") # Handle projects with space assert File.exists(apk_path), "Apk file does not exist at " + apk_path # Verify final package contains right modules (or verify bundle when it is used) if "--bundle" not in attributes.keys(): assert "Webpack compilation complete" not in output else: assert "Webpack compilation complete" in output assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "bundle.js")) assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "package.json")) assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "starter.js")) assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "vendor.js")) assert not Folder.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_NPM_MODULES_PATH)) return output
def test_400_plugin_create_with_wrong_template(self): plugin_url = "https://github.com/NativeScript/nativescript-plugin-seed/" output = Tns.plugin_create(name=self.plugin_name, attributes={"--template": plugin_url}, assert_success=False) assert "successfully created" not in output, "It is expected plugin create to fail in this test case." assert not Folder.exists(self.plugin_name), "Plugin folder should not exists if create operation fails."
def build_android(attributes={}, assert_success=True, tns_path=None, log_trace=False, measureTime=False): output = Tns.run_tns_command("build android", attributes=attributes, tns_path=tns_path, log_trace=log_trace, measureTime=measureTime) if assert_success: # Verify output of build command assert "Project successfully built" in output, "Build failed!" + os.linesep + output assert "FAILURE" not in output assert "NOT FOUND" not in output # Test for https://github.com/NativeScript/android-runtime/issues/390 if log_trace: assert "BUILD SUCCESSFUL" in output, "Build failed!" + os.linesep + output else: assert "BUILD SUCCESSFUL" not in output, "Native build out is displayed even without --log trace" # Verify apk packages app_name = Tns.__get_app_name_from_attributes( attributes=attributes) Tns.__get_platform_string(platform=Platform.ANDROID) android_version_string = str( TnsAsserts.get_platform_version(app_name=app_name, platform='android')) android_major_version = int( android_version_string.split('-')[0].split('.')[0]) if android_major_version > 3: apk_name = "app" debug_app_path = os.path.join( app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, apk_name) release_app_path = os.path.join( app_name, TnsAsserts.PLATFORM_ANDROID_APK_RELEASE_PATH, apk_name) else: apk_name = Tns.__get_final_package_name( app_name, platform=Platform.ANDROID) debug_app_path = os.path.join( app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, apk_name) release_app_path = os.path.join( app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, apk_name) if "--release" in attributes.keys(): apk_path = release_app_path + "-release.apk" else: apk_path = debug_app_path + "-debug.apk" apk_path = apk_path.replace("\"", "") # Handle projects with space assert File.exists( apk_path), "Apk file does not exist at " + apk_path # Verify final package contains right modules (or verify bundle when it is used) if "--bundle" not in attributes.keys(): assert "Webpack compilation complete" not in output else: assert "Webpack compilation complete" in output assert File.exists( os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "bundle.js")) assert File.exists( os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "package.json")) assert File.exists( os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "starter.js")) assert File.exists( os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "vendor.js")) assert not Folder.exists( os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_NPM_MODULES_PATH)) return output