From 1fa4f7e03e5cdaebeda0f0b4c49120c991f5bf57 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 19 Jul 2018 20:19:32 +0100 Subject: first cut of a UT for testing state store (untested) --- tests/storage/test_state.py | 151 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 tests/storage/test_state.py (limited to 'tests/storage') diff --git a/tests/storage/test_state.py b/tests/storage/test_state.py new file mode 100644 index 0000000000..acf36e077f --- /dev/null +++ b/tests/storage/test_state.py @@ -0,0 +1,151 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from twisted.internet import defer + +from synapse.api.constants import EventTypes, Membership +from synapse.types import RoomID, UserID + +import tests.unittest +import tests.utils + + +class StateStoreTestCase(tests.unittest.TestCase): + def __init__(self, *args, **kwargs): + super(StateStoreTestCase, self).__init__(*args, **kwargs) + self.store = None # type: synapse.storage.DataStore + + @defer.inlineCallbacks + def setUp(self): + hs = yield tests.utils.setup_test_homeserver() + + self.store = hs.get_datastore() + self.event_builder_factory = hs.get_event_builder_factory() + self.event_creation_handler = hs.get_event_creation_handler() + + self.u_alice = UserID.from_string("@alice:test") + self.u_bob = UserID.from_string("@bob:test") + + # User elsewhere on another host + self.u_charlie = UserID.from_string("@charlie:elsewhere") + + self.room = RoomID.from_string("!abc123:test") + + yield self.store.store_room( + self.room.to_string(), + room_creator_user_id="@creator:text", + is_public=True + ) + + @defer.inlineCallbacks + def inject_state_event(self, room, sender, typ, state_key, content): + builder = self.event_builder_factory.new({ + "type": typ, + "sender": sender.to_string(), + "state_key": state_key, + "room_id": room.to_string(), + "content": content, + }) + + event, context = yield self.event_creation_handler.create_new_client_event( + builder + ) + + yield self.store.persist_event(event, context) + + defer.returnValue(event) + + @defer.inlineCallbacks + def test_get_state_for_events(self): + + # this defaults to a linear DAG as each new injection defaults to whatever + # forward extremities are currently in the DB for this room. + (e1, c1) = yield self.inject_state_event( + self.room, self.u_alice, EventTypes.Create, '', {}, + ) + (e2, c2) = yield self.inject_state_event( + self.room, self.u_alice, EventTypes.Name, '', { + "name": "test room" + }, + ) + (e3, c3) = yield self.inject_state_event( + self.room, self.u_alice, EventTypes.Member, self.u_alice, { + "membership": Membership.JOIN + }, + ) + (e4, c4) = yield self.inject_state_event( + self.room, self.u_bob, EventTypes.Member, self.u_bob, { + "membership": Membership.JOIN + }, + ) + (e5, c5) = yield self.inject_state_event( + self.room, self.u_bob, EventTypes.Member, self.u_bob, { + "membership": Membership.LEAVE + }, + ) + + # check we get the full state as of the final event + state = yield self.store.get_state_for_events( + e5.event_id, None, filtered_types=None + ) + + self.assertDictEqual({ + (e1.type, e1.state_key): e1.event_id, + (e2.type, e2.state_key): e2.event_id, + (e3.type, e3.state_key): e3.event_id, + # e4 is overwritten by e5 + (e5.type, e5.state_key): e5.event_id, + }, state) + + # check we can filter to the m.room.name event (with a '' state key) + state = yield self.store.get_state_for_events( + e5.event_id, ((EventTypes.Name, '')), filtered_types=None + ) + + self.assertDictEqual({ + (e2.type, e2.state_key): e2.event_id, + }, state) + + # check we can filter to the m.room.name event (with a wildcard None state key) + state = yield self.store.get_state_for_events( + e5.event_id, ((EventTypes.Name, None)), filtered_types=None + ) + + self.assertDictEqual({ + (e2.type, e2.state_key): e2.event_id, + }, state) + + # check we can grab the m.room.member events (with a wildcard None state key) + state = yield self.store.get_state_for_events( + e5.event_id, ((EventTypes.Member, None)), filtered_types=None + ) + + self.assertDictEqual({ + (e3.type, e3.state_key): e3.event_id, + (e5.type, e5.state_key): e5.event_id, + }, state) + + # check we can use filter_types to grab a specific room member + # without filtering out the other event types + state = yield self.store.get_state_for_events( + e5.event_id, ((EventTypes.Member, self.u_alice)), + filtered_types=[EventTypes.Member], + ) + + self.assertDictEqual({ + (e1.type, e1.state_key): e3.event_id, + (e2.type, e2.state_key): e3.event_id, + (e3.type, e3.state_key): e5.event_id, + }, state) -- cgit 1.4.1 From 650daf56285c515d9c0875a9a3894a033337b0c9 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 19 Jul 2018 20:49:44 +0100 Subject: make test work --- tests/storage/test_state.py | 83 +++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 37 deletions(-) (limited to 'tests/storage') diff --git a/tests/storage/test_state.py b/tests/storage/test_state.py index acf36e077f..8924ba9f7f 100644 --- a/tests/storage/test_state.py +++ b/tests/storage/test_state.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging + from twisted.internet import defer from synapse.api.constants import EventTypes, Membership @@ -21,6 +23,8 @@ from synapse.types import RoomID, UserID import tests.unittest import tests.utils +logger = logging.getLogger(__name__) + class StateStoreTestCase(tests.unittest.TestCase): def __init__(self, *args, **kwargs): @@ -38,9 +42,6 @@ class StateStoreTestCase(tests.unittest.TestCase): self.u_alice = UserID.from_string("@alice:test") self.u_bob = UserID.from_string("@bob:test") - # User elsewhere on another host - self.u_charlie = UserID.from_string("@charlie:elsewhere") - self.room = RoomID.from_string("!abc123:test") yield self.store.store_room( @@ -67,85 +68,93 @@ class StateStoreTestCase(tests.unittest.TestCase): defer.returnValue(event) + def assertStateMapEqual(self, s1, s2): + for t in s1: + # just compare event IDs for simplicity + self.assertEqual(s1[t].event_id, s2[t].event_id) + self.assertEqual(len(s1), len(s2)) + @defer.inlineCallbacks - def test_get_state_for_events(self): + def test_get_state_for_event(self): # this defaults to a linear DAG as each new injection defaults to whatever # forward extremities are currently in the DB for this room. - (e1, c1) = yield self.inject_state_event( + e1 = yield self.inject_state_event( self.room, self.u_alice, EventTypes.Create, '', {}, ) - (e2, c2) = yield self.inject_state_event( + e2 = yield self.inject_state_event( self.room, self.u_alice, EventTypes.Name, '', { "name": "test room" }, ) - (e3, c3) = yield self.inject_state_event( - self.room, self.u_alice, EventTypes.Member, self.u_alice, { + e3 = yield self.inject_state_event( + self.room, self.u_alice, EventTypes.Member, self.u_alice.to_string(), { "membership": Membership.JOIN }, ) - (e4, c4) = yield self.inject_state_event( - self.room, self.u_bob, EventTypes.Member, self.u_bob, { + e4 = yield self.inject_state_event( + self.room, self.u_bob, EventTypes.Member, self.u_bob.to_string(), { "membership": Membership.JOIN }, ) - (e5, c5) = yield self.inject_state_event( - self.room, self.u_bob, EventTypes.Member, self.u_bob, { + e5 = yield self.inject_state_event( + self.room, self.u_bob, EventTypes.Member, self.u_bob.to_string(), { "membership": Membership.LEAVE }, ) # check we get the full state as of the final event - state = yield self.store.get_state_for_events( + state = yield self.store.get_state_for_event( e5.event_id, None, filtered_types=None ) - self.assertDictEqual({ - (e1.type, e1.state_key): e1.event_id, - (e2.type, e2.state_key): e2.event_id, - (e3.type, e3.state_key): e3.event_id, + self.assertIsNotNone(e4) + + self.assertStateMapEqual({ + (e1.type, e1.state_key): e1, + (e2.type, e2.state_key): e2, + (e3.type, e3.state_key): e3, # e4 is overwritten by e5 - (e5.type, e5.state_key): e5.event_id, + (e5.type, e5.state_key): e5, }, state) # check we can filter to the m.room.name event (with a '' state key) - state = yield self.store.get_state_for_events( - e5.event_id, ((EventTypes.Name, '')), filtered_types=None + state = yield self.store.get_state_for_event( + e5.event_id, [(EventTypes.Name, '')], filtered_types=None ) - self.assertDictEqual({ - (e2.type, e2.state_key): e2.event_id, + self.assertStateMapEqual({ + (e2.type, e2.state_key): e2, }, state) # check we can filter to the m.room.name event (with a wildcard None state key) - state = yield self.store.get_state_for_events( - e5.event_id, ((EventTypes.Name, None)), filtered_types=None + state = yield self.store.get_state_for_event( + e5.event_id, [(EventTypes.Name, None)], filtered_types=None ) - self.assertDictEqual({ - (e2.type, e2.state_key): e2.event_id, + self.assertStateMapEqual({ + (e2.type, e2.state_key): e2, }, state) # check we can grab the m.room.member events (with a wildcard None state key) - state = yield self.store.get_state_for_events( - e5.event_id, ((EventTypes.Member, None)), filtered_types=None + state = yield self.store.get_state_for_event( + e5.event_id, [(EventTypes.Member, None)], filtered_types=None ) - self.assertDictEqual({ - (e3.type, e3.state_key): e3.event_id, - (e5.type, e5.state_key): e5.event_id, + self.assertStateMapEqual({ + (e3.type, e3.state_key): e3, + (e5.type, e5.state_key): e5, }, state) # check we can use filter_types to grab a specific room member # without filtering out the other event types - state = yield self.store.get_state_for_events( - e5.event_id, ((EventTypes.Member, self.u_alice)), + state = yield self.store.get_state_for_event( + e5.event_id, [(EventTypes.Member, self.u_alice.to_string())], filtered_types=[EventTypes.Member], ) - self.assertDictEqual({ - (e1.type, e1.state_key): e3.event_id, - (e2.type, e2.state_key): e3.event_id, - (e3.type, e3.state_key): e5.event_id, + self.assertStateMapEqual({ + (e1.type, e1.state_key): e1, + (e2.type, e2.state_key): e2, + (e3.type, e3.state_key): e3, }, state) -- cgit 1.4.1 From cd241d6bda01a761fbe1ca29727dacd918fb8975 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 24 Jul 2018 12:39:40 +0100 Subject: incorporate more review --- synapse/handlers/sync.py | 12 +++++++++--- synapse/storage/state.py | 36 +++++++++--------------------------- tests/storage/test_state.py | 9 +++++++++ 3 files changed, 27 insertions(+), 30 deletions(-) (limited to 'tests/storage') diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 5689ad2f58..e5a2329d73 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -1526,6 +1526,9 @@ def _calculate_state( previous (dict): state at the end of the previous sync (or empty dict if this is an initial sync) current (dict): state at the end of the timeline + lazy_load_members (bool): whether to return members from timeline_start + or not. assumes that timeline_start has already been filtered to + include only the members the client needs to know about. Returns: dict @@ -1545,9 +1548,12 @@ def _calculate_state( p_ids = set(e for e in previous.values()) tc_ids = set(e for e in timeline_contains.values()) - # track the membership events in the state as of the start of the timeline - # so we can add them back in to the state if we're lazyloading. We don't - # add them into state if they're already contained in the timeline. + # If we are lazyloading room members, we explicitly add the membership events + # for the senders in the timeline into the state block returned by /sync, + # as we may not have sent them to the client before. We find these membership + # events by filtering them out of timeline_start, which has already been filtered + # to only include membership events for the senders in the timeline. + if lazy_load_members: ll_ids = set( e for t, e in timeline_start.iteritems() diff --git a/synapse/storage/state.py b/synapse/storage/state.py index f99d3871e4..1413a6f910 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -185,7 +185,7 @@ class StateGroupWorkerStore(SQLBaseStore): }) @defer.inlineCallbacks - def _get_state_groups_from_groups(self, groups, types, filtered_types=None): + def _get_state_groups_from_groups(self, groups, types): """Returns the state groups for a given set of groups, filtering on types of state events. @@ -194,9 +194,6 @@ class StateGroupWorkerStore(SQLBaseStore): types (Iterable[str, str|None]|None): list of 2-tuples of the form (`type`, `state_key`), where a `state_key` of `None` matches all state_keys for the `type`. If None, all types are returned. - filtered_types(Iterable[str]|None): Only apply filtering via `types` to this - list of event types. Other types of events are returned unfiltered. - If None, `types` filtering is applied to all events. Returns: dictionary state_group -> (dict of (type, state_key) -> event id) @@ -207,14 +204,14 @@ class StateGroupWorkerStore(SQLBaseStore): for chunk in chunks: res = yield self.runInteraction( "_get_state_groups_from_groups", - self._get_state_groups_from_groups_txn, chunk, types, filtered_types, + self._get_state_groups_from_groups_txn, chunk, types, ) results.update(res) defer.returnValue(results) def _get_state_groups_from_groups_txn( - self, txn, groups, types=None, filtered_types=None, + self, txn, groups, types=None, ): results = {group: {} for group in groups} @@ -266,17 +263,6 @@ class StateGroupWorkerStore(SQLBaseStore): ) for etype, state_key in types ] - - if filtered_types is not None: - # XXX: check whether this slows postgres down like a list of - # ORs does too? - unique_types = set(filtered_types) - clause_to_args.append( - ( - "AND type <> ? " * len(unique_types), - list(unique_types) - ) - ) else: # If types is None we fetch all the state, and so just use an # empty where clause with no extra args. @@ -306,13 +292,6 @@ class StateGroupWorkerStore(SQLBaseStore): where_clauses.append("(type = ? AND state_key = ?)") where_args.extend([typ[0], typ[1]]) - if filtered_types is not None: - unique_types = set(filtered_types) - where_clauses.append( - "(" + " AND ".join(["type <> ?"] * len(unique_types)) + ")" - ) - where_args.extend(list(unique_types)) - where_clause = "AND (%s)" % (" OR ".join(where_clauses)) else: where_clause = "" @@ -643,13 +622,13 @@ class StateGroupWorkerStore(SQLBaseStore): # cache. Hence, if we are doing a wildcard lookup, populate the # cache fully so that we can do an efficient lookup next time. - if types and any(k is None for (t, k) in types): + if filtered_types or (types and any(k is None for (t, k) in types)): types_to_fetch = None else: types_to_fetch = types group_to_state_dict = yield self._get_state_groups_from_groups( - missing_groups, types_to_fetch, filtered_types + missing_groups, types_to_fetch ) for group, group_state_dict in iteritems(group_to_state_dict): @@ -659,7 +638,10 @@ class StateGroupWorkerStore(SQLBaseStore): if types: for k, v in iteritems(group_state_dict): (typ, _) = k - if k in types or (typ, None) in types: + if ( + (k in types or (typ, None) in types) or + (filtered_types and typ not in filtered_types) + ): state_dict[k] = v else: state_dict.update(group_state_dict) diff --git a/tests/storage/test_state.py b/tests/storage/test_state.py index 8924ba9f7f..b2f314e9db 100644 --- a/tests/storage/test_state.py +++ b/tests/storage/test_state.py @@ -158,3 +158,12 @@ class StateStoreTestCase(tests.unittest.TestCase): (e2.type, e2.state_key): e2, (e3.type, e3.state_key): e3, }, state) + + state = yield self.store.get_state_for_event( + e5.event_id, [], filtered_types=[EventTypes.Member], + ) + + self.assertStateMapEqual({ + (e1.type, e1.state_key): e1, + (e2.type, e2.state_key): e2, + }, state) -- cgit 1.4.1 From 0a7ee0ab8b0794c8633177edca8f839d34c6a42a Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 25 Jul 2018 16:10:34 +0100 Subject: add tests for _get_some_state_from_cache --- tests/storage/test_state.py | 150 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) (limited to 'tests/storage') diff --git a/tests/storage/test_state.py b/tests/storage/test_state.py index b2f314e9db..b7797c45e8 100644 --- a/tests/storage/test_state.py +++ b/tests/storage/test_state.py @@ -159,6 +159,8 @@ class StateStoreTestCase(tests.unittest.TestCase): (e3.type, e3.state_key): e3, }, state) + # check that types=[], filtered_types=[EventTypes.Member] + # doesn't return all members state = yield self.store.get_state_for_event( e5.event_id, [], filtered_types=[EventTypes.Member], ) @@ -167,3 +169,151 @@ class StateStoreTestCase(tests.unittest.TestCase): (e1.type, e1.state_key): e1, (e2.type, e2.state_key): e2, }, state) + + ################################## + # _get_some_state_from_cache tests + ################################## + + room_id = self.room.to_string() + group_ids = yield self.store.get_state_groups_ids(room_id, [e5.event_id]) + group = group_ids.keys()[0] + + # test that _get_some_state_from_cache correctly filters out members with types=[] + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [], filtered_types=[EventTypes.Member] + ) + + self.assertEqual(is_all, True) + self.assertDictEqual({ + (e1.type, e1.state_key): e1.event_id, + (e2.type, e2.state_key): e2.event_id, + }, state_dict) + + # test that _get_some_state_from_cache correctly filters out members with types=wildcard + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [(EventTypes.Member, None)], filtered_types=[EventTypes.Member] + ) + + self.assertEqual(is_all, True) + self.assertDictEqual({ + (e1.type, e1.state_key): e1.event_id, + (e2.type, e2.state_key): e2.event_id, + (e3.type, e3.state_key): e3.event_id, + # e4 is overwritten by e5 + (e5.type, e5.state_key): e5.event_id, + }, state_dict) + + # test that _get_some_state_from_cache correctly filters out members with types=specific + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [(EventTypes.Member, e5.state_key)], filtered_types=[EventTypes.Member] + ) + + self.assertEqual(is_all, True) + self.assertDictEqual({ + (e1.type, e1.state_key): e1.event_id, + (e2.type, e2.state_key): e2.event_id, + (e5.type, e5.state_key): e5.event_id, + }, state_dict) + + # test that _get_some_state_from_cache correctly filters out members with types=specific + # and no filtered_types + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [(EventTypes.Member, e5.state_key)], filtered_types=None + ) + + self.assertEqual(is_all, True) + self.assertDictEqual({ + (e5.type, e5.state_key): e5.event_id, + }, state_dict) + + ####################################################### + # deliberately remove e2 (room name) from the _state_group_cache + + (is_all, known_absent, state_dict_ids) = self.store._state_group_cache.get(group) + + self.assertEqual(is_all, True) + self.assertEqual(known_absent, set()) + self.assertDictEqual(state_dict_ids, { + (e1.type, e1.state_key): e1.event_id, + (e2.type, e2.state_key): e2.event_id, + (e3.type, e3.state_key): e3.event_id, + # e4 is overwritten by e5 + (e5.type, e5.state_key): e5.event_id, + }) + + state_dict_ids.pop((e2.type, e2.state_key)) + self.store._state_group_cache.invalidate(group) + self.store._state_group_cache.update( + sequence=self.store._state_group_cache.sequence, + key=group, + value=state_dict_ids, + # list fetched keys so it knows it's partial + fetched_keys=( + (e1.type, e1.state_key), + (e3.type, e3.state_key), + (e5.type, e5.state_key), + ) + ) + + (is_all, known_absent, state_dict_ids) = self.store._state_group_cache.get(group) + + self.assertEqual(is_all, False) + self.assertEqual(known_absent, set([ + (e1.type, e1.state_key), + (e3.type, e3.state_key), + (e5.type, e5.state_key), + ])) + self.assertDictEqual(state_dict_ids, { + (e1.type, e1.state_key): e1.event_id, + (e3.type, e3.state_key): e3.event_id, + (e5.type, e5.state_key): e5.event_id, + }) + + ################################################### + # test that things work with a partial cache + + # test that _get_some_state_from_cache correctly filters out members with types=[] + room_id = self.room.to_string() + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [], filtered_types=[EventTypes.Member] + ) + + self.assertEqual(is_all, False) + self.assertDictEqual({ + (e1.type, e1.state_key): e1.event_id, + }, state_dict) + + # test that _get_some_state_from_cache correctly filters out members with types=wildcard + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [(EventTypes.Member, None)], filtered_types=[EventTypes.Member] + ) + + self.assertEqual(is_all, False) + self.assertDictEqual({ + (e1.type, e1.state_key): e1.event_id, + (e3.type, e3.state_key): e3.event_id, + # e4 is overwritten by e5 + (e5.type, e5.state_key): e5.event_id, + }, state_dict) + + # test that _get_some_state_from_cache correctly filters out members with types=specific + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [(EventTypes.Member, e5.state_key)], filtered_types=[EventTypes.Member] + ) + + self.assertEqual(is_all, False) + self.assertDictEqual({ + (e1.type, e1.state_key): e1.event_id, + (e5.type, e5.state_key): e5.event_id, + }, state_dict) + + # test that _get_some_state_from_cache correctly filters out members with types=specific + # and no filtered_types + (state_dict, is_all) = yield self.store._get_some_state_from_cache( + group, [(EventTypes.Member, e5.state_key)], filtered_types=None + ) + + self.assertEqual(is_all, True) + self.assertDictEqual({ + (e5.type, e5.state_key): e5.event_id, + }, state_dict) -- cgit 1.4.1 From 0620d27f4d4a7f5c228c519b489efc8bc0c0a7d0 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 25 Jul 2018 17:21:17 +0100 Subject: flake8 --- tests/storage/test_state.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/storage') diff --git a/tests/storage/test_state.py b/tests/storage/test_state.py index b7797c45e8..7a76d67b8c 100644 --- a/tests/storage/test_state.py +++ b/tests/storage/test_state.py @@ -170,15 +170,15 @@ class StateStoreTestCase(tests.unittest.TestCase): (e2.type, e2.state_key): e2, }, state) - ################################## - # _get_some_state_from_cache tests - ################################## + ####################################################### + # _get_some_state_from_cache tests against a full cache + ####################################################### room_id = self.room.to_string() group_ids = yield self.store.get_state_groups_ids(room_id, [e5.event_id]) group = group_ids.keys()[0] - # test that _get_some_state_from_cache correctly filters out members with types=[] + # test _get_some_state_from_cache correctly filters out members with types=[] (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [], filtered_types=[EventTypes.Member] ) @@ -189,7 +189,7 @@ class StateStoreTestCase(tests.unittest.TestCase): (e2.type, e2.state_key): e2.event_id, }, state_dict) - # test that _get_some_state_from_cache correctly filters out members with types=wildcard + # test _get_some_state_from_cache correctly filters in members with wildcard types (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [(EventTypes.Member, None)], filtered_types=[EventTypes.Member] ) @@ -203,7 +203,7 @@ class StateStoreTestCase(tests.unittest.TestCase): (e5.type, e5.state_key): e5.event_id, }, state_dict) - # test that _get_some_state_from_cache correctly filters out members with types=specific + # test _get_some_state_from_cache correctly filters in members with specific types (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [(EventTypes.Member, e5.state_key)], filtered_types=[EventTypes.Member] ) @@ -215,7 +215,7 @@ class StateStoreTestCase(tests.unittest.TestCase): (e5.type, e5.state_key): e5.event_id, }, state_dict) - # test that _get_some_state_from_cache correctly filters out members with types=specific + # test _get_some_state_from_cache correctly filters in members with specific types # and no filtered_types (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [(EventTypes.Member, e5.state_key)], filtered_types=None @@ -269,10 +269,10 @@ class StateStoreTestCase(tests.unittest.TestCase): (e5.type, e5.state_key): e5.event_id, }) - ################################################### + ############################################ # test that things work with a partial cache - # test that _get_some_state_from_cache correctly filters out members with types=[] + # test _get_some_state_from_cache correctly filters out members with types=[] room_id = self.room.to_string() (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [], filtered_types=[EventTypes.Member] @@ -283,7 +283,7 @@ class StateStoreTestCase(tests.unittest.TestCase): (e1.type, e1.state_key): e1.event_id, }, state_dict) - # test that _get_some_state_from_cache correctly filters out members with types=wildcard + # test _get_some_state_from_cache correctly filters in members wildcard types (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [(EventTypes.Member, None)], filtered_types=[EventTypes.Member] ) @@ -296,7 +296,7 @@ class StateStoreTestCase(tests.unittest.TestCase): (e5.type, e5.state_key): e5.event_id, }, state_dict) - # test that _get_some_state_from_cache correctly filters out members with types=specific + # test _get_some_state_from_cache correctly filters in members with specific types (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [(EventTypes.Member, e5.state_key)], filtered_types=[EventTypes.Member] ) @@ -307,7 +307,7 @@ class StateStoreTestCase(tests.unittest.TestCase): (e5.type, e5.state_key): e5.event_id, }, state_dict) - # test that _get_some_state_from_cache correctly filters out members with types=specific + # test _get_some_state_from_cache correctly filters in members with specific types # and no filtered_types (state_dict, is_all) = yield self.store._get_some_state_from_cache( group, [(EventTypes.Member, e5.state_key)], filtered_types=None -- cgit 1.4.1