Exemple #1
0
 def test_self_compatibility_success(self):
     package_to_results = {
         PACKAGE_1.install_name: [
             compatibility_store.CompatibilityResult(
                 packages=[PACKAGE_1],
                 python_major_version=3,
                 status=compatibility_store.Status.SUCCESS,
             )
         ]
     }
     rh = grid_builder._ResultHolder(package_to_results=package_to_results,
                                     pairwise_to_results={})
     self.assertEqual(
         rh.get_result(PACKAGE_1.install_name, PACKAGE_1.install_name), {
             'status': 'SUCCESS',
             'self': True
         })
Exemple #2
0
    def test_missing_self(self):
        """CompatibilityResult not available for individual packages."""
        packages = [PACKAGE_1, PACKAGE_2]
        store = fake_compatibility_store.CompatibilityStore()
        store.save_compatibility_statuses([
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_1, PACKAGE_2],
                python_major_version=3,
                status=compatibility_store.Status.SUCCESS),
        ])

        with self.patch_finder, self.patch_highlighter:
            package_to_results = store.get_self_compatibilities(packages)
            pairwise_to_results = store.get_compatibility_combinations(
                packages)
            results = dashboard_builder._ResultHolder(package_to_results,
                                                      pairwise_to_results)
            builder = dashboard_builder.DashboardBuilder(packages, results)
            builder.build_dashboard('dashboard/grid-template.html')
Exemple #3
0
 def test_self_compatibility_error(self):
     package_to_results = {
         PACKAGE_1.install_name: [
             compatibility_store.CompatibilityResult(
                 packages=[PACKAGE_1],
                 python_major_version=3,
                 status=compatibility_store.Status.INSTALL_ERROR,
                 details='Installation failure',
             )
         ]
     }
     rh = grid_builder._ResultHolder(package_to_results=package_to_results,
                                     pairwise_to_results={})
     self.assertEqual(
         rh.get_result(PACKAGE_1.install_name, PACKAGE_1.install_name), {
             'status': 'INSTALL_ERROR',
             'details': 'Installation failure',
             'self': True
         })
Exemple #4
0
    def test_save_compatibility_statuses_release_time(self):
        packages = [PACKAGE_1]
        status = compatibility_store.Status.SUCCESS
        comp_status = compatibility_store.CompatibilityResult(
            packages=packages,
            python_major_version='3',
            status=status,
            details=None,
            dependency_info={
                'dep1': {
                    'installed_version': '2.1.0',
                    'installed_version_time': '2018-05-12T16:26:31',
                    'latest_version': '2.1.0',
                    'current_time': '2018-07-13T17:11:29.140608',
                    'latest_version_time': '2018-05-12T16:26:31',
                    'is_latest': True,
                }
            },
            timestamp=None)
        row_release_time = ('package1', 'dep1', '2.1.0', '2018-05-12T16:26:31',
                            '2.1.0', '2018-05-12T16:26:31', True,
                            '2018-07-13T17:11:29.140608')

        mock_pymysql = mock.Mock()
        mock_conn = mock.Mock()
        mock_cursor = mock.Mock()
        mock_pymysql.connect.return_value = mock_conn
        mock_conn.cursor.return_value = mock_cursor
        patch_pymysql = mock.patch(
            'compatibility_lib.compatibility_store.pymysql', mock_pymysql)

        sql = 'REPLACE INTO release_time_for_dependencies values ' \
              '(%s, %s, %s, %s, %s, %s, %s, %s)'

        with patch_pymysql:
            store = compatibility_store.CompatibilityStore()
            store.save_compatibility_statuses([comp_status])

        mock_cursor.executemany.assert_called_with(sql, [row_release_time])
Exemple #5
0
def _result_dict_to_compatibility_result(results, python_version):
    res_list = []

    for item in results:
        res_dict = item[0]
        check_result = res_dict.get('result')
        packages_list = [
            package.Package(pkg) for pkg in res_dict.get('packages')
        ]
        details = res_dict.get('description')
        timestamp = datetime.datetime.now().isoformat()
        dependency_info = res_dict.get('dependency_info')

        compatibility_result = compatibility_store.CompatibilityResult(
            packages=packages_list,
            python_major_version=python_version,
            status=compatibility_store.Status(check_result),
            details=details,
            timestamp=timestamp,
            dependency_info=dependency_info)
        res_list.append(compatibility_result)

    return res_list
