def test__get_pair_compatibility_dict_internal_error(self):
        expected_self = {
            'py2': {
                'status': main.BadgeStatus.INTERNAL_ERROR,
                'details': 'NO DETAILS'
            },
            'py3': {
                'status': main.BadgeStatus.INTERNAL_ERROR,
                'details': 'NO DETAILS'
            }
        }
        expected_google = {
            'py2': {
                'status': main.BadgeStatus.INTERNAL_ERROR,
                'details': {}
            },
            'py3': {
                'status': main.BadgeStatus.INTERNAL_ERROR,
                'details': {}
            }
        }
        expected_dep = {
            'status': main.BadgeStatus.INTERNAL_ERROR,
            'details': 'NO DETAILS'
        }

        test = mock.Mock(side_effect=Exception())
        patch_get_self = mock.patch('main._get_self_compatibility_dict', test)
        with patch_get_self:
            results = main._get_check_results('tensorflow')

        self_res, google_res, dep_res = results
        self.assertEqual(self_res, expected_self)
        self.assertEqual(google_res, expected_google)
        self.assertEqual(dep_res, expected_dep)
    def test__get_check_results_unknown(self):
        msg = ('This package is not a whitelisted google python package; to '
               'whitelist a package, contact the python team.')
        expected_self_res = {
            'py2': {
                'status': main.BadgeStatus.UNKNOWN_PACKAGE,
                'details': msg
            },
            'py3': {
                'status': main.BadgeStatus.UNKNOWN_PACKAGE,
                'details': msg
            },
        }
        expected_google_res = {
            'py2': {
                'status': main.BadgeStatus.UNKNOWN_PACKAGE,
                'details': {}
            },
            'py3': {
                'status': main.BadgeStatus.UNKNOWN_PACKAGE,
                'details': {}
            },
        }
        expected_dep_res = {
            'status': main.BadgeStatus.UNKNOWN_PACKAGE,
            'details': {},
        }

        mock_self_res = mock.Mock()
        mock_self_res.return_value = expected_self_res

        mock_google_res = mock.Mock()
        mock_google_res.return_value = expected_google_res

        mock_dep_res = mock.Mock()
        mock_dep_res.return_value = expected_dep_res

        patch_self_res = mock.patch('main._get_self_compatibility_dict',
                                    mock_self_res)
        patch_google_res = mock.patch('main._get_pair_compatibility_dict',
                                      mock_google_res)
        patch_dep_res = mock.patch('main._get_dependency_dict', mock_dep_res)

        with patch_self_res, patch_google_res, patch_dep_res:
            self_res, google_res, dep_res = main._get_check_results(
                'unknown_package')
            status = main._get_badge_status(self_res, google_res, dep_res)

        self.assertEqual(self_res, expected_self_res)
        self.assertEqual(google_res, expected_google_res)
        self.assertEqual(dep_res, expected_dep_res)
        self.assertEqual(status, main.BadgeStatus.UNKNOWN_PACKAGE)
    def test__get_check_results_internal_error(self):
        expected_self_res = {
            'py2': {
                'status': main.BadgeStatus.INTERNAL_ERROR,
                'details': {}
            },
            'py3': {
                'status': main.BadgeStatus.INTERNAL_ERROR,
                'details': {}
            },
        }
        expected_google_res = {
            'py2': {
                'status': main.BadgeStatus.SUCCESS,
                'details': {}
            },
            'py3': {
                'status': main.BadgeStatus.SUCCESS,
                'details': {}
            },
        }
        expected_dep_res = {
            'status': main.BadgeStatus.SUCCESS,
            'details': {},
        }

        mock_self_res = mock.Mock()
        mock_self_res.return_value = expected_self_res

        mock_google_res = mock.Mock()
        mock_google_res.return_value = expected_google_res

        mock_dep_res = mock.Mock()
        mock_dep_res.return_value = expected_dep_res

        patch_self_res = mock.patch('main._get_self_compatibility_dict',
                                    mock_self_res)
        patch_google_res = mock.patch('main._get_pair_compatibility_dict',
                                      mock_google_res)
        patch_dep_res = mock.patch('main._get_dependency_dict', mock_dep_res)

        with patch_self_res, patch_google_res, patch_dep_res:
            self_res, google_res, dep_res = main._get_check_results(
                'opencensus')
            status = main._get_badge_status(self_res, google_res, dep_res)

        self.assertEqual(self_res, expected_self_res)
        self.assertEqual(google_res, expected_google_res)
        self.assertEqual(dep_res, expected_dep_res)
        self.assertEqual(status, main.BadgeStatus.INTERNAL_ERROR)