summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2015-01-28 11:00:27 -0200
committerDuda Dornelles <ddornell@thoughtworks.com>2015-01-28 11:00:27 -0200
commitcf9982ed9469ba10ddb1064b68905b8411251ece (patch)
tree8f81f9abb41c222ae97857bf8ca0a7b1a921edea
parent5dfd6a24111b708c9aa1280d34d376bba164d7e1 (diff)
Fixing _render function on app_test_client for integration tests so that when result is NOT_DONE_YET but the request is finished already we return a simple succeed defer
-rw-r--r--service/test/support/integration/app_test_client.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index fba9ba9c..d60d84dc 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -29,13 +29,12 @@ from pixelated.adapter.soledad.soledad_querier import SoledadQuerier
from pixelated.adapter.services.tag_service import TagService
from pixelated.config import App
from pixelated.resources.root_resource import RootResource
-import pixelated.runserver
from pixelated.adapter.model.mail import PixelatedMail
from pixelated.adapter.search import SearchEngine
from test.support.integration.model import MailBuilder
from test.support.test_helper import request_mock
from twisted.internet import reactor
-from twisted.internet.defer import Deferred
+from twisted.internet.defer import succeed
from twisted.web.resource import getChildForRequest
from twisted.web.server import Site
@@ -88,15 +87,10 @@ class AppTestClient:
if isinstance(result, basestring):
return get_str(result), request
- if request.finished:
- d = Deferred()
- d.addCallback(get_request_written_data)
- return d, request
- else:
- d = request.notifyFinish()
- d.addCallback(lambda _: request)
- d.addCallback(get_request_written_data)
- return d, request
+ # result is NOT_DONE_YET
+ d = succeed(request) if request.finished else request.notifyFinish()
+ d.addCallback(get_request_written_data)
+ return d, request
def run_on_a_thread(self, logfile='/tmp/app_test_client.log', port=4567, host='0.0.0.0'):
def _start():