示例#1
0
    def _installBusinessTemplateList(self,
                                     bt_list,
                                     update_repository_bt_list=True,
                                     *args,
                                     **kwargs):
        """Install depencencies automatically

    taken from runUnitTest._ZodbTestComponentBootstrapOnly.
    """
        template_tool = self.portal.portal_templates

        from Products.ERP5.ERP5Site import getBootstrapDirectory
        bt5_path_list = [
            os.environ.get('erp5_tests_bootstrap_path')
            or getBootstrapDirectory()
        ]
        for path in os.environ['erp5_tests_bt5_path'].split(','):
            if os.path.exists(os.path.join(path, "bt5list")):
                bt5_path_list.append(path)
            for path in glob(os.path.join(path, "*", "bt5list")):
                bt5_path_list.append(os.path.dirname(path))

        template_tool.updateRepositoryBusinessTemplateList(bt5_path_list)

        url_bt_tuple_list = [
            ('%s/%s' % (repository, bt_title), bt_title) for repository,
            bt_title in template_tool.resolveBusinessTemplateListDependency(
                [x[1] for x in bt_list], with_test_dependency_list=True)
        ]

        return super(CodingStyleTest, self)._installBusinessTemplateList(
            url_bt_tuple_list, *args, **kwargs)
示例#2
0
文件: runUnitTest.py 项目: poses/erp5
                def _installBusinessTemplateList(
                        self,
                        bt_list,
                        update_repository_bt_list=True,
                        *args,
                        **kwargs):
                    """
          Before installing BTs by calling the original method:

          1/ Get filesystem BT repositories and set them to Template Tool
          2/ Update BT repositories
          3/ Resolve dependencies:
             * dependency_list: recursive.
             * test_dependency_list: non-recursive.
          4/ Install BTs as before
          """
                    template_tool = self.portal.portal_templates

                    from Products.ERP5.ERP5Site import getBootstrapDirectory
                    bt5_path_list = [
                        os.environ.get('erp5_tests_bootstrap_path')
                        or getBootstrapDirectory()
                    ]

                    bt5_path = os.environ.get('erp5_tests_bt5_path')
                    if bt5_path:
                        bt5_path_list.extend([
                            bt5_path.replace('*', '')
                            for bt5_path in bt5_path.split(',')
                        ])
                    else:
                        from App.config import getConfiguration
                        instancehome = getConfiguration().instancehome
                        bt5_path_list.append(os.path.join(instancehome, 'bt5'))

                    bt5_path_list = [
                        bt5_path for bt5_path in bt5_path_list
                        if os.path.exists(bt5_path)
                    ]

                    template_tool.updateRepositoryBusinessTemplateList(
                        bt5_path_list)

                    url_bt_tuple_list = [
                        ('%s/%s' % (repository, bt_title), bt_title)
                        for repository, bt_title in
                        template_tool.resolveBusinessTemplateListDependency(
                            bt_list, with_test_dependency_list=True)
                    ]

                    return super(_ZodbTestComponentBootstrapOnly,
                                 self)._installBusinessTemplateList(
                                     url_bt_tuple_list, *args, **kwargs)
示例#3
0
        def _installBusinessTemplateList(self,
                                         bt_list,
                                         update_repository_bt_list=True,
                                         *args,
                                         **kwargs):
          """
          Before installing BTs by calling the original method:

          1/ Get filesystem BT repositories and set them to Template Tool
          2/ Update BT repositories
          3/ Resolve dependencies:
             * dependency_list: recursive.
             * test_dependency_list: non-recursive.
          4/ Install BTs as before
          """
          template_tool = self.portal.portal_templates

          from Products.ERP5.ERP5Site import getBootstrapDirectory
          bt5_path_list = [os.environ.get('erp5_tests_bootstrap_path') or
                           getBootstrapDirectory()]

          bt5_path = os.environ.get('erp5_tests_bt5_path')
          if bt5_path:
            bt5_path_list += {re.sub("(\/\*|\*)", '', bt5_path)
                              for bt5_path in bt5_path.split(',')}
          else:
            from App.config import getConfiguration
            instancehome = getConfiguration().instancehome
            bt5_path_list.append(os.path.join(instancehome, 'bt5'))

          valid_bt5_path_list = []
          for bt5_path in bt5_path_list:
            if bt5_path:
              bt5_path = os.path.expanduser(bt5_path)
              if not os.path.exists(bt5_path):
                _print("Ignoring non existant bt5 path %s\n" % bt5_path)
              else:
                valid_bt5_path_list.append(bt5_path)

          template_tool.updateRepositoryBusinessTemplateList(valid_bt5_path_list)

          url_bt_tuple_list = [
            ('%s/%s' % (repository, bt_title), bt_title) for repository, bt_title in
            template_tool.resolveBusinessTemplateListDependency(
              bt_list,
              with_test_dependency_list=True)]

          return super(_ZodbTestComponentBootstrapOnly,
                       self)._installBusinessTemplateList(url_bt_tuple_list,
                                                          *args, **kwargs)
