kopia lustrzana https://github.com/snarfed/bridgy-fed
disable ndb in-memory cache
it has a bug/weird behavior that we want to avoid, at least for now. https://github.com/googleapis/python-ndb/issues/888 https://github.com/snarfed/bridgy-fed/issues/558pull/561/head
rodzic
c97ee862a5
commit
cba4845394
|
@ -47,7 +47,12 @@ app.url_map.merge_slashes = False
|
|||
app.url_map.redirect_defaults = False
|
||||
|
||||
app.wsgi_app = flask_util.ndb_context_middleware(
|
||||
app.wsgi_app, client=appengine_config.ndb_client)
|
||||
app.wsgi_app, client=appengine_config.ndb_client,
|
||||
# disable in-memory cache
|
||||
# (also in tests/testutil.py)
|
||||
# https://github.com/googleapis/python-ndb/issues/888
|
||||
cache_policy=lambda key: False,
|
||||
)
|
||||
|
||||
cache = Cache(app)
|
||||
|
||||
|
|
|
@ -1124,7 +1124,8 @@ class ActivityPubTest(TestCase):
|
|||
labels=['activity'])
|
||||
|
||||
obj.deleted = True
|
||||
self.assert_entities_equal(obj, protocol.objects_cache['http://an/obj'])
|
||||
self.assert_entities_equal(obj, protocol.objects_cache['http://an/obj'],
|
||||
ignore=['expire', 'created', 'updated'])
|
||||
|
||||
def test_update_note(self, *mocks):
|
||||
Object(id='https://a/note', as2={}).put()
|
||||
|
|
|
@ -116,6 +116,26 @@ class ObjectTest(TestCase):
|
|||
super().setUp()
|
||||
g.user = None
|
||||
|
||||
def test_ndb_in_memory_cache_off(self):
|
||||
"""It has a weird bug that we want to avoid.
|
||||
|
||||
https://github.com/googleapis/python-ndb/issues/888
|
||||
"""
|
||||
from google.cloud.ndb import Model, StringProperty
|
||||
class Foo(Model):
|
||||
a = StringProperty()
|
||||
|
||||
f = Foo(id='x', a='asdf')
|
||||
f.put()
|
||||
# print(id(f))
|
||||
|
||||
f.a = 'qwert'
|
||||
|
||||
got = Foo.get_by_id('x')
|
||||
# print(got)
|
||||
# print(id(got))
|
||||
self.assertEqual('asdf', got.a)
|
||||
|
||||
def test_proxy_url(self):
|
||||
obj = Object(id='abc', source_protocol='bluesky')
|
||||
self.assertEqual('http://localhost/convert/bluesky/web/abc',
|
||||
|
|
|
@ -55,10 +55,10 @@ class PagesTest(TestCase):
|
|||
|
||||
def test_user_web_custom_username_doesnt_redirect(self):
|
||||
"""https://github.com/snarfed/bridgy-fed/issues/534"""
|
||||
self.user.obj = Object(id='a', as2={
|
||||
self.user.obj_key = Object(id='a', as2={
|
||||
**ACTOR_AS2,
|
||||
'url': 'acct:baz@user.com',
|
||||
})
|
||||
}).put()
|
||||
self.user.put()
|
||||
self.assertEqual('baz', self.user.username())
|
||||
|
||||
|
|
|
@ -227,11 +227,13 @@ class ProtocolTest(TestCase):
|
|||
self.assertEqual(['foo'], Fake.fetched)
|
||||
|
||||
def test_load_remote_true_unchanged(self):
|
||||
obj = self.store_object(id='foo', our_as1={'x': 'stored'})
|
||||
obj = self.store_object(id='foo', our_as1={'x': 'stored'},
|
||||
source_protocol='fake')
|
||||
Fake.objects['foo'] = {'x': 'stored'}
|
||||
|
||||
loaded = Fake.load('foo', remote=True)
|
||||
self.assert_entities_equal(obj, loaded)
|
||||
self.assert_entities_equal(obj, loaded,
|
||||
ignore=['expire', 'created', 'updated'])
|
||||
self.assertFalse(loaded.changed)
|
||||
self.assertFalse(loaded.new)
|
||||
self.assertEqual(['foo'], Fake.fetched)
|
||||
|
|
|
@ -199,6 +199,7 @@ class WebfingerTest(TestCase):
|
|||
'acct:notthisuser@boop.org',
|
||||
'acct:customuser@user.com',
|
||||
]
|
||||
self.user.obj.put()
|
||||
self.user.put()
|
||||
|
||||
for resource in (
|
||||
|
|
|
@ -139,7 +139,10 @@ class TestCase(unittest.TestCase, testutil.Asserts):
|
|||
|
||||
# clear datastore
|
||||
requests.post(f'http://{ndb_client.host}/reset')
|
||||
self.ndb_context = ndb_client.context()
|
||||
# disable in-memory cache
|
||||
# (also in flask_app.py)
|
||||
# https://github.com/googleapis/python-ndb/issues/888
|
||||
self.ndb_context = ndb_client.context(cache_policy=lambda key: False)
|
||||
self.ndb_context.__enter__()
|
||||
|
||||
util.now = lambda **kwargs: testutil.NOW
|
||||
|
|
Ładowanie…
Reference in New Issue