Exemplo n.º 1
0
    def _test_update(self, filename, contents, expected_new_contents,
                     expected_updates):
        with tempfile.TemporaryDirectory() as tmpdir:
            manifest = os.path.join(tmpdir, filename)
            with open(manifest, "w") as f:
                f.write(contents)

            appdata = os.path.join(
                tmpdir,
                os.path.splitext(filename)[0] + ".appdata.xml",
            )
            with open(appdata, "w") as f:
                f.write("""<application></application>""")

            checker = ManifestChecker(manifest)
            checker._checkers = [UpdateEverythingChecker()]
            checker.check()
            updates = checker.update_manifests()

            with open(manifest, "r") as f:
                new_contents = f.read()

            self.assertEqual(new_contents, expected_new_contents)
            self.assertEqual(updates, expected_updates)

            with open(appdata, "r") as f:
                appdata_doc = minidom.parse(f)

            releases = appdata_doc.getElementsByTagName("release")
            self.assertNotEqual(releases, [])
            self.assertEqual(releases, releases[:1])
            self.assertEqual(releases[0].getAttribute("version"), "1.2.3.4")
            self.assertEqual(releases[0].getAttribute("date"), "2019-08-28")
Exemplo n.º 2
0
 def test_check(self):
     checker = ManifestChecker(TEST_MANIFEST)
     ext_data = checker.check()
     for data in ext_data:
         self.assertIsNotNone(data)
         self.assertIsNotNone(data.new_version)
         self.assertIsNotNone(data.new_version.url)
         self.assertIsNotNone(data.new_version.checksum)
         self.assertIsNotNone(data.new_version.version)
         self.assertNotEqual(data.new_version.url, data.current_version.url)
         self.assertNotEqual(
             data.new_version.checksum, data.current_version.checksum
         )
         self.assertRegex(
             data.new_version.url, r"http://deb.debian.org/debian/pool/main/.+"
         )
         if data.filename == "python-apt-source.tar.xz":
             self.assertRegex(
                 data.new_version.url,
                 r"http://deb.debian.org/debian/pool/main/p/python-apt/python-apt_(\d[\d\.-]+\d).tar.xz",
             )
         elif data.filename == "apt-aarch64.deb":
             self.assertRegex(
                 data.new_version.url,
                 r"http://deb.debian.org/debian/pool/main/a/apt/apt_(\d[\d\.-]+\d)_arm64.deb",
             )
         else:
             self.fail(f"Unknown data {data.filename}")
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), NUM_ALL_EXT_DATA)

        ext_data_with_new_version = 0

        for data in ext_data:
            if data.new_version:
                ext_data_with_new_version += 1

        self.assertEqual(ext_data_with_new_version, 1)

        file_ext_data = checker.get_external_data(ExternalData.Type.FILE)
        self.assertEqual(len(file_ext_data), NUM_FILE_IN_MANIFEST)

        archive_ext_data = checker.get_external_data(ExternalData.Type.ARCHIVE)
        self.assertEqual(len(archive_ext_data), NUM_ARCHIVE_IN_MANIFEST)

        extra_data = checker.get_external_data(ExternalData.Type.EXTRA_DATA)
        self.assertEqual(len(extra_data), NUM_EXTRA_DATA_IN_MANIFEST)

        outdated_ext_data = checker.get_outdated_external_data()
        self.assertEqual(len(outdated_ext_data), NUM_ALL_EXT_DATA - 1)

        dropbox = self._find_by_filename(ext_data, "dropbox.tgz")
        self.assertIsNotNone(dropbox)
        self.assertEqual(dropbox.new_version.version, "64")
        self.assertEqual(dropbox.new_version.url, "https://httpbingo.org/base64/4puE")

        # this URL is a redirect, but since it is not a rotating-url the URL
        # should not be updated.
        image = self._find_by_filename(ext_data, "image.jpeg")
        self.assertIsNone(image)
Exemplo n.º 4
0
    def _test_remove(self, filename, contents, expected_new_contents, expected_updates):
        with tempfile.TemporaryDirectory() as tmpdir:
            manifest = os.path.join(tmpdir, filename)
            with open(manifest, "w") as f:
                f.write(contents)

            checker = ManifestChecker(manifest)
            checker._checkers = [RemoveEverythingChecker()]
            checker.check()
            updates = checker.update_manifests()

            with open(manifest, "r") as f:
                new_contents = f.read()

            self.assertEqual(new_contents, expected_new_contents)
            self.assertEqual(updates, expected_updates)
