from pytest_mock import MockerFixture from documents.caching import CLASSIFIER_VERSION_KEY from documents.caching import get_suggestion_cache from documents.caching import get_suggestion_cache_key from documents.classifier import DocumentClassifier class TestGetSuggestionCache: def test_rejected_entry_is_a_cache_miss(self, mocker: MockerFixture) -> None: """ GIVEN: - A document suggestion entry the cache serializer rejected, which get_many reports as None - A classifier version entry matching the current format WHEN: - The suggestion cache is read THEN: - It is treated as a cache miss """ doc_key = get_suggestion_cache_key(1) mocker.patch( "documents.caching.cache.get_many", return_value={ CLASSIFIER_VERSION_KEY: DocumentClassifier.FORMAT_VERSION, doc_key: None, }, ) assert get_suggestion_cache(1) is None