# -*- coding: utf-8 -*-

from twisted.internet.defer import inlineCallbacks

from globaleaks.handlers import export
from globaleaks.jobs.delivery_sched import DeliverySchedule
from globaleaks.tests import helpers

class TestExportHandler(helpers.TestHandlerWithPopulatedDB):
    complex_field_population = True
    _handler = export.ExportHandler

    @inlineCallbacks
    def setUp(self):
        yield helpers.TestHandlerWithPopulatedDB.setUp(self)
        yield self.perform_minimal_submission()
        yield DeliverySchedule().run()

    @inlineCallbacks
    def test_export(self):
        rtips_desc = yield self.get_rtips()

        handler = self.request({}, role='receiver')
        handler.current_user.user_id = rtips_desc[0]['receiver_id']

        # As the handler calls internally the flush() we should
        # mock that function because during tests the flush could not
        # be called as the handler is not fully run.
        def flush_mock():
            pass

        handler.flush = flush_mock

        yield handler.get(rtips_desc[0]['id'])

@@ -444,24 +444,25 @@
 p(self)%0A
+%0A
         
 yield se
@@ -457,47 +457,126 @@
     
-yield self.perform_minimal_submission()
+# this call is needed in order to populate the database%0A        # tables related to tips, comments, messages and files
 %0A   
@@ -590,30 +590,44 @@
 eld 
-DeliverySchedule().run
+self.perform_full_submission_actions
 ()%0A%0A

Revise commit e2a7e3ef95186ccda25022bdda4a042a5a89aeb6 covering template usage for Comments and Messages