diff options
author | Amber H. Brown <hawkowl@atleastfornow.net> | 2019-07-03 22:39:30 +1000 |
---|---|---|
committer | Amber H. Brown <hawkowl@atleastfornow.net> | 2019-07-03 22:39:30 +1000 |
commit | f4343c7d2bbde2d4b9674a029867bbe0353616e4 (patch) | |
tree | 44b29f777ae1418b1c858e2aa7cbbece06bafc70 /tests | |
parent | Merge remote-tracking branch 'origin/develop' into shhs (diff) | |
parent | 1.1.0rc2 (diff) | |
download | synapse-f4343c7d2bbde2d4b9674a029867bbe0353616e4.tar.xz |
Merge remote-tracking branch 'origin/develop' into shhs
Diffstat (limited to 'tests')
-rw-r--r-- | tests/rest/media/v1/test_url_preview.py | 12 | ||||
-rw-r--r-- | tests/util/test_logcontext.py | 33 |
2 files changed, 33 insertions, 12 deletions
diff --git a/tests/rest/media/v1/test_url_preview.py b/tests/rest/media/v1/test_url_preview.py index 8fe5961866..976652aee8 100644 --- a/tests/rest/media/v1/test_url_preview.py +++ b/tests/rest/media/v1/test_url_preview.py @@ -460,3 +460,15 @@ class URLPreviewTests(unittest.HomeserverTestCase): "error": "DNS resolution failure during URL preview generation", }, ) + + def test_OPTIONS(self): + """ + OPTIONS returns the OPTIONS. + """ + request, channel = self.make_request( + "OPTIONS", "url_preview?url=http://example.com", shorthand=False + ) + request.render(self.preview_url) + self.pump() + self.assertEqual(channel.code, 200) + self.assertEqual(channel.json_body, {}) diff --git a/tests/util/test_logcontext.py b/tests/util/test_logcontext.py index 8adaee3c8d..8d69fbf111 100644 --- a/tests/util/test_logcontext.py +++ b/tests/util/test_logcontext.py @@ -39,24 +39,17 @@ class LoggingContextTestCase(unittest.TestCase): callback_completed = [False] - def test(): + with LoggingContext() as context_one: context_one.request = "one" - d = function() + + # fire off function, but don't wait on it. + d2 = logcontext.run_in_background(function) def cb(res): - self._check_test_key("one") callback_completed[0] = True return res - d.addCallback(cb) - - return d - - with LoggingContext() as context_one: - context_one.request = "one" - - # fire off function, but don't wait on it. - logcontext.run_in_background(test) + d2.addCallback(cb) self._check_test_key("one") @@ -105,6 +98,22 @@ class LoggingContextTestCase(unittest.TestCase): return self._test_run_in_background(testfunc) + def test_run_in_background_with_coroutine(self): + async def testfunc(): + self._check_test_key("one") + d = Clock(reactor).sleep(0) + self.assertIs(LoggingContext.current_context(), LoggingContext.sentinel) + await d + self._check_test_key("one") + + return self._test_run_in_background(testfunc) + + def test_run_in_background_with_nonblocking_coroutine(self): + async def testfunc(): + self._check_test_key("one") + + return self._test_run_in_background(testfunc) + @defer.inlineCallbacks def test_make_deferred_yieldable(self): # a function which retuns an incomplete deferred, but doesn't follow |