From d55e54dd88e86ff99d8703ff67e238ab37a3d5d9 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:21:55 +1100 Subject: [PATCH 01/16] add an info decorator --- tests/unittest.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unittest.py b/tests/unittest.py index a59291cc6010..4d40bdb6a553 100644 --- a/tests/unittest.py +++ b/tests/unittest.py @@ -146,6 +146,13 @@ def DEBUG(target): return target +def INFO(target): + """A decorator to set the .loglevel attribute to logging.INFO. + Can apply to either a TestCase or an individual test method.""" + target.loglevel = logging.INFO + return target + + class HomeserverTestCase(TestCase): """ A base TestCase that reduces boilerplate for HomeServer-using test cases. @@ -373,5 +380,5 @@ def login(self, username, password, device_id=None): self.render(request) self.assertEqual(channel.code, 200) - access_token = channel.json_body["access_token"].encode('ascii') + access_token = channel.json_body["access_token"] return access_token From edf43313bb63ebd9a1d6b8a4c4a075494461c45e Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:22:15 +1100 Subject: [PATCH 02/16] some py3 fixes --- synapse/push/mailer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py index 16fb5e847160..25981cebae7c 100644 --- a/synapse/push/mailer.py +++ b/synapse/push/mailer.py @@ -191,11 +191,11 @@ def _fetch_room_state(room_id): multipart_msg.attach(html_part) logger.info("Sending email push notification to %s" % email_address) - # logger.debug(html_text) yield sendmail( self.hs.config.email_smtp_host, - raw_from, raw_to, multipart_msg.as_string(), + raw_from, raw_to, multipart_msg.as_string().encode('utf8'), + reactor=self.hs.get_reactor(), port=self.hs.config.email_smtp_port, requireAuthentication=self.hs.config.email_smtp_user is not None, username=self.hs.config.email_smtp_user, @@ -333,7 +333,7 @@ def make_summary_text(self, notifs_by_room, room_state_ids, notif_events, user_id, reason): if len(notifs_by_room) == 1: # Only one room has new stuff - room_id = notifs_by_room.keys()[0] + room_id = list(notifs_by_room.keys())[0] # If the room has some kind of name, use it, but we don't # want the generated-from-names one here otherwise we'll From 8fdf80839a9ac4197f25e773b885366a10c5eae8 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:23:57 +1100 Subject: [PATCH 03/16] another py3 fix --- synapse/push/emailpusher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/synapse/push/emailpusher.py b/synapse/push/emailpusher.py index f369124258ee..50e1007d849a 100644 --- a/synapse/push/emailpusher.py +++ b/synapse/push/emailpusher.py @@ -85,7 +85,10 @@ def on_stop(self): self.timed_call = None def on_new_notifications(self, min_stream_ordering, max_stream_ordering): - self.max_stream_ordering = max(max_stream_ordering, self.max_stream_ordering) + if self.max_stream_ordering: + self.max_stream_ordering = max(max_stream_ordering, self.max_stream_ordering) + else: + self.max_stream_ordering = max_stream_ordering self._start_processing() def on_new_receipts(self, min_stream_id, max_stream_id): From 42ca2474527b8367a41e44efa8feb3a1a6532b0c Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:24:07 +1100 Subject: [PATCH 04/16] some initial tests of the email pusher --- tests/push/__init__.py | 0 tests/push/test_email.py | 113 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 tests/push/__init__.py create mode 100644 tests/push/test_email.py diff --git a/tests/push/__init__.py b/tests/push/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/push/test_email.py b/tests/push/test_email.py new file mode 100644 index 000000000000..ec5815260e8c --- /dev/null +++ b/tests/push/test_email.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 New Vector +# +# 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. + +import os + +import pkg_resources + +from twisted.test.proto_helpers import AccumulatingProtocol + +from synapse.rest.client.v1 import admin, login, room + +from tests.server import FakeTransport +from tests.unittest import INFO, HomeserverTestCase + + +@INFO +class EmailPusherTests(HomeserverTestCase): + + servlets = [ + admin.register_servlets, + room.register_servlets, + login.register_servlets, + ] + user_id = True + hijack_auth = False + + def make_homeserver(self, reactor, clock): + + config = self.default_config() + config.email_enable_notifs = True + config.start_pushers = True + + config.email_template_dir = os.path.abspath( + pkg_resources.resource_filename('synapse', 'res/templates') + ) + config.email_notif_template_html = "notif_mail.html" + config.email_notif_template_text = "notif_mail.txt" + config.email_smtp_host = "127.0.0.1" + config.email_smtp_port = 20 + config.require_transport_security = False + config.email_smtp_user = None + config.email_app_name = "Matrix" + config.email_notif_from = "test@example.com" + + hs = self.setup_test_homeserver(config=config) + + return hs + + def test_sends_email(self): + # Register the user who gets notified + user_id = self.register_user("user", "pass") + access_token = self.login("user", "pass") + + # Register the user who sends the message + other_user_id = self.register_user("otheruser", "pass") + other_access_token = self.login("otheruser", "pass") + + # Register the pusher + user_tuple = self.get_success( + self.hs.get_datastore().get_user_by_access_token(access_token) + ) + token_id = user_tuple["token_id"] + + self.get_success( + self.hs.get_pusherpool().add_pusher( + user_id=user_id, + access_token=token_id, + kind="email", + app_id="m.email", + app_display_name="Email Notifications", + device_display_name="a@example.com", + pushkey="a@example.com", + lang=None, + data={}, + ) + ) + + # Create a room + room = self.helper.create_room_as(user_id, tok=access_token) + + # Invite the other person + self.helper.invite(room=room, src=user_id, tok=access_token, targ=other_user_id) + + # The other user joins + self.helper.join(room=room, user=other_user_id, tok=other_access_token) + + # The other user sends some messages + self.helper.send(room, body="Hi!", tok=other_access_token) + self.helper.send(room, body="There!", tok=other_access_token) + + # Advance time a bit, so the pusher will register + self.pump(100) + + # It then tries to send the email. + self.assertEqual(len(self.reactor.tcpClients), 1) + + mailer = self.reactor.tcpClients[0][2] + + print(mailer.fromEmail) + print(mailer.toEmail) + print(mailer.file.read()) From 6d748864d25b8fd8975653c836893351ff285612 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:26:34 +1100 Subject: [PATCH 05/16] changelog --- changelog.d/4095.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4095.bugfix diff --git a/changelog.d/4095.bugfix b/changelog.d/4095.bugfix new file mode 100644 index 000000000000..76ee7148c272 --- /dev/null +++ b/changelog.d/4095.bugfix @@ -0,0 +1 @@ +Fix exceptions when using the email mailer on Python 3. From 858cd1a21a184c4341569919e201cac725594a9d Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:28:13 +1100 Subject: [PATCH 06/16] some cleanups --- tests/push/test_email.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/push/test_email.py b/tests/push/test_email.py index ec5815260e8c..d855a6f620db 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -22,10 +22,9 @@ from synapse.rest.client.v1 import admin, login, room from tests.server import FakeTransport -from tests.unittest import INFO, HomeserverTestCase +from tests.unittest import HomeserverTestCase -@INFO class EmailPusherTests(HomeserverTestCase): servlets = [ @@ -105,9 +104,3 @@ def test_sends_email(self): # It then tries to send the email. self.assertEqual(len(self.reactor.tcpClients), 1) - - mailer = self.reactor.tcpClients[0][2] - - print(mailer.fromEmail) - print(mailer.toEmail) - print(mailer.file.read()) From 7f1abc27c2458f67651a985c4cde869efe497c2b Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:28:44 +1100 Subject: [PATCH 07/16] sneaky travis speedups --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd41841c77cd..9628db2dc569 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,10 +33,10 @@ matrix: env: TOX_ENV="pep8,check_isort" - python: 2.7 - env: TOX_ENV=py27 + env: TOX_ENV=py27 TRIAL_FLAGS="-j 4" - python: 2.7 - env: TOX_ENV=py27-old + env: TOX_ENV=py27-old TRIAL_FLAGS="-j 4" - python: 2.7 env: TOX_ENV=py27-postgres TRIAL_FLAGS="-j 4" @@ -44,10 +44,10 @@ matrix: - postgresql - python: 3.5 - env: TOX_ENV=py35 + env: TOX_ENV=py35 TRIAL_FLAGS="-j 4" - python: 3.6 - env: TOX_ENV=py36 + env: TOX_ENV=py36 TRIAL_FLAGS="-j 4" - python: 3.6 env: TOX_ENV=py36-postgres TRIAL_FLAGS="-j 4" From 35b5f320f695d69d0fb56b743f85c9b73cec0409 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:41:14 +1100 Subject: [PATCH 08/16] fix tests --- tests/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/server.py b/tests/server.py index 7bee58dff162..819c854448e2 100644 --- a/tests/server.py +++ b/tests/server.py @@ -125,7 +125,9 @@ def make_request(method, path, content=b"", access_token=None, request=SynapseRe req.content = BytesIO(content) if access_token: - req.requestHeaders.addRawHeader(b"Authorization", b"Bearer " + access_token) + req.requestHeaders.addRawHeader( + b"Authorization", b"Bearer " + access_token.encode('ascii') + ) if content: req.requestHeaders.addRawHeader(b"Content-Type", b"application/json") From 477d2ad9349f70643dff6ba524a724ee386c5dda Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:41:21 +1100 Subject: [PATCH 09/16] fix pep8 --- tests/push/test_email.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/push/test_email.py b/tests/push/test_email.py index d855a6f620db..1e7bfa455bc9 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -17,11 +17,8 @@ import pkg_resources -from twisted.test.proto_helpers import AccumulatingProtocol - from synapse.rest.client.v1 import admin, login, room -from tests.server import FakeTransport from tests.unittest import HomeserverTestCase From a5c75020c45563eb6b41d6c243b18ba1be9dc351 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:41:32 +1100 Subject: [PATCH 10/16] see if -j2 makes it faster --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9628db2dc569..560b57f19c04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,10 +33,10 @@ matrix: env: TOX_ENV="pep8,check_isort" - python: 2.7 - env: TOX_ENV=py27 TRIAL_FLAGS="-j 4" + env: TOX_ENV=py27 TRIAL_FLAGS="-j 2" - python: 2.7 - env: TOX_ENV=py27-old TRIAL_FLAGS="-j 4" + env: TOX_ENV=py27-old TRIAL_FLAGS="-j 2" - python: 2.7 env: TOX_ENV=py27-postgres TRIAL_FLAGS="-j 4" @@ -44,10 +44,10 @@ matrix: - postgresql - python: 3.5 - env: TOX_ENV=py35 TRIAL_FLAGS="-j 4" + env: TOX_ENV=py35 TRIAL_FLAGS="-j 2" - python: 3.6 - env: TOX_ENV=py36 TRIAL_FLAGS="-j 4" + env: TOX_ENV=py36 TRIAL_FLAGS="-j 2" - python: 3.6 env: TOX_ENV=py36-postgres TRIAL_FLAGS="-j 4" From 07b41711fbaba149a3399682b379586e2c68d17c Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:44:02 +1100 Subject: [PATCH 11/16] try and fix tests if we don't have jinja --- tests/push/test_email.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/push/test_email.py b/tests/push/test_email.py index 1e7bfa455bc9..f2f243c1aa82 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -21,9 +21,15 @@ from tests.unittest import HomeserverTestCase +try: + from synapse.push.mailer import load_jinja2_templates +except Exception: + load_jinja2_templates = None + class EmailPusherTests(HomeserverTestCase): + skip = "No Jinja installed" if not load_jinja2_templates else None servlets = [ admin.register_servlets, room.register_servlets, From c99c6a94fb6c08529fa0637a11f9fca7b094e480 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sat, 27 Oct 2018 00:58:58 +1100 Subject: [PATCH 12/16] fix --- tests/test_mau.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mau.py b/tests/test_mau.py index bdbacb844848..5d387851c537 100644 --- a/tests/test_mau.py +++ b/tests/test_mau.py @@ -207,7 +207,7 @@ def create_user(self, localpart): def do_sync_for_user(self, token): request, channel = make_request( - "GET", "/sync", access_token=token.encode('ascii') + "GET", "/sync", access_token=token ) render(request, self.resource, self.reactor) From e2ce1f1f3c175586d28ea16adb3fb9002240dd24 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 30 Oct 2018 01:48:54 +1100 Subject: [PATCH 13/16] inject sendmail and test using that, also test what happens when it succeeds --- synapse/push/mailer.py | 3 +-- synapse/server.py | 7 ++++++ tests/push/test_email.py | 46 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py index 25981cebae7c..a5f463b28478 100644 --- a/synapse/push/mailer.py +++ b/synapse/push/mailer.py @@ -26,7 +26,6 @@ import jinja2 from twisted.internet import defer -from twisted.mail.smtp import sendmail from synapse.api.constants import EventTypes from synapse.api.errors import StoreError @@ -192,7 +191,7 @@ def _fetch_room_state(room_id): logger.info("Sending email push notification to %s" % email_address) - yield sendmail( + yield self.hs.get_sendmail()( self.hs.config.email_smtp_host, raw_from, raw_to, multipart_msg.as_string().encode('utf8'), reactor=self.hs.get_reactor(), diff --git a/synapse/server.py b/synapse/server.py index cf6b872cbd70..2b2d017e009f 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -216,6 +216,13 @@ def get_reactor(self): """ return self._reactor + def get_sendmail(self): + if hasattr(self, "_sendmail"): + return self._sendmail + else: + from twisted.mail.smtp import sendmail + return sendmail + def get_ip_from_request(self, request): # X-Forwarded-For is handled by our custom request type. return request.getClientIP() diff --git a/tests/push/test_email.py b/tests/push/test_email.py index f2f243c1aa82..50df1d44decc 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -18,6 +18,7 @@ import pkg_resources from synapse.rest.client.v1 import admin, login, room +from twisted.internet.defer import Deferred from tests.unittest import HomeserverTestCase @@ -61,6 +62,17 @@ def make_homeserver(self, reactor, clock): return hs def test_sends_email(self): + + # List[Tuple[Deferred, args, kwargs]] + email_attempts = [] + + def sendmail(*args, **kwargs): + d = Deferred() + email_attempts.append((d, args, kwargs)) + return d + + self.hs._sendmail = sendmail + # Register the user who gets notified user_id = self.register_user("user", "pass") access_token = self.login("user", "pass") @@ -102,8 +114,36 @@ def test_sends_email(self): self.helper.send(room, body="Hi!", tok=other_access_token) self.helper.send(room, body="There!", tok=other_access_token) - # Advance time a bit, so the pusher will register + # Get the stream ordering before it gets sent + pushers = self.get_success( + self.hs.get_datastore().get_pushers_by(dict(user_name=user_id)) + ) + self.assertEqual(len(pushers), 1) + last_stream_ordering = pushers[0]["last_stream_ordering"] + + # Advance time a bit, so the pusher will register something has happened self.pump(100) - # It then tries to send the email. - self.assertEqual(len(self.reactor.tcpClients), 1) + # It hasn't succeeded yet, so the stream ordering shouldn't have moved + pushers = self.get_success( + self.hs.get_datastore().get_pushers_by(dict(user_name=user_id)) + ) + self.assertEqual(len(pushers), 1) + self.assertEqual(last_stream_ordering, pushers[0]["last_stream_ordering"]) + + # One email was attempted to be sent + self.assertEqual(len(email_attempts), 1) + + # Make the email succeed + email_attempts[0][0].callback(True) + self.pump() + + # One email was attempted to be sent + self.assertEqual(len(email_attempts), 1) + + # The stream ordering has increased + pushers = self.get_success( + self.hs.get_datastore().get_pushers_by(dict(user_name=user_id)) + ) + self.assertEqual(len(pushers), 1) + self.assertTrue(pushers[0]["last_stream_ordering"] > last_stream_ordering) From 87b7bb4d5a31d9a5cb760405cf809ebf1158b0e7 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 30 Oct 2018 01:52:10 +1100 Subject: [PATCH 14/16] isort --- tests/push/test_email.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/push/test_email.py b/tests/push/test_email.py index 50df1d44decc..f3f126364564 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -17,9 +17,10 @@ import pkg_resources -from synapse.rest.client.v1 import admin, login, room from twisted.internet.defer import Deferred +from synapse.rest.client.v1 import admin, login, room + from tests.unittest import HomeserverTestCase try: From e2de666ec5c9c7e4c79bc2f46280e9584dacb8ef Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 30 Oct 2018 23:38:21 +1100 Subject: [PATCH 15/16] review comments --- .travis.yml | 3 +++ synapse/push/mailer.py | 3 ++- synapse/server.py | 12 +++++------- tests/push/test_email.py | 26 ++++++++++++-------------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 560b57f19c04..655fab9d8e8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,9 @@ branches: - develop - /^release-v/ +# When running the tox environments that call Twisted Trial, we can pass the -j +# flag to run the tests concurrently. We set this to 2 for CPU bound tests +# (SQLite) and 4 for I/O bound tests (PostgreSQL). matrix: fast_finish: true include: diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py index a5f463b28478..ebcb93bfc7fb 100644 --- a/synapse/push/mailer.py +++ b/synapse/push/mailer.py @@ -84,6 +84,7 @@ def __init__(self, hs, app_name, notif_template_html, notif_template_text): self.notif_template_html = notif_template_html self.notif_template_text = notif_template_text + self.sendmail = self.hs.get_sendmail() self.store = self.hs.get_datastore() self.macaroon_gen = self.hs.get_macaroon_generator() self.state_handler = self.hs.get_state_handler() @@ -191,7 +192,7 @@ def _fetch_room_state(room_id): logger.info("Sending email push notification to %s" % email_address) - yield self.hs.get_sendmail()( + yield self.sendmail( self.hs.config.email_smtp_host, raw_from, raw_to, multipart_msg.as_string().encode('utf8'), reactor=self.hs.get_reactor(), diff --git a/synapse/server.py b/synapse/server.py index 2b2d017e009f..dd03eeab7f00 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -24,6 +24,7 @@ from twisted.enterprise import adbapi from twisted.web.client import BrowserLikePolicyForHTTPS +from twisted.mail.smtp import sendmail from synapse.api.auth import Auth from synapse.api.filtering import Filtering @@ -174,6 +175,7 @@ def build_DEPENDENCY(self) 'message_handler', 'pagination_handler', 'room_context_handler', + 'sendmail', ] # This is overridden in derived application classes @@ -216,13 +218,6 @@ def get_reactor(self): """ return self._reactor - def get_sendmail(self): - if hasattr(self, "_sendmail"): - return self._sendmail - else: - from twisted.mail.smtp import sendmail - return sendmail - def get_ip_from_request(self, request): # X-Forwarded-For is handled by our custom request type. return request.getClientIP() @@ -276,6 +271,9 @@ def build_simple_http_client(self): def build_room_creation_handler(self): return RoomCreationHandler(self) + def build_sendmail(self): + return sendmail + def build_state_handler(self): return StateHandler(self) diff --git a/tests/push/test_email.py b/tests/push/test_email.py index f3f126364564..50ee6910d16a 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -42,6 +42,14 @@ class EmailPusherTests(HomeserverTestCase): def make_homeserver(self, reactor, clock): + # List[Tuple[Deferred, args, kwargs]] + self.email_attempts = [] + + def sendmail(*args, **kwargs): + d = Deferred() + self.email_attempts.append((d, args, kwargs)) + return d + config = self.default_config() config.email_enable_notifs = True config.start_pushers = True @@ -58,22 +66,12 @@ def make_homeserver(self, reactor, clock): config.email_app_name = "Matrix" config.email_notif_from = "test@example.com" - hs = self.setup_test_homeserver(config=config) + hs = self.setup_test_homeserver(config=config, sendmail=sendmail) return hs def test_sends_email(self): - # List[Tuple[Deferred, args, kwargs]] - email_attempts = [] - - def sendmail(*args, **kwargs): - d = Deferred() - email_attempts.append((d, args, kwargs)) - return d - - self.hs._sendmail = sendmail - # Register the user who gets notified user_id = self.register_user("user", "pass") access_token = self.login("user", "pass") @@ -133,14 +131,14 @@ def sendmail(*args, **kwargs): self.assertEqual(last_stream_ordering, pushers[0]["last_stream_ordering"]) # One email was attempted to be sent - self.assertEqual(len(email_attempts), 1) + self.assertEqual(len(self.email_attempts), 1) # Make the email succeed - email_attempts[0][0].callback(True) + self.email_attempts[0][0].callback(True) self.pump() # One email was attempted to be sent - self.assertEqual(len(email_attempts), 1) + self.assertEqual(len(self.email_attempts), 1) # The stream ordering has increased pushers = self.get_success( From ae95786c73b772f501d6dfc7fa34dd6805bad641 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 30 Oct 2018 23:38:34 +1100 Subject: [PATCH 16/16] isort --- synapse/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/server.py b/synapse/server.py index dd03eeab7f00..9985687b95d9 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -23,8 +23,8 @@ import logging from twisted.enterprise import adbapi -from twisted.web.client import BrowserLikePolicyForHTTPS from twisted.mail.smtp import sendmail +from twisted.web.client import BrowserLikePolicyForHTTPS from synapse.api.auth import Auth from synapse.api.filtering import Filtering