Exemple #1
0
    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 created_ts(app_name, output=None):
        """
        Assert TypeScript application is created properly.
        :param app_name: App name
        :param output: Output of `tns create command`
        """

        # First make sure base app is created
        TnsAsserts.created(app_name=app_name, output=output)

        # Assert output contains TypeScript plugin
        if USE_YARN != "True":
            if Npm.version() < 5:
                assert 'nativescript-dev-typescript' in output

        # Assert files added with TypeScript plugin
        ts_config = os.path.join(app_name, 'tsconfig.json')
        ref_dts = os.path.join(app_name, 'references.d.ts')
        dts = os.path.join(app_name, TnsAsserts.TNS_MODULES, 'tns-core-modules.d.ts')

        # Assert content of files added with TypeScript plugin.
        assert File.exists(ts_config)
        assert not File.exists(ref_dts)
        assert File.exists(dts)

        ts_config_json = TnsAsserts.get_tsconfig_json(app_name=app_name)
        paths = ts_config_json.get('compilerOptions').get('paths')
        assert paths is not None, 'Paths missing in tsconfig.json'

        assert not Folder.is_empty(os.path.join(app_name, TnsAsserts.NODE_MODULES, 'nativescript-dev-typescript'))
        assert File.exists(os.path.join(app_name, TnsAsserts.HOOKS, 'before-prepare', 'nativescript-dev-typescript.js'))
        assert File.exists(os.path.join(app_name, TnsAsserts.HOOKS, 'before-watch', 'nativescript-dev-typescript.js'))
        assert File.exists(os.path.join(app_name, TnsAsserts.NODE_MODULES, 'typescript', 'bin', 'tsc'))
Exemple #3
0
 def test_330_platform_update_ios_platform_not_added(self):
     Tns.create_app(self.app_name)
     output = Tns.platform_update(platform="ios",
                                  attributes={"--path": self.app_name},
                                  assert_success=False)
     assert "Platform ios successfully added" in output
     assert not Folder.is_empty(
         self.app_name + "/platforms/ios/internal/metadata-generator")
Exemple #4
0
 def test_201_platform_remove_ios(self):
     Tns.platform_add_ios(attributes={
         "--path": self.app_name,
         "--frameworkPath": IOS_PACKAGE
     })
     Tns.platform_remove(platform="ios",
                         attributes={"--path": self.app_name})
     assert Folder.is_empty(self.app_name + '/platforms')
     output = File.read(self.app_name + os.sep + "package.json")
     assert "tns-ios" not 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
Exemple #6
0
    def created_ts(app_name, output=None):
        """
        Assert TypeScript application is created properly.
        :param app_name: App name
        :param output: Output of `tns create command`
        """

        # First make sure base app is created
        TnsAsserts.created(app_name=app_name, output=output)

        # Assert output contains TypeScript plugin
        if USE_YARN != "True":
            if Npm.version() < 5:
                assert 'nativescript-dev-typescript' in output

        # Assert files added with TypeScript plugin
        ts_config = os.path.join(app_name, 'tsconfig.json')
        ref_dts = os.path.join(app_name, 'references.d.ts')
        dts = os.path.join(app_name, TnsAsserts.TNS_MODULES,
                           'tns-core-modules.d.ts')

        # Assert content of files added with TypeScript plugin.
        assert File.exists(ts_config)
        assert not File.exists(ref_dts)
        assert File.exists(dts)

        ts_config_json = TnsAsserts.get_tsconfig_json(app_name=app_name)
        paths = ts_config_json.get('compilerOptions').get('paths')
        assert paths is not None, 'Paths missing in tsconfig.json'

        assert not Folder.is_empty(
            os.path.join(app_name, TnsAsserts.NODE_MODULES,
                         'nativescript-dev-typescript'))
        assert File.exists(
            os.path.join(app_name, TnsAsserts.HOOKS, 'before-prepare',
                         'nativescript-dev-typescript.js'))
        assert File.exists(
            os.path.join(app_name, TnsAsserts.HOOKS, 'before-watch',
                         'nativescript-dev-typescript.js'))
        assert File.exists(
            os.path.join(app_name, TnsAsserts.NODE_MODULES, 'typescript',
                         'bin', 'tsc'))
 def test_330_platform_update_ios_platform_not_added(self):
     Tns.create_app(self.app_name)
     output = Tns.platform_update(platform="ios", attributes={"--path": self.app_name}, assert_success=False)
     assert "Platform ios successfully added" in output
     assert not Folder.is_empty(self.app_name + "/platforms/ios/internal/metadata-generator")
 def test_201_platform_remove_ios(self):
     Tns.platform_add_ios(attributes={"--path": self.app_name, "--frameworkPath": IOS_PACKAGE})
     Tns.platform_remove(platform="ios", attributes={"--path": self.app_name})
     assert Folder.is_empty(self.app_name + '/platforms')
     output = File.read(self.app_name + os.sep + "package.json")
     assert "tns-ios" not in output