From 18aa302dac0dfe7cb0330e8ea94b1aabe92cb73d Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Sun, 12 Jan 2025 08:11:29 -0800 Subject: [PATCH] temporarily enable ndb context cache for everything for #1149 --- common.py | 12 +++++++----- tests/test_common.py | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common.py b/common.py index 2d0650bd..894c5152 100644 --- a/common.py +++ b/common.py @@ -390,12 +390,14 @@ def cache_policy(key): Returns: bool: whether to cache this object """ - if isinstance(key, Key): - # use internal google.cloud.datastore.key.Key - # https://github.com/googleapis/python-ndb/issues/987 - key = key._key + return True + + # if isinstance(key, Key): + # # use internal google.cloud.datastore.key.Key + # # https://github.com/googleapis/python-ndb/issues/987 + # key = key._key - return key and key.kind == 'Object' and key.name.startswith('did:') + # return key and key.kind == 'Object' and key.name.startswith('did:') def global_cache_policy(key): diff --git a/tests/test_common.py b/tests/test_common.py index 69141707..cb861e99 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,4 +1,5 @@ """Unit tests for common.py.""" +from unittest import skip from unittest.mock import Mock, patch import flask @@ -112,6 +113,7 @@ def test_host_url(self): with app.test_request_context(base_url='https://bsky.brid.gy', path='/foo'): self.assertEqual('https://bsky.brid.gy/asdf', common.host_url('asdf')) + @skip def test_cache_policy(self): for id in 'did:plc:foo', 'did:web:foo': self.assertTrue(common.cache_policy(Object(id=id).key))