Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_mimetype.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import unittest | import unittest | ||||
import logging | import logging | ||||
from unittest.mock import patch | from unittest.mock import patch | ||||
from swh.indexer.mimetype import ( | from swh.indexer.mimetype import ( | ||||
ContentMimetypeIndexer, MimetypeRangeIndexer, compute_mimetype_encoding | MimetypeIndexer, MimetypeRangeIndexer, compute_mimetype_encoding | ||||
) | ) | ||||
from swh.indexer.tests.test_utils import ( | from swh.indexer.tests.test_utils import ( | ||||
MockObjStorage, BasicMockStorage, BasicMockIndexerStorage, | MockObjStorage, BasicMockStorage, BasicMockIndexerStorage, | ||||
CommonContentIndexerTest, CommonContentIndexerRangeTest, | CommonContentIndexerTest, CommonContentIndexerRangeTest, | ||||
CommonIndexerWithErrorsTest, CommonIndexerNoTool, | CommonIndexerWithErrorsTest, CommonIndexerNoTool, | ||||
BASE_TEST_CONFIG | BASE_TEST_CONFIG | ||||
) | ) | ||||
Show All 17 Lines | def test_compute_mimetype_encoding(self, mock_magic): | ||||
actual_result = compute_mimetype_encoding(_input) | actual_result = compute_mimetype_encoding(_input) | ||||
self.assertEqual(actual_result, { | self.assertEqual(actual_result, { | ||||
'mimetype': _mimetype, | 'mimetype': _mimetype, | ||||
'encoding': _encoding | 'encoding': _encoding | ||||
}) | }) | ||||
class MimetypeTestIndexer(ContentMimetypeIndexer): | class MimetypeTestIndexer(MimetypeIndexer): | ||||
"""Specific mimetype indexer instance whose configuration is enough to | """Specific mimetype indexer instance whose configuration is enough to | ||||
satisfy the indexing tests. | satisfy the indexing tests. | ||||
""" | """ | ||||
def parse_config_file(self, *args, **kwargs): | def parse_config_file(self, *args, **kwargs): | ||||
return { | return { | ||||
**BASE_TEST_CONFIG, | **BASE_TEST_CONFIG, | ||||
'tools': { | 'tools': { | ||||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |