def setUpClass(cls):
        TnsRunTest.setUpClass()

        # Ensure template package
        template_folder = os.path.join(Settings.TEST_SUT_HOME, 'templates',
                                       'packages',
                                       Template.MASTER_DETAIL_VUE.name)
        out_file = os.path.join(Settings.TEST_SUT_HOME,
                                Template.MASTER_DETAIL_VUE.name + '.tgz')
        Npm.pack(folder=template_folder, output_file=out_file)
        assert File.exists(
            out_file
        ), "Failed to pack template: " + Template.MASTER_DETAIL_VUE.name

        # Create app
        Tns.create(app_name=cls.app_name,
                   template=Template.MASTER_DETAIL_VUE.local_package,
                   update=True)
        Tns.platform_add_android(
            app_name=cls.app_name,
            framework_path=Settings.Android.FRAMEWORK_PATH)
        if Settings.HOST_OS is OSType.OSX:
            Tns.platform_add_ios(app_name=cls.app_name,
                                 framework_path=Settings.IOS.FRAMEWORK_PATH)

        # Copy TestApp to data folder.
        Folder.copy(source=cls.source_project_dir,
                    target=cls.target_project_dir)
Exemple #2
0
def __get_templates(branch=Settings.Packages.TEMPLATES_BRANCH):
    """
    Clone hello-world templates and pack them as local npm packages.
    :param branch: Branch of https://github.com/NativeScript/nativescript-app-templates
    """
    local_folder = os.path.join(Settings.TEST_SUT_HOME, 'templates')
    Git.clone(repo_url=Template.REPO, branch=branch, local_folder=local_folder)

    apps = [
        Template.HELLO_WORLD_JS, Template.HELLO_WORLD_TS,
        Template.HELLO_WORLD_NG, Template.MASTER_DETAIL_NG, Template.VUE_BLANK,
        Template.MASTER_DETAIL_VUE, Template.TAB_NAVIGATION_JS
    ]
    for app in apps:
        template_name = app.name
        template_folder = os.path.join(local_folder, 'packages', template_name)
        out_file = os.path.join(Settings.TEST_SUT_HOME, template_name + '.tgz')
        Npm.pack(folder=template_folder, output_file=out_file)
        if File.exists(out_file):
            app.path = out_file
        else:
            raise IOError("Failed to clone and pack template: " +
                          template_name)