Exemplo n.º 5
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), 4)
        for data in ext_data:
            if data.filename != "Pillow-7.2.0.tar.gz":
                self.assertIsNotNone(data.new_version)
                self.assertIsNotNone(data.new_version.url)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsNotNone(data.new_version.version)
                self.assertNotEqual(data.new_version.url,
                                    data.current_version.url)
                self.assertNotEqual(data.new_version.checksum,
                                    data.current_version.checksum)
            if data.filename == "setuptools-50.3.2-py3-none-any.whl":
                self.assertRegex(
                    data.new_version.url,
                    r"https://files.pythonhosted.org/packages/[a-f0-9/]+/setuptools-[\d\.]+-[\S\.]+-none-any.whl",
                )
            elif data.filename == "PyYAML-5.3.1.tar.gz":
                self.assertRegex(
                    data.new_version.url,
                    r"https://files.pythonhosted.org/packages/[a-f0-9/]+/PyYAML-[\d\.]+.(tar.(gz|xz|bz2)|zip)",
                )
            elif data.filename == "vdf-3.1-py2.py3-none-any.whl":
                self.assertRegex(
                    data.new_version.url,
                    r"https://files.pythonhosted.org/packages/[a-f0-9/]+/vdf-[\d\.]+-[\S\.]+-none-any.whl",
                )
                self.assertEqual(data.new_version.version, "3.2")
            elif data.filename == "Pillow-7.2.0.tar.gz":
                self.assertIsNone(data.new_version)
            else:
                self.fail(f"Unknown data {data.filename}")
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), 4)
        for data in ext_data:
            self.assertIsNotNone(data)
            self.assertIsNotNone(data.new_version)
            if data.filename == "jq-1.4.tar.gz":
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertNotEqual(data.current_version.url, data.new_version.url)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://github.com/stedolan/jq/releases/download/jq-[0-9\.\w]+/jq-[0-9\.\w]+\.tar.gz$",
                )
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, str)
                self.assertNotEqual(
                    data.new_version.checksum,
                    "0000000000000000000000000000000000000000000000000000000000000000",
                )
            elif data.filename == "oniguruma.git":
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertEqual(data.current_version.url, data.new_version.url)
                self.assertIsNotNone(data.new_version.tag)
                self.assertIsNotNone(data.new_version.commit)
                self.assertNotEqual(data.new_version.tag, data.current_version.tag)
                self.assertNotEqual(
                    data.new_version.commit, data.current_version.commit
                )
                self.assertNotEqual(
                    data.new_version.commit, "e03900b038a274ee2f1341039e9003875c11e47d"
                )
                self.assertIsNotNone(data.new_version.version)
                self.assertIsNotNone(data.new_version.timestamp)
            elif data.filename == "yasm.git":
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertEqual(data.current_version.url, data.new_version.url)
                self.assertIsNotNone(data.new_version.tag)
                self.assertIsNotNone(data.new_version.commit)
                self.assertNotEqual(data.new_version.tag, data.current_version.tag)
                self.assertIsNotNone(data.new_version.version)
                self.assertIsNone(data.new_version.timestamp)
            elif data.filename == "tdesktop.git":
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertEqual(data.current_version.url, data.new_version.url)
                self.assertIsNotNone(data.new_version.tag)
                self.assertIsNotNone(data.new_version.commit)
                self.assertNotEqual(data.new_version.tag, data.current_version.tag)
                self.assertIsNotNone(data.new_version.version)
                self.assertIsNone(data.new_version.timestamp)
            else:
                self.fail(f"Unhandled data {data.filename}")
    def test_check_filtered(self):
        # Use only the URLChecker which is fast so we don't have to wait a lot
        # for this test; so save the real checkers for later
        dummy_checker = ManifestChecker(TEST_MANIFEST)
        dummy_checker._checkers = [DummyChecker()]

        ext_data = dummy_checker.check()
        ext_data_from_getter = dummy_checker.get_external_data()
        self.assertEqual(len(ext_data), len(ext_data_from_getter))
        self.assertEqual(set(ext_data), set(ext_data_from_getter))

        self.assertEqual(len(ext_data), NUM_ALL_EXT_DATA)
        ext_data = dummy_checker.check(ExternalData.Type.EXTRA_DATA)
        self.assertEqual(len(ext_data), NUM_EXTRA_DATA_IN_MANIFEST)

        ext_data = dummy_checker.check(ExternalData.Type.FILE)
        self.assertEqual(len(ext_data), NUM_FILE_IN_MANIFEST)

        ext_data = dummy_checker.check(ExternalData.Type.ARCHIVE)
        self.assertEqual(len(ext_data), NUM_ARCHIVE_IN_MANIFEST)
