kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
2437a16b1e
commit
18aa302dac
12
common.py
12
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
|
||||
|
||||
return key and key.kind == 'Object' and key.name.startswith('did:')
|
||||
# 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:')
|
||||
|
||||
|
||||
def global_cache_policy(key):
|
||||
|
|
|
@ -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 @@ class CommonTest(TestCase):
|
|||
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))
|
||||
|
|
Ładowanie…
Reference in New Issue