Esempio n. 1
0
    def test_package(self, name):
        expected = self.expected[name]

        try:
            url = self._get_scm(name)
        except unittest.SkipTest:
            raise
        except Exception:
            if name in self.expected_failures:
                return
            raise

        if name in self.expected_failures:
            return

        self.assertIsNotNone(url)
        self.assertInsensitiveEqual(url, expected)
        if isinstance(expected, str):
            self.assertIn("/", expected, "{} should be {}".format(expected, url))

        normalised_name = normalize(name)
        fetch_list = _fetch_mapping[normalised_name]
        self.assertFalse(fetch_list)

        if normalised_name in missing_repos:
            pass
        elif url.startswith("https://github.com/"):
            slug = url[len("https://github.com/") :]
            rv = self._check_github_repo(slug)

            self.assertTrue(rv)

            try:
                rv = self._check_github_setuppy(slug, normalised_name)
            except GitHubAPIMessage as e:
                raise unittest.SkipTest(str(e))

            if rv is False:
                return
            self.assertTrue(rv)

        else:
            r = web_session.get(url)
            r.raise_for_status()

        if PY2:
            return

        if isinstance(expected, str):
            self.assertGreater(_compute_similarity(name, expected), 0.05)
        else:
            highest = 0
            for i in expected:
                val = _compute_similarity(name, i)
                highest = max(highest, val)
            self.assertGreater(highest, 0.05)
Esempio n. 2
0
    def test_package(self, name):
        expected = self.expected[name]

        url = self._test_package(name)

        if name in self.expected_failures:
            return

        self.assertIsNotNone(url)
        self.assertInsensitiveEqual(url, expected)
        if isinstance(expected, str):
            self.assertIn("/", expected, "{} should be {}".format(expected, url))

        normalised_name = normalize(name)
        fetch_list = _fetch_mapping[normalised_name]

        self.assertTrue(fetch_list)

        if normalised_name in missing_repos:
            pass
        elif url.startswith("https://github.com/"):
            slug = url[len("https://github.com/") :]
            rv = self._check_github_repo(slug)

            self.assertTrue(rv)

            try:
                rv = self._check_github_setuppy(slug, normalised_name)
            except GitHubAPIMessage as e:
                raise unittest.SkipTest(str(e))

            if rv is False:
                return
            self.assertTrue(rv)

        elif url == "https://wiki.mozilla.org/Auto-tools/Projects/Mozbase":
            # Fetching is a bit slow, and failures for moz* are very repetitive
            pass
        else:
            r = web_session.get(url)
            r.raise_for_status()

        if PY2:
            return

        if isinstance(expected, str):
            self.assertGreater(_compute_similarity(name, expected), 0.05)
        else:
            highest = 0
            for i in expected:
                val = _compute_similarity(name, i)
                highest = max(highest, val)
            self.assertGreater(highest, 0.05)
Esempio n. 3
0
    def test_package(self, name):
        expected = self.expected[name]

        url = self._get_scm(name)

        self.assertIsNotNone(url)
        self.assertInsensitiveEqual(url, expected)

        normalised_name = normalize(name)
        fetch_list = _fetch_mapping[normalised_name]
        self.assertTrue(fetch_list)

        if normalised_name in missing_repos:
            pass
        elif url.startswith("https://github.com/"):
            slug = url[len("https://github.com/") :]
            rv = self._check_github_repo(slug)

            self.assertTrue(rv)

            try:
                rv = self._check_github_setuppy(slug, normalised_name)
            except GitHubAPIMessage as e:
                raise unittest.SkipTest(str(e))

            if rv is False:
                return
            self.assertTrue(rv)

        else:
            r = web_session.get(url)
            r.raise_for_status()

        if PY2:
            return

        if isinstance(expected, str):
            self.assertLess(
                _compute_similarity(name, expected),
                0.05,
                "{} - {} should be moved to name mismatches".format(name, expected),
            )
        else:
            for i in expected:
                self.assertLess(
                    _compute_similarity(name, i),
                    0.05,
                    "{} - {} should be moved to name mismatches".format(name, expected),
                )
Esempio n. 4
0
    def test_package(self, name):
        expected = self.expected[name]
        try:
            url = self.converter.get_vcs(name)
        except Exception:
            if name in self.expected_failures:
                return
            raise

        if name in self.expected_failures:
            return

        self.assertIsNotNone(url)
        self.assertInsensitiveEqual(url, expected)

        normalised_name = normalize(name)

        if normalised_name in missing_repos:
            return
        r = web_session.get(url)
        r.raise_for_status()
Esempio n. 5
0
    def _check_result(self, name, url):
        normalised_name = normalize(name)

        r = None
        if normalised_name in missing_repos:
            pass
        elif url.startswith("https://github.com/"):
            slug = url[len("https://github.com/") :]
            rv = self._check_github_repo(slug)

            self.assertTrue(rv)

            try:
                rv = self._check_github_setuppy(slug, normalised_name)
            except GitHubAPIMessage as e:
                raise unittest.SkipTest(str(e))

            if rv is False:
                return
            self.assertTrue(rv)

        else:
            r = web_session.get(url, allow_redirects=False)

        if r is not None:
            r.raise_for_status()
            self.assertEqual(r.url, url)
            location = r.headers.get("location")
            if location:
                self.assertIn(r.status_code, [301, 302])
                location = location.replace(
                    "code.google.com/archive/p/", "code.google.com/p/"
                )
                self.assertIn(location, [url, url + "/"])
            else:
                self.assertEqual(r.status_code, 200)