mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 01:30:20 +00:00
Merge pull request #3172 from matrix-org/rav/fix_test_logcontext_leaks
Fix a couple of logcontext leaks in unit tests
This commit is contained in:
commit
4e9bdeba57
2 changed files with 9 additions and 3 deletions
|
@ -17,6 +17,8 @@ from synapse.appservice.scheduler import (
|
||||||
_ServiceQueuer, _TransactionController, _Recoverer
|
_ServiceQueuer, _TransactionController, _Recoverer
|
||||||
)
|
)
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
|
from synapse.util.logcontext import make_deferred_yieldable
|
||||||
from ..utils import MockClock
|
from ..utils import MockClock
|
||||||
from mock import Mock
|
from mock import Mock
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
|
@ -204,7 +206,9 @@ class ApplicationServiceSchedulerQueuerTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_send_single_event_with_queue(self):
|
def test_send_single_event_with_queue(self):
|
||||||
d = defer.Deferred()
|
d = defer.Deferred()
|
||||||
self.txn_ctrl.send = Mock(return_value=d)
|
self.txn_ctrl.send = Mock(
|
||||||
|
side_effect=lambda x, y: make_deferred_yieldable(d),
|
||||||
|
)
|
||||||
service = Mock(id=4)
|
service = Mock(id=4)
|
||||||
event = Mock(event_id="first")
|
event = Mock(event_id="first")
|
||||||
event2 = Mock(event_id="second")
|
event2 = Mock(event_id="second")
|
||||||
|
@ -235,7 +239,10 @@ class ApplicationServiceSchedulerQueuerTestCase(unittest.TestCase):
|
||||||
srv_2_event2 = Mock(event_id="srv2b")
|
srv_2_event2 = Mock(event_id="srv2b")
|
||||||
|
|
||||||
send_return_list = [srv_1_defer, srv_2_defer]
|
send_return_list = [srv_1_defer, srv_2_defer]
|
||||||
self.txn_ctrl.send = Mock(side_effect=lambda x, y: send_return_list.pop(0))
|
|
||||||
|
def do_send(x, y):
|
||||||
|
return make_deferred_yieldable(send_return_list.pop(0))
|
||||||
|
self.txn_ctrl.send = Mock(side_effect=do_send)
|
||||||
|
|
||||||
# send events for different ASes and make sure they are sent
|
# send events for different ASes and make sure they are sent
|
||||||
self.queuer.enqueue(srv1, srv_1_event)
|
self.queuer.enqueue(srv1, srv_1_event)
|
||||||
|
|
|
@ -128,7 +128,6 @@ class EventPushActionsStoreTestCase(tests.unittest.TestCase):
|
||||||
yield _rotate(10)
|
yield _rotate(10)
|
||||||
yield _assert_counts(1, 1)
|
yield _assert_counts(1, 1)
|
||||||
|
|
||||||
@tests.unittest.DEBUG
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_find_first_stream_ordering_after_ts(self):
|
def test_find_first_stream_ordering_after_ts(self):
|
||||||
def add_event(so, ts):
|
def add_event(so, ts):
|
||||||
|
|
Loading…
Reference in a new issue