diff options
author | H. Shay <hillerys@element.io> | 2023-02-21 14:27:19 -0800 |
---|---|---|
committer | H. Shay <hillerys@element.io> | 2023-02-21 14:27:19 -0800 |
commit | 5cebb3767b6bae73b77d75332010b1b27e0161d4 (patch) | |
tree | 0f63423bf99d16f90ec1359d071676e9ea828cc8 | |
parent | change callsites to reflect new function signature (diff) | |
download | synapse-5cebb3767b6bae73b77d75332010b1b27e0161d4.tar.xz |
update tests to reflect new function signature
-rw-r--r-- | tests/handlers/test_message.py | 20 | ||||
-rw-r--r-- | tests/handlers/test_register.py | 2 | ||||
-rw-r--r-- | tests/handlers/test_user_directory.py | 2 | ||||
-rw-r--r-- | tests/push/test_bulk_push_rule_evaluator.py | 8 | ||||
-rw-r--r-- | tests/rest/admin/test_user.py | 2 | ||||
-rw-r--r-- | tests/storage/test_event_chain.py | 4 | ||||
-rw-r--r-- | tests/storage/test_redaction.py | 12 | ||||
-rw-r--r-- | tests/storage/test_state.py | 2 | ||||
-rw-r--r-- | tests/test_utils/event_injection.py | 1 | ||||
-rw-r--r-- | tests/test_visibility.py | 6 | ||||
-rw-r--r-- | tests/unittest.py | 2 | ||||
-rw-r--r-- | tests/utils.py | 8 |
12 files changed, 37 insertions, 32 deletions
diff --git a/tests/handlers/test_message.py b/tests/handlers/test_message.py index 69d384442f..179c96adf2 100644 --- a/tests/handlers/test_message.py +++ b/tests/handlers/test_message.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -from typing import Tuple +from typing import Optional, Tuple from twisted.test.proto_helpers import MemoryReactor @@ -79,7 +79,9 @@ class EventCreationTestCase(unittest.HomeserverTestCase): return memberEvent, memberEventContext - def _create_duplicate_event(self, txn_id: str) -> Tuple[EventBase, EventContext]: + def _create_duplicate_event( + self, txn_id: str + ) -> Tuple[EventBase, EventContext, Optional[dict]]: """Create a new event with the given transaction ID. All events produced by this method will be considered duplicates. """ @@ -107,7 +109,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase): txn_id = "something_suitably_random" - event1, context = self._create_duplicate_event(txn_id) + event1, context, _ = self._create_duplicate_event(txn_id) ret_event1 = self.get_success( self.handler.handle_new_client_event( @@ -119,7 +121,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase): self.assertEqual(event1.event_id, ret_event1.event_id) - event2, context = self._create_duplicate_event(txn_id) + event2, context, _ = self._create_duplicate_event(txn_id) # We want to test that the deduplication at the persit event end works, # so we want to make sure we test with different events. @@ -140,7 +142,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase): # Let's test that calling `persist_event` directly also does the right # thing. - event3, context = self._create_duplicate_event(txn_id) + event3, context, _ = self._create_duplicate_event(txn_id) self.assertNotEqual(event1.event_id, event3.event_id) ret_event3, event_pos3, _ = self.get_success( @@ -154,7 +156,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase): # Let's test that calling `persist_events` directly also does the right # thing. - event4, context = self._create_duplicate_event(txn_id) + event4, context, _ = self._create_duplicate_event(txn_id) self.assertNotEqual(event1.event_id, event3.event_id) events, _ = self.get_success( @@ -174,8 +176,8 @@ class EventCreationTestCase(unittest.HomeserverTestCase): txn_id = "something_else_suitably_random" # Create two duplicate events to persist at the same time - event1, context1 = self._create_duplicate_event(txn_id) - event2, context2 = self._create_duplicate_event(txn_id) + event1, context1, _ = self._create_duplicate_event(txn_id) + event2, context2, _ = self._create_duplicate_event(txn_id) # Ensure their event IDs are different to start with self.assertNotEqual(event1.event_id, event2.event_id) @@ -200,7 +202,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase): memberEvent, _ = self._create_and_persist_member_event() # Try to create the event with empty prev_events bit with some auth_events - event, _ = self.get_success( + event, _, _ = self.get_success( self.handler.create_event( self.requester, { diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py index 782ef09cf4..ad42a7183e 100644 --- a/tests/handlers/test_register.py +++ b/tests/handlers/test_register.py @@ -507,7 +507,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase): # Lower the permissions of the inviter. event_creation_handler = self.hs.get_event_creation_handler() requester = create_requester(inviter) - event, context = self.get_success( + event, context, _ = self.get_success( event_creation_handler.create_event( requester, { diff --git a/tests/handlers/test_user_directory.py b/tests/handlers/test_user_directory.py index f65a68b9c2..9bb9c1afc6 100644 --- a/tests/handlers/test_user_directory.py +++ b/tests/handlers/test_user_directory.py @@ -957,7 +957,7 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) diff --git a/tests/push/test_bulk_push_rule_evaluator.py b/tests/push/test_bulk_push_rule_evaluator.py index 7567756135..2fe879df47 100644 --- a/tests/push/test_bulk_push_rule_evaluator.py +++ b/tests/push/test_bulk_push_rule_evaluator.py @@ -131,7 +131,7 @@ class TestBulkPushRuleEvaluator(HomeserverTestCase): # Create a new message event, and try to evaluate it under the dodgy # power level event. - event, context = self.get_success( + event, context, _ = self.get_success( self.event_creation_handler.create_event( self.requester, { @@ -171,7 +171,7 @@ class TestBulkPushRuleEvaluator(HomeserverTestCase): """Ensure that push rules are not calculated when disabled in the config""" # Create a new message event which should cause a notification. - event, context = self.get_success( + event, context, _ = self.get_success( self.event_creation_handler.create_event( self.requester, { @@ -201,7 +201,7 @@ class TestBulkPushRuleEvaluator(HomeserverTestCase): ) -> bool: """Returns true iff the `mentions` trigger an event push action.""" # Create a new message event which should cause a notification. - event, context = self.get_success( + event, context, _ = self.get_success( self.event_creation_handler.create_event( self.requester, { @@ -377,7 +377,7 @@ class TestBulkPushRuleEvaluator(HomeserverTestCase): bulk_evaluator = BulkPushRuleEvaluator(self.hs) # Create & persist an event to use as the parent of the relation. - event, context = self.get_success( + event, context, _ = self.get_success( self.event_creation_handler.create_event( self.requester, { diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py index f5b213219f..87efab59bb 100644 --- a/tests/rest/admin/test_user.py +++ b/tests/rest/admin/test_user.py @@ -2935,7 +2935,7 @@ class UserMembershipRestTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( event_creation_handler.create_new_client_event(builder) ) diff --git a/tests/storage/test_event_chain.py b/tests/storage/test_event_chain.py index a10e5fa8b1..8d7310d8e5 100644 --- a/tests/storage/test_event_chain.py +++ b/tests/storage/test_event_chain.py @@ -524,7 +524,7 @@ class EventChainBackgroundUpdateTestCase(HomeserverTestCase): latest_event_ids = self.get_success( self.store.get_prev_events_for_room(room_id) ) - event, context = self.get_success( + event, context, _ = self.get_success( event_handler.create_event( self.requester, { @@ -546,7 +546,7 @@ class EventChainBackgroundUpdateTestCase(HomeserverTestCase): assert state_ids1 is not None state1 = set(state_ids1.values()) - event, context = self.get_success( + event, context, _ = self.get_success( event_handler.create_event( self.requester, { diff --git a/tests/storage/test_redaction.py b/tests/storage/test_redaction.py index 0100f7da14..b8b997f38a 100644 --- a/tests/storage/test_redaction.py +++ b/tests/storage/test_redaction.py @@ -74,7 +74,7 @@ class RedactionTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) @@ -98,7 +98,7 @@ class RedactionTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) @@ -123,7 +123,7 @@ class RedactionTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) @@ -265,7 +265,7 @@ class RedactionTestCase(unittest.HomeserverTestCase): def internal_metadata(self) -> _EventInternalMetadata: return self._base_builder.internal_metadata - event_1, unpersisted_context_1 = self.get_success( + event_1, unpersisted_context_1, _ = self.get_success( self.event_creation_handler.create_new_client_event( cast( EventBuilder, @@ -290,7 +290,7 @@ class RedactionTestCase(unittest.HomeserverTestCase): self.get_success(self._persistence.persist_event(event_1, context_1)) - event_2, unpersisted_context_2 = self.get_success( + event_2, unpersisted_context_2, _ = self.get_success( self.event_creation_handler.create_new_client_event( cast( EventBuilder, @@ -431,7 +431,7 @@ class RedactionTestCase(unittest.HomeserverTestCase): }, ) - redaction_event, unpersisted_context = self.get_success( + redaction_event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) diff --git a/tests/storage/test_state.py b/tests/storage/test_state.py index f730b888f7..333a67e84d 100644 --- a/tests/storage/test_state.py +++ b/tests/storage/test_state.py @@ -67,7 +67,7 @@ class StateStoreTestCase(HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) diff --git a/tests/test_utils/event_injection.py b/tests/test_utils/event_injection.py index a6330ed840..de797992c3 100644 --- a/tests/test_utils/event_injection.py +++ b/tests/test_utils/event_injection.py @@ -95,6 +95,7 @@ async def create_event( ( event, unpersisted_context, + _, ) = await hs.get_event_creation_handler().create_new_client_event( builder, prev_event_ids=prev_event_ids ) diff --git a/tests/test_visibility.py b/tests/test_visibility.py index 2801a950a8..2b6d7048d1 100644 --- a/tests/test_visibility.py +++ b/tests/test_visibility.py @@ -177,7 +177,7 @@ class FilterEventsForServerTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) context = self.get_success(unpersisted_context.persist(event)) @@ -203,7 +203,7 @@ class FilterEventsForServerTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) context = self.get_success(unpersisted_context.persist(event)) @@ -226,7 +226,7 @@ class FilterEventsForServerTestCase(unittest.HomeserverTestCase): }, ) - event, unpersisted_context = self.get_success( + event, unpersisted_context, _ = self.get_success( self.event_creation_handler.create_new_client_event(builder) ) context = self.get_success(unpersisted_context.persist(event)) diff --git a/tests/unittest.py b/tests/unittest.py index c1cb5933fa..2d73911747 100644 --- a/tests/unittest.py +++ b/tests/unittest.py @@ -718,7 +718,7 @@ class HomeserverTestCase(TestCase): event_creator = self.hs.get_event_creation_handler() requester = create_requester(user) - event, context = self.get_success( + event, context, _ = self.get_success( event_creator.create_event( requester, { diff --git a/tests/utils.py b/tests/utils.py index 15fabbc2d0..a22f1d1241 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -335,9 +335,11 @@ async def create_room(hs: HomeServer, room_id: str, creator_id: str) -> None: }, ) - event, unpersisted_context = await event_creation_handler.create_new_client_event( - builder - ) + ( + event, + unpersisted_context, + _, + ) = await event_creation_handler.create_new_client_event(builder) context = await unpersisted_context.persist(event) await persistence_store.persist_event(event, context) |