Ejemplo n.º 1
0
 def get_dependencies_needed_to_update(self) -> Mapping[str, List]:
     """
     Returns a dict of package names together with the dependencies that
     they need to update.
     """
     highlighter = dependency_highlighter.DependencyHighlighter(
         py_version='3', checker=self.checker, store=self.store)
     result = highlighter.check_packages(packages=configs.PKG_LIST,
                                         max_workers=10)
     return result
    def test_check_packages(self):
        packages = ['apache-beam[gcp]', 'not-in-bigquery']
        highlighter = dependency_highlighter.DependencyHighlighter(
            checker=self._checker, store=self._store)
        res = highlighter.check_packages(packages)

        for pkgname, outdated in res.items():
            reprs = [repr(dep) for dep in outdated]
            reprs.sort()

            zipped = zip(self.expected_check_package_res, reprs)
            for expected, got in zipped:
                self.assertEqual(expected, got)
    def test_check_package(self):
        highlighter = dependency_highlighter.DependencyHighlighter(
            checker=self._checker, store=self._store)
        res = highlighter.check_package('apache-beam[gcp]')

        reprs = [repr(dep) for dep in res]
        reprs.sort()

        zipped = zip(self.expected_check_package_res, reprs)
        for expected, got in zipped:
            self.assertEqual(expected, got)

        highlighter = dependency_highlighter.DependencyHighlighter(
            checker=self._checker, store=self._store)
        res = highlighter.check_package('not-in-bigquery')

        reprs = [repr(dep) for dep in res]
        reprs.sort()

        zipped = zip(self.expected_check_package_res, reprs)
        for expected, got in zipped:
            self.assertEqual(expected, got)
    def setup_test__get_update_priority(self):
        low = dependency_highlighter.PriorityLevel.LOW_PRIORITY
        high = dependency_highlighter.PriorityLevel.HIGH_PRIORITY

        not_updated = 'PACKAGE is not up to date with the latest version'

        six_months = ('it has been over 6 months since the latest version '
                      'for PACKAGE was released')

        three_minor = ('PACKAGE is 3 or more minor versions '
                       'behind the latest version')

        thirty_days = ('it has been over 30 days since the major version '
                       'for PACKAGE was released')

        major_version = ('PACKAGE is 1 or more major versions '
                         'behind the latest version')

        highlighter = dependency_highlighter.DependencyHighlighter(
            checker=self._checker, store=self._store)

        def dictify(args):
            major, minor, patch = args
            return {'major': major, 'minor': minor, 'patch': patch}

        def expect(level, msg):
            return dependency_highlighter.Priority(level, msg)

        def run(install_tup, latest_tup, numdays):
            install, latest = dictify(install_tup), dictify(latest_tup)
            res = highlighter._get_update_priority('PACKAGE', install, latest,
                                                   timedelta(days=numdays))
            return res

        cases = [
            (expect(low, not_updated), run((2, 5, 0), (2, 6, 0), 5)),
            (expect(high, six_months), run((2, 5, 0), (2, 6, 0), 200)),
            (expect(high, three_minor), run((2, 5, 0), (2, 8, 0), 13)),
            (expect(low, not_updated), run((2, 5, 0), (3, 0, 0), 29)),
            (expect(high, thirty_days), run((2, 5, 0), (3, 0, 0), 50)),
            (expect(high, major_version), run((2, 5, 0), (3, 0, 4), 1)),
            (expect(high, major_version), run((2, 5, 0), (5, 0, 4), 1)),
        ]

        return cases
Ejemplo n.º 5
0
import pybadges

from compatibility_lib import compatibility_checker
from compatibility_lib import compatibility_store
from compatibility_lib import configs
from compatibility_lib import dependency_highlighter
from compatibility_lib import deprecated_dep_finder

# Initializations
DB_CONNECTION_NAME = 'python-compatibility-tools:us-central1:' \
                     'compatibility-data'
UNIX_SOCKET = '/cloudsql/{}'.format(DB_CONNECTION_NAME)

checker = compatibility_checker.CompatibilityChecker()
store = compatibility_store.CompatibilityStore(mysql_unix_socket=UNIX_SOCKET)
highlighter = dependency_highlighter.DependencyHighlighter(
    checker=checker, store=store)
finder = deprecated_dep_finder.DeprecatedDepFinder(
    checker=checker, store=store)
priority_level = dependency_highlighter.PriorityLevel

TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%S"

URL_PREFIX = 'https://img.shields.io/badge/'
GITHUB_HEAD_NAME = 'github head'
GITHUB_API = 'https://api.github.com/repos'
GITHUB_CACHE_TIME = 1800  # seconds
SVG_CONTENT_TYPE = 'image/svg+xml'
EMPTY_DETAILS = 'NO DETAILS'
PACKAGE_NOT_SUPPORTED = "The package is not supported by checker server."

PY_VER_MAPPING = {