Exemplo n.º 8
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), 2)

        for data in ext_data:
            self.assertIsNotNone(data.new_version)
            self.assertRegex(data.new_version.url, r"^https?://.*\.tar.gz$")
            self.assertIsInstance(data.new_version.size, int)
            self.assertGreater(data.new_version.size, 1024 * 1024)
            self.assertIsNotNone(data.new_version.version)
 def test_check(self):
     checker = ManifestChecker(TEST_MANIFEST)
     ext_data = checker.check()
     self._test_separate_patterns(
         self._find_by_filename(ext_data, "xeyes-1.1.0.tar.bz2"))
     self._test_check_with_url_template(
         self._find_by_filename(ext_data, "ico-1.0.4.tar.bz2"))
     self._test_combo_pattern(
         self._find_by_filename(ext_data, "libXScrnSaver-1.2.2.tar.bz2"))
     self._test_combo_pattern_nosort(
         self._find_by_filename(ext_data, "qrupdate-1.1.0.tar.gz"))
     self._test_no_match(
         self._find_by_filename(ext_data, "libFS-1.0.7.tar.bz2"))
Exemplo n.º 10
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), NUM_ALL_EXT_DATA)

        ext_data_with_new_version = 0

        for data in ext_data:
            if data.new_version:
                ext_data_with_new_version += 1

        self.assertEqual(ext_data_with_new_version, 2)

        file_ext_data = checker.get_external_data(ExternalData.Type.FILE)
        self.assertEqual(len(file_ext_data), NUM_FILE_IN_MANIFEST)

        archive_ext_data = checker.get_external_data(ExternalData.Type.ARCHIVE)
        self.assertEqual(len(archive_ext_data), NUM_ARCHIVE_IN_MANIFEST)

        extra_data = checker.get_external_data(ExternalData.Type.EXTRA_DATA)
        self.assertEqual(len(extra_data), NUM_EXTRA_DATA_IN_MANIFEST)

        outdated_ext_data = checker.get_outdated_external_data()
        self.assertEqual(len(outdated_ext_data), NUM_ALL_EXT_DATA - 1)

        dropbox = self._find_by_filename(ext_data, "dropbox.tgz")
        self.assertIsNotNone(dropbox)
        self.assertEqual(dropbox.new_version.version, "64")
        self.assertEqual(dropbox.new_version.url,
                         "https://httpbingo.org/base64/4puE")

        relative_redirect = self._find_by_filename(ext_data,
                                                   "relative-redirect.txt")
        self.assertIsNotNone(relative_redirect)
        self.assertEqual(
            relative_redirect.new_version.url,
            "https://httpbingo.org/base64/MzAtNTAgZmVyYWwgaG9ncyEK",
        )
        self.assertEqual(
            relative_redirect.new_version.checksum,
            "e4d67702da4eeeb2f15629b65bf6767c028a511839c14ed44d9f34479eaa2b94",
        )
        self.assertEqual(relative_redirect.new_version.size, 18)

        # this URL is a redirect, but since it is not a rotating-url the URL
        # should not be updated.
        image = self._find_by_filename(ext_data, "image.jpeg")
        self.assertIsNone(image)
Exemplo n.º 11
0
    def test_check_and_update(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), 8)
        for data in ext_data:
            self.assertIsInstance(data, ExternalGitRepo)
            self.assertIsInstance(data.current_version, ExternalGitRef)
            if data.filename == "jansson.git":
                self.assertEqual(data.state, data.State.UNKNOWN)
                self.assertIsNone(data.new_version)
            elif data.filename == "c-vtapi.git":
                self.assertEqual(data.state, data.State.BROKEN)
                self.assertIsNotNone(data.new_version)
                self.assertEqual(data.current_version.url, data.new_version.url)
                self.assertNotEqual(
                    data.current_version.commit, data.new_version.commit
                )
                self.assertFalse(data.current_version.matches(data.new_version))
            elif data.filename == "qt-virustotal-uploader.git":
                self.assertEqual(data.state, data.State.VALID)
                self.assertIsNone(data.new_version)
            elif data.filename == "protobuf-c.git":
                self.assertEqual(data.state, data.State.UNKNOWN)
                self.assertIsNone(data.new_version)
            elif data.filename == "yara.git":
                self.assertEqual(data.state, data.State.BROKEN)
                self.assertIsNone(data.new_version)
            elif data.filename == "yara-python.git":
                self.assertEqual(data.state, data.State.UNKNOWN)
                self.assertIsNone(data.new_version)
            elif data.filename == "vt-py.git":
                self.assertEqual(data.state, data.State.VALID)
                self.assertIsNone(data.new_version)
            elif data.filename == "extra-cmake-modules.git":
                self.assertIsNotNone(data.new_version)
                self.assertIsNone(data.new_version.branch)
                self.assertIsNotNone(data.new_version.commit)
                self.assertIsNotNone(data.new_version.tag)
                self.assertIsNotNone(data.new_version.version)
                self.assertNotEqual(data.new_version.tag, data.current_version.tag)
                self.assertNotEqual(
                    data.new_version.commit, data.current_version.commit
                )
                self.assertRegex(data.new_version.tag, r"^[vV][\d.]+$")
                self.assertRegex(data.new_version.version, r"^[\d.]+$")
            else:
                self.fail(f"Unknown data {data.filename}")
            self._test_update_data(data, copy.deepcopy(data.source))
