From e2bf8c49af958ea14f4e2a2b2987adeeef84c316 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Mon, 12 Sep 2022 23:33:49 -0400 Subject: [PATCH] test_decorators: Remove cachify test cases. cachify has been removed in 9d448e73d2c3b7f2983f239a24e2d45ec9704904. We don't need to keep its tests. TODO: functools.lru_cache can be replaced by functools.cache when we drop Python 3.8. Signed-off-by: Zixuan James Li --- zerver/tests/test_decorators.py | 71 --------------------------------- 1 file changed, 71 deletions(-) diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 1616353562..db75a724c6 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -3,7 +3,6 @@ import os import re import uuid from collections import defaultdict -from functools import lru_cache from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Tuple, Union from unittest import mock, skipUnless @@ -2018,76 +2017,6 @@ class RestAPITest(ZulipTestCase): self.assertTrue(result["Location"].endswith("/login/?next=%2Fjson%2Fusers")) -class CacheTestCase(ZulipTestCase): - def test_cachify_basics(self) -> None: - @lru_cache(maxsize=None) - def add(w: Any, x: Any, y: Any, z: Any) -> Any: - return w + x + y + z - - for i in range(2): - self.assertEqual(add(1, 2, 4, 8), 15) - self.assertEqual(add("a", "b", "c", "d"), "abcd") - - def test_cachify_is_per_call(self) -> None: - def test_greetings(greeting: str) -> Tuple[List[str], List[str]]: - - result_log: List[str] = [] - work_log: List[str] = [] - - @lru_cache(maxsize=None) - def greet(first_name: str, last_name: str) -> str: - msg = f"{greeting} {first_name} {last_name}" - work_log.append(msg) - return msg - - result_log.append(greet("alice", "smith")) - result_log.append(greet("bob", "barker")) - result_log.append(greet("alice", "smith")) - result_log.append(greet("cal", "johnson")) - - return (work_log, result_log) - - work_log, result_log = test_greetings("hello") - self.assertEqual( - work_log, - [ - "hello alice smith", - "hello bob barker", - "hello cal johnson", - ], - ) - - self.assertEqual( - result_log, - [ - "hello alice smith", - "hello bob barker", - "hello alice smith", - "hello cal johnson", - ], - ) - - work_log, result_log = test_greetings("goodbye") - self.assertEqual( - work_log, - [ - "goodbye alice smith", - "goodbye bob barker", - "goodbye cal johnson", - ], - ) - - self.assertEqual( - result_log, - [ - "goodbye alice smith", - "goodbye bob barker", - "goodbye alice smith", - "goodbye cal johnson", - ], - ) - - class TestUserAgentParsing(ZulipTestCase): def test_user_agent_parsing(self) -> None: """Test for our user agent parsing logic, using a large data set."""