|
10 | 10 | log = logging.getLogger("ctu-test") |
11 | 11 | # log.setLevel(logging.DEBUG) |
12 | 12 |
|
| 13 | +SECRET = b"incredible secret key for testing encrypted cache..." |
13 | 14 |
|
14 | 15 | def has_service(host="localhost", port=22): |
15 | 16 | """check whether a network TCP/IP service is available.""" |
@@ -233,14 +234,15 @@ def test_redis(): |
233 | 234 |
|
234 | 235 | c0 = redis.Redis(host="localhost") |
235 | 236 | c1 = ctu.RedisCache(c0) |
236 | | - c2 = ctu.LockedCache(c1, threading.RLock()) |
237 | | - run_cached(c2) |
238 | | - assert len(c2) >= 50 |
239 | | - assert c2[(1, "a", True)] == 111 |
240 | | - assert c2[(3, None, False)] == -17 |
241 | | - setgetdel(c2) |
| 237 | + c2 = ctu.EncryptedCache(c1, SECRET) |
| 238 | + c3 = ctu.LockedCache(c2, threading.RLock()) |
| 239 | + run_cached(c3) |
| 240 | + assert len(c3) >= 50 |
| 241 | + assert c3[(1, "a", True)] == 111 |
| 242 | + assert c3[(3, None, False)] == -17 |
| 243 | + setgetdel(c3) |
242 | 244 | try: |
243 | | - c2.__iter__() |
| 245 | + c3.__iter__() |
244 | 246 | pytest.fail("not supported") |
245 | 247 | except Exception as e: |
246 | 248 | assert "not implemented yet" in str(e) |
@@ -546,7 +548,6 @@ def test_cache_key(): |
546 | 548 |
|
547 | 549 |
|
548 | 550 | def test_encrypted_cache(): |
549 | | - SECRET = b"incredible secret key for testing encrypted cache..." |
550 | 551 | # bytes |
551 | 552 | cache = ctu.EncryptedCache(ctu.DictCache(), SECRET) |
552 | 553 | cache[b"Hello"] = b"World!" |
|
0 commit comments