def test_equal_number_per_major(self):
        """
            Drupal fails hard after updating with auto updater of versions.xml
            This is because misc/tableheader.js had newer versions and not older versions of the 7.x branch.
            I've removed these manually, but if this is not auto fixed, then it
                opens up some extremely buggy-looking behaviour.

            So, in conclusion, each version should have the same number of
            files (as defined in versions.xml file) as all other versions in
            the same major branch.

            E.g. All drupal 7.x versions should reference 3 files. If one of
            them has more than 3, the detection algorithm will fail.
        """
        fails = []
        for xml_path in glob(dscan.PWD + "plugins/*/versions.xml"):
            vf = VersionsFile(xml_path)

            if "silverstripe" in xml_path:
                major_numbers = 2
            else:
                major_numbers = 1

            fpvm = vf.files_per_version_major(major_numbers)

            number = 0
            for major in fpvm:
                for version in fpvm[major]:
                    nb = len(fpvm[major][version])
                    if number == 0:
                        number = nb

                    if nb != number:
                        msg = """All majors should have the same number of
                          files, and version %s has %s, versus %s on other
                          files.""" % (
                            version,
                            nb,
                            number,
                        )

                        fails.append(" ".join(msg.split()))

                number = 0

        if len(fails) > 0:
            for fail in fails:
                print(fail)

            assert False
Exemple #2
0
    def test_equal_number_per_major(self):
        """
            Drupal fails hard after updating with auto updater of versions.xml
            This is because misc/tableheader.js had newer versions and not older versions of the 7.x branch.
            I've removed these manually, but if this is not auto fixed, then it
                opens up some extremely buggy-looking behaviour.

            So, in conclusion, each version should have the same number of
            files (as defined in versions.xml file) as all other versions in
            the same major branch.

            E.g. All drupal 7.x versions should reference 3 files. If one of
            them has more than 3, the detection algorithm will fail.
        """
        fails = []
        for xml_path in glob(dscan.PWD + 'plugins/*/versions.xml'):
            vf = VersionsFile(xml_path)

            controller_name = xml_path.split('/')[-2]
            controller = self.controller_get(controller_name)
            major_numbers = len(controller.update_majors[0].split('.'))

            fpvm = vf.files_per_version_major(major_numbers)

            number = 0
            for major in fpvm:
                for version in fpvm[major]:
                    nb = len(fpvm[major][version])
                    if number == 0:
                        number = nb
                        example_number = version

                    if nb != number:
                        msg = """All majors should have the same number of
                          files, and version %s has %s, versus %s on other
                          files (e.g. %s).""" % (version, nb, number,
                                                 example_number)

                        fails.append(" ".join(msg.split()))

                number = 0

        if len(fails) > 0:
            for fail in fails:
                print(fail)

            assert False