Exemple #6
0
    def test_self_compatibility_success(self):
        package_to_results = {
            PACKAGE_1: [
                compatibility_store.CompatibilityResult(
                    packages=[PACKAGE_1],
                    python_major_version=3,
                    status=compatibility_store.Status.SUCCESS,
                )
            ]
        }

        with self.patch_finder, self.patch_highlighter:
            rh = dashboard_builder._ResultHolder(
                package_to_results=package_to_results, pairwise_to_results={})

        expected = {
            'status_type': 'self-success',
            'self_compatibility_check': [{
                'status': 'SUCCESS',
                'self': True
            }],
            'pairwise_compatibility_check': []
        }
        self.assertEqual(rh.get_result(PACKAGE_1, PACKAGE_1), expected)
import datetime
import unittest

from compatibility_lib import compatibility_store
from compatibility_lib import fake_compatibility_store
from compatibility_lib import package

PACKAGE_1 = package.Package("package1")
PACKAGE_2 = package.Package("package2")
PACKAGE_3 = package.Package("package3")
PACKAGE_4 = package.Package("package4")

PACKAGE_1_PY2_CR = compatibility_store.CompatibilityResult(
    packages=[PACKAGE_1],
    python_major_version=2,
    status=compatibility_store.Status.SUCCESS,
)

PACKAGE_1_PY2_OLD_CR = compatibility_store.CompatibilityResult(
    packages=[PACKAGE_1],
    python_major_version=2,
    status=compatibility_store.Status.SUCCESS,
    timestamp=datetime.datetime(2018, 1, 1, tzinfo=datetime.timezone.utc),
)

PACKAGE_1_PY3_CR = compatibility_store.CompatibilityResult(
    packages=[PACKAGE_1],
    python_major_version=3,
    status=compatibility_store.Status.SUCCESS,
)
from compatibility_lib import deprecated_dep_finder_stub
from compatibility_lib import fake_compatibility_store
from compatibility_lib import package

import main
import utils

APACHE_BEAM_RECENT_SUCCESS_2 = compatibility_store.CompatibilityResult(
    [package.Package('apache-beam[gcp]')],
    python_major_version=2,
    status=compatibility_store.Status.SUCCESS,
    dependency_info={
        'apache-beam[gcp]': {
            'current_time': datetime.datetime(2019, 5, 7, 0, 0, 0),
            'installed_version': '2.12.0',
            'installed_version_time': datetime.datetime(
                2019, 2, 19, 21, 15, 56),
            'is_latest': True,
            'latest_version': '2.12.0',
            'latest_version_time': datetime.datetime(
                2019, 2, 19, 21, 15, 56),
        },
    },
    timestamp=datetime.datetime(2019, 5, 7, 0, 0, 0))

