diff options
author | Mark Haines <mark.haines@matrix.org> | 2016-04-07 16:41:37 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2016-04-07 16:41:37 +0100 |
commit | 57fa1801c336603c6c710d6d868aaae596a7f5b8 (patch) | |
tree | 3a373e073741f4fcff79c51948af0b5d4bd044fe /tests | |
parent | Add tests for get_latest_event_ids_in_room and get_current_state (diff) | |
download | synapse-57fa1801c336603c6c710d6d868aaae596a7f5b8.tar.xz |
Add sensible __eq__ operators inside the tests.
Rather than adding them globally. This limits the changes to only affect the tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/replication/slave/storage/test_events.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/replication/slave/storage/test_events.py b/tests/replication/slave/storage/test_events.py index d5d0ef1148..9af62702b3 100644 --- a/tests/replication/slave/storage/test_events.py +++ b/tests/replication/slave/storage/test_events.py @@ -14,20 +14,47 @@ from ._base import BaseSlavedStoreTestCase -from synapse.events import FrozenEvent +from synapse.events import FrozenEvent, _EventInternalMetadata from synapse.events.snapshot import EventContext from synapse.storage.roommember import RoomsForUser from twisted.internet import defer + USER_ID = "@feeling:blue" USER_ID_2 = "@bright:blue" OUTLIER = {"outlier": True} ROOM_ID = "!room:blue" +def dict_equals(self, other): + return self.__dict__ == other.__dict__ + + +def patch__eq__(cls): + eq = getattr(cls, "__eq__", None) + cls.__eq__ = dict_equals + + def unpatch(): + if eq is not None: + cls.__eq__ = eq + return unpatch + + class SlavedEventStoreTestCase(BaseSlavedStoreTestCase): + def setUp(self): + # Patch up the equality operator for events so that we can check + # whether lists of events match using assertEquals + self.unpatches = [ + patch__eq__(_EventInternalMetadata), + patch__eq__(FrozenEvent), + ] + return super(SlavedEventStoreTestCase, self).setUp() + + def tearDown(self): + [unpatch() for unpatch in self.unpatches] + @defer.inlineCallbacks def test_room_name_and_aliases(self): create = yield self.persist(type="m.room.create", key="", creator=USER_ID) |