Exemplo n.º 12
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        data = self._find_by_filename(ext_data, "UnityHubSetup.AppImage")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "UnityHubSetup.AppImage")
        self.assertIsNotNone(data.new_version)
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertNotEqual(
            data.new_version.checksum,
            "0000000000000000000000000000000000000000000000000000000000000000",
        )
        self.assertIsNotNone(data.new_version.version)
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), 1)
        data = ext_data[0]
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https://static.rust-lang.org/dist/[\-\d]+/rust-nightly-x86_64-unknown-linux-gnu.tar.xz$",
        )
        self.assertIsNone(data.new_version.size)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertNotEqual(
            data.new_version.checksum,
            "24b4681187654778817652273a68a4d55f5090604cd14b1f1c3ff8785ad24b99",
        )
Exemplo n.º 14
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        data = self._find_by_filename(ext_data, "phpstorm.tar.gz")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "phpstorm.tar.gz")
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https://download\.jetbrains\.com/webide/PhpStorm-.+\.tar\.gz$",  # noqa: E501
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertNotEqual(
            data.new_version.checksum,
            "0000000000000000000000000000000000000000000000000000000000000000",
        )
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        data = self._find_by_filename(ext_data, "nordpass.snap")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "nordpass.snap")
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https://api\.snapcraft\.io/api/v1/snaps/download/[A-Za-z0-9]{32}_[0-9]+.snap$",
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertNotEqual(
            data.new_version.checksum,
            "0000000000000000000000000000000000000000000000000000000000000000",
        )
    def test_check_with_url_template(self):
        checker = ManifestChecker(TEST_MANIFEST_WITH_URL_TEMPLATE)
        ext_data = checker.check()

        data = self._find_by_filename(ext_data, "xdebug.tar.gz")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "xdebug.tar.gz")
        self.assertIsNotNone(data.new_version)
        self.assertEqual(
            data.new_version.url,
            "https://xdebug.org/files/xdebug-2.9.0.tgz",
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertEqual(
            data.new_version.checksum,
            "8dd1f867805d4ae78ccefc1825da1180eb82efbe6d6575eef2cc3dd1aeca5943",
        )
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        data = self._find_by_filename(ext_data,
                                      "flash_player_sa_linux.x86_64.tar.gz")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "flash_player_sa_linux.x86_64.tar.gz")
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https?://fpdownload\.macromedia\.com/pub/flashplayer/updaters/.+/flash_player_sa_linux\.x86_64\.tar\.gz$",  # noqa: E501
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertNotEqual(
            data.new_version.checksum,
            "0000000000000000000000000000000000000000000000000000000000000000",
        )
Exemplo n.º 18
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        data = self._find_by_filename(ext_data, "baobab-3.34.0.tar.xz")

        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "baobab-3.34.0.tar.xz")
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https://download\.gnome\.org/sources/baobab/.+/baobab-.+\.tar\.xz$",  # noqa: E501
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertNotEqual(
            data.new_version.checksum,
            "0000000000000000000000000000000000000000000000000000000000000000",
        )
Exemplo n.º 19
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        for data in ext_data:
            self.assertIsNotNone(data.new_version)
            self.assertIsNotNone(data.new_version.checksum)
            self.assertIsInstance(data.new_version.checksum, str)
            self.assertNotEqual(
                data.new_version.checksum,
                "0000000000000000000000000000000000000000000000000000000000000000",
            )
            self.assertIsNotNone(data.new_version.version)
            self.assertIsInstance(data.new_version.version, str)

            if data.filename == "baobab-3.34.0.tar.xz":
                self._test_stable_only(data)
            elif data.filename == "pygobject-3.36.0.tar.xz":
                self._test_include_unstable(data)
            elif data.filename == "alleyoop-0.9.8.tar.xz":
                self._test_non_standard_version(data)
