Test the append_params method
(self)
| 136 | self.assertEqual(cache2.get("hello"), "你好") |
| 137 | |
| 138 | def test_append_params(self): |
| 139 | """Test the append_params method""" |
| 140 | cache_instance = cache.TranslationCache("test_engine", {"initial": "value"}) |
| 141 | |
| 142 | # Test appending new parameter |
| 143 | cache_instance.add_params("new_param", "new_value") |
| 144 | self.assertEqual( |
| 145 | cache_instance.params, {"initial": "value", "new_param": "new_value"} |
| 146 | ) |
| 147 | |
| 148 | # Test that cache with appended params works correctly |
| 149 | cache_instance.set("hello", "你好") |
| 150 | self.assertEqual(cache_instance.get("hello"), "你好") |
| 151 | |
| 152 | # Test overwriting existing parameter |
| 153 | cache_instance.add_params("initial", "new_value") |
| 154 | self.assertEqual( |
| 155 | cache_instance.params, {"initial": "new_value", "new_param": "new_value"} |
| 156 | ) |
| 157 | |
| 158 | # Cache should work with updated params |
| 159 | cache_instance.set("hello2", "你好2") |
| 160 | self.assertEqual(cache_instance.get("hello2"), "你好2") |
| 161 | |
| 162 | # Sometimes the problem of "database is locked" occurs. Temporarily disable this test. |
| 163 | # def test_thread_safety(self): |
nothing calls this directly
no test coverage detected