Пример #1
0
    def test_filter_authorized_result(self, mock_is_authorized):
        result = base.SearchResult('rhel', 'Red Hat Enterprise Linux')

        ret = self.backend._filter_result(result)

        self.assertIs(ret, True)
        mock_is_authorized.assert_called_once_with(result.name)
Пример #2
0
    def test_filter_authorized_result_v2(self, mock_v2_is_authorized, mock_v1_authorized):
        result = base.SearchResult('rhel', 'Red Hat Enterprise Linux',
                                   True, True, 8, True)
        mock_v1_authorized.side_effect = exceptions.HTTPError(mock.Mock(status=404), 'not found')
        ret = self.backend._filter_result(result)

        self.assertIs(ret, True)
        mock_v2_is_authorized.assert_called_once_with(result.name)
Пример #3
0
    def test_filter_nonauthorized_result(self, mock_name_authorized, mock_is_authorized):
        result = base.SearchResult('rhel', 'Red Hat Enterprise Linux',
                                   **base.SearchResult.result_defaults)
        mock_is_authorized.side_effect = exceptions.HTTPError(httplib.NOT_FOUND)
        mock_name_authorized.side_effect = exceptions.HTTPError(httplib.NOT_FOUND)
        ret = self.backend._filter_result(result)

        self.assertIs(ret, False)
        mock_is_authorized.assert_called_once_with(result.name)
Пример #4
0
    def test_format_result(self):
        result = base.SearchResult('rhel', 'Red Hat Enterprise Linux')

        ret = self.backend._format_result(result)

        self.assertDictEqual(
            ret, {
                'name': 'rhel',
                'description': 'Red Hat Enterprise Linux',
                'is_trusted': True,
                'is_official': True,
                'star_count': 5,
            })
Пример #5
0
    def test_non_defaults(self):
        result = base.SearchResult('rhel', 'Red Hat Enterprise Linux',
                                   True, True, 8, False)

        ret = self.backend._format_result(result)

        self.assertDictEqual(ret, {
            'name': 'rhel',
            'description': 'Red Hat Enterprise Linux',
            'is_trusted': True,
            'is_official': True,
            'star_count': 8,
            'should_filter': False,
        })