Exemplo n.º 20
0
    def test_check_library(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        data = self._find_by_filename(ext_data, "alleyoop-0.9.8.tar.xz")

        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "alleyoop-0.9.8.tar.xz")
        self.assertIsNotNone(data.new_version)
        self.assertEqual(
            data.new_version.version,
            "0.9.8",
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, str)
        self.assertEqual(
            data.new_version.checksum,
            "adaa432fbbdccdb07751b2a5b8f0159a31d8d8f3d27503374a96122778163ff1",
        )
Exemplo n.º 21
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        def data_with_state(state):
            return [data for data in ext_data if data.state == state]

        removed = data_with_state(ExternalData.State.REMOVED)
        added = data_with_state(ExternalData.State.ADDED)
        updated = data_with_state(ExternalData.State.VALID)

        self.assertEqual(len(removed), 2)
        self.assertGreater(len(added), 0)
        self.assertEqual(len(updated), 1)

        data = updated[0]
        self.assertEqual(data.filename, "firefox.tar.bz2")
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https?://.*/linux-x86_64/en-US/firefox-.+\.tar\.bz2$",
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)

        for data in removed:
            self.assertIsNone(data.new_version)
            self.assertIn(data.filename, ["foo.xpi", "bar.xpi"])

        for data in added:
            self.assertIsNotNone(data.current_version)
            self.assertRegex(
                data.current_version.url,
                r"^https?://.*/linux-x86_64/.*/.*\.xpi$",
            )
            self.assertIsInstance(data.current_version.size, int)
            self.assertGreater(data.current_version.size, 0)
            self.assertIsNotNone(data.current_version.checksum)
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), 2)
        for data in ext_data:
            if data.filename == "flatpak-1.8.2.tar.xz":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://github.com/flatpak/flatpak/releases/download/[\w\d.]+/flatpak-[\w\d.]+.tar.xz$",
                )
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, str)
                self.assertNotEqual(
                    data.new_version.checksum,
                    "7926625df7c2282a5ee1a8b3c317af53d40a663b1bc6b18a2dc8747e265085b0",
                )
            elif data.filename == "ostree.git":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertIsNotNone(data.new_version.commit)
                self.assertIsNotNone(data.new_version.tag)
                self.assertNotEqual(
                    data.new_version.commit, data.current_version.commit
                )
                self.assertNotEqual(data.new_version.tag, data.current_version.tag)
                self.assertIsNotNone(data.new_version.version)
                self.assertNotEqual(
                    data.new_version.commit, data.current_version.commit
                )
            else:
                self.fail(f"Unknown data {data.filename}")
Exemplo n.º 23
0
    def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = checker.check()

        self.assertEqual(len(ext_data), 4)
        for data in ext_data:
            if data.filename == "ghostscript-9.26.tar.xz":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs[\d]+/ghostscript-[\d.]+.tar.xz$",
                )
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, str)
                self.assertNotEqual(
                    data.new_version.checksum,
                    "90ed475f37584f646e9ef829932b2525d5c6fc2e0147e8d611bc50aa0e718598",
                )
            elif data.filename == "boost_1_74_0.tar.bz2":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://dl\.bintray\.com/boostorg/release/[\d.]+/source/boost_[\d]+_[\d]+_[\d]+.tar.bz2$",
                )
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, str)
                self.assertNotEqual(
                    data.new_version.checksum,
                    "83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1",
                )
            elif data.filename == "flatpak-1.8.2.tar.xz":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://github.com/flatpak/flatpak/releases/download/[\w\d.]+/flatpak-[\w\d.]+.tar.xz$",
                )
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, str)
                self.assertNotEqual(
                    data.new_version.checksum,
                    "7926625df7c2282a5ee1a8b3c317af53d40a663b1bc6b18a2dc8747e265085b0",
                )
            elif data.filename == "ostree.git":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertIsNotNone(data.new_version.commit)
                self.assertIsNotNone(data.new_version.tag)
                self.assertNotEqual(data.new_version.commit,
                                    data.current_version.commit)
                self.assertNotEqual(data.new_version.tag,
                                    data.current_version.tag)
                self.assertIsNotNone(data.new_version.version)
                self.assertNotEqual(data.new_version.commit,
                                    data.current_version.commit)
            else:
                self.fail(f"Unknown data {data.filename}")