示例#4
0
                def _installBusinessTemplateList(
                        self,
                        bt_list,
                        update_repository_bt_list=True,
                        *args,
                        **kwargs):
                    """
          Before installing BTs by calling the original method:

          1/ Get filesystem BT repositories and set them to Template Tool
          2/ Update BT repositories
          3/ Resolve dependencies:
             * dependency_list: recursive.
             * test_dependency_list: non-recursive.
          4/ Install BTs as before
          """
                    template_tool = self.portal.portal_templates

                    from Products.ERP5.ERP5Site import getBootstrapDirectory
                    bt5_path_list = [
                        os.environ.get('erp5_tests_bootstrap_path')
                        or getBootstrapDirectory()
                    ]
                    for path in os.environ['erp5_tests_bt5_path'].split(','):
                        if os.path.exists(os.path.join(path, "bt5list")):
                            bt5_path_list.append(path)
                        for path in glob(os.path.join(path, "*", "bt5list")):
                            bt5_path_list.append(os.path.dirname(path))

                    template_tool.updateRepositoryBusinessTemplateList(
                        bt5_path_list)

                    url_bt_tuple_list = [
                        ('%s/%s' % (repository, bt_title), bt_title)
                        for repository, bt_title in
                        template_tool.resolveBusinessTemplateListDependency(
                            bt_list, with_test_dependency_list=True)
                    ]

                    return super(_ZodbTestComponentBootstrapOnly,
                                 self)._installBusinessTemplateList(
                                     url_bt_tuple_list, *args, **kwargs)
示例#5
0
        def _installBusinessTemplateList(self,
                                         bt_list,
                                         update_repository_bt_list=True,
                                         *args,
                                         **kwargs):
          """
          Before installing BTs by calling the original method:

          1/ Get filesystem BT repositories and set them to Template Tool
          2/ Update BT repositories
          3/ Resolve dependencies:
             * dependency_list: recursive.
             * test_dependency_list: non-recursive.
          4/ Install BTs as before
          """
          template_tool = self.portal.portal_templates

          from Products.ERP5.ERP5Site import getBootstrapDirectory
          bt5_path_list = [os.environ.get('erp5_tests_bootstrap_path') or
                           getBootstrapDirectory()]
          for path in os.environ['erp5_tests_bt5_path'].split(','):
            if os.path.exists(os.path.join(path, "bt5list")):
              bt5_path_list.append(path)
            for path in glob(os.path.join(path, "*", "bt5list")):
              bt5_path_list.append(os.path.dirname(path))

          template_tool.updateRepositoryBusinessTemplateList(bt5_path_list)

          url_bt_tuple_list = [
            ('%s/%s' % (repository, bt_title), bt_title) for repository, bt_title in
            template_tool.resolveBusinessTemplateListDependency(
              bt_list,
              with_test_dependency_list=True)]

          return super(_ZodbTestComponentBootstrapOnly,
                       self)._installBusinessTemplateList(url_bt_tuple_list,
                                                          *args, **kwargs)
示例#6
0
    def _installBusinessTemplateList(self,
                                     bt_list,
                                     update_repository_bt_list=True,
                                     *args,
                                     **kwargs):
        """Install dependencies automatically and also install erp5_upgrader,
    which is needed for CodingStyleTestCase.test_run_upgrader

    the resolution approach is taken from runUnitTest._ZodbTestComponentBootstrapOnly.
    """
        template_tool = self.portal.portal_templates

        from Products.ERP5.ERP5Site import getBootstrapDirectory
        bt5_path_list = [
            os.environ.get('erp5_tests_bootstrap_path')
            or getBootstrapDirectory()
        ]
        for path in os.environ['erp5_tests_bt5_path'].split(','):
            if os.path.exists(os.path.join(path, "bt5list")):
                bt5_path_list.append(path)
            for path in glob(os.path.join(path, "*", "bt5list")):
                bt5_path_list.append(os.path.dirname(path))

        template_tool.updateRepositoryBusinessTemplateList(bt5_path_list)

        bt_to_install_title_set = set(x[1] for x in bt_list)
        bt_to_install_title_set.add('erp5_core')
        # Install the tested business template.
        try:
            url_bt_tuple_list = [
                ('%s/%s' % (repository, bt_title), bt_title)
                for repository, bt_title in
                template_tool.resolveBusinessTemplateListDependency(
                    bt_to_install_title_set, with_test_dependency_list=True)
            ]
        except BusinessTemplateMissingDependency as e:
            # it may have a virtual dependency on erp5_full_text_catalog, if that's
            # the case, we choose erp5_full_text_mroonga_catalog
            if str(e).startswith(
                    'Unable to resolve dependencies for erp5_full_text_catalog,'
            ):
                url_bt_tuple_list = [
                    ('%s/%s' % (repository, bt_title), bt_title)
                    for repository, bt_title in
                    template_tool.resolveBusinessTemplateListDependency(
                        bt_to_install_title_set
                        | set(('erp5_full_text_mroonga_catalog', )),
                        with_test_dependency_list=True)
                ]

        if 'erp5_upgrader' not in bt_to_install_title_set:
            upgrader_url_bt_tuple_list = [
                ('%s/%s' % (repository, bt_title), bt_title)
                for repository, bt_title in
                template_tool.resolveBusinessTemplateListDependency(
                    ['erp5_upgrader'],
                    # We don't actually run erp5_upgrader test, so we don't want to install
                    # erp5_upgrader test dependencies
                    with_test_dependency_list=False)
            ]
            for url, bt in upgrader_url_bt_tuple_list:
                if bt not in bt_to_install_title_set:
                    url_bt_tuple_list.append((url, bt))

        return super(CodingStyleTest, self)._installBusinessTemplateList(
            url_bt_tuple_list, *args, **kwargs)