APACHE_BEAM_GIT_RECENT_SUCCESS_2 = compatibility_store.CompatibilityResult(
    [package.Package('git+git://github.com/google/apache-beam.git')],
    python_major_version=2,
    status=compatibility_store.Status.SUCCESS,
    dependency_info={
        'apache-beam[gcp]': {
Exemple #9
0
    def test_save_compatibility_statuses_release_time_for_latest_many_packages(
            self):
        status = compatibility_store.Status.SUCCESS
        apache_beam_py2 = compatibility_store.CompatibilityResult(
            packages=[package.Package('apache-beam[gcp]')],
            python_major_version='2',
            status=status,
            details=None,
            dependency_info={
                'six': {
                    'installed_version': '9.9.9',
                    'installed_version_time': '2018-05-12T16:26:31',
                    'latest_version': '2.7.0',
                    'current_time': '2018-07-13T17:11:29.140608',
                    'latest_version_time': '2018-05-12T16:26:31',
                    'is_latest': False,
                },
                'apache-beam': {
                    'installed_version': '2.7.0',
                    'installed_version_time': '2018-05-12T16:26:31',
                    'latest_version': '2.7.0',
                    'current_time': '2018-07-13T17:11:29.140608',
                    'latest_version_time': '2018-05-12T16:26:31',
                    'is_latest': True,
                }
            },
            timestamp=None)
        apache_beam_py3 = compatibility_store.CompatibilityResult(
            packages=[package.Package('apache-beam[gcp]')],
            python_major_version='3',
            status=status,
            details=None,
            dependency_info={
                'apache-beam': {
                    'installed_version': '2.2.0',
                    'installed_version_time': '2018-05-12T16:26:31',
                    'latest_version': '2.7.0',
                    'current_time': '2018-07-13T17:11:29.140608',
                    'latest_version_time': '2018-05-12T16:26:31',
                    'is_latest': False,
                }
            },
            timestamp=None)
        google_api_core_py2 = compatibility_store.CompatibilityResult(
            packages=[package.Package('google-api-core')],
            python_major_version='2',
            status=status,
            details=None,
            dependency_info={
                'google-api-core': {
                    'installed_version': '3.7.0',
                    'installed_version_time': '2018-05-12T16:26:31',
                    'latest_version': '2.7.0',
                    'current_time': '2018-07-13T17:11:29.140608',
                    'latest_version_time': '2018-05-12T16:26:31',
                    'is_latest': True,
                }
            },
            timestamp=None)
        google_api_core_py3 = compatibility_store.CompatibilityResult(
            packages=[package.Package('google-api-core')],
            python_major_version='3',
            status=status,
            details=None,
            dependency_info={
                'google-api-core': {
                    'installed_version': '3.7.1',
                    'installed_version_time': '2018-05-12T16:26:31',
                    'latest_version': '2.7.0',
                    'current_time': '2018-07-13T17:11:29.140608',
                    'latest_version_time': '2018-05-12T16:26:31',
                    'is_latest': False,
                }
            },
            timestamp=None)

        apache_beam_row = ('apache-beam[gcp]', 'apache-beam', '2.7.0',
                           '2018-05-12T16:26:31', '2.7.0',
                           '2018-05-12T16:26:31', True,
                           '2018-07-13T17:11:29.140608')

        six_row = ('apache-beam[gcp]', 'six', '9.9.9', '2018-05-12T16:26:31',
                   '2.7.0', '2018-05-12T16:26:31', False,
                   '2018-07-13T17:11:29.140608')

        google_api_core_row = ('google-api-core', 'google-api-core', '3.7.1',
                               '2018-05-12T16:26:31', '2.7.0',
                               '2018-05-12T16:26:31', False,
                               '2018-07-13T17:11:29.140608')

        mock_pymysql = mock.Mock()
        mock_conn = mock.Mock()
        mock_cursor = mock.Mock()
        mock_pymysql.connect.return_value = mock_conn
        mock_conn.cursor.return_value = mock_cursor
        patch_pymysql = mock.patch(
            'compatibility_lib.compatibility_store.pymysql', mock_pymysql)
        sql = 'REPLACE INTO release_time_for_dependencies values ' \
              '(%s, %s, %s, %s, %s, %s, %s, %s)'

        with patch_pymysql:
            store = compatibility_store.CompatibilityStore()
            store.save_compatibility_statuses([
                apache_beam_py2, apache_beam_py3, google_api_core_py2,
                google_api_core_py3
            ])

        mock_cursor.executemany.assert_called_with(
            sql, [apache_beam_row, six_row, google_api_core_row])
Exemple #10
0
        'latest_version': '1.12.0',
        'latest_version_time': datetime.datetime.utcnow(),
    },
    'six': {
        'current_time': datetime.datetime.utcnow(),
        'installed_version': '1.2.2',
        'installed_version_time': datetime.datetime.utcnow(),
        'is_latest': 1,
        'latest_version': '1.2.2',
        'latest_version_time': datetime.datetime.utcnow(),
    }
}

PACKAGE_1_PY2_CR = compatibility_store.CompatibilityResult(
    packages=[PACKAGE_1],
    python_major_version=2,
    status=compatibility_store.Status.SUCCESS,
)

PACKAGE_1_PY2_OLD_CR = compatibility_store.CompatibilityResult(
    packages=[PACKAGE_1],
    python_major_version=2,
    status=compatibility_store.Status.SUCCESS,
    timestamp=datetime.datetime(2018, 1, 1),
)

PACKAGE_1_PY3_CR = compatibility_store.CompatibilityResult(
    packages=[PACKAGE_1],
    python_major_version=3,
    status=compatibility_store.Status.SUCCESS,
)