def test_async_render_empty_garant_letter_subarenda(self):
        data = {
        }

        new_user_doc = UserDocument()
        new_user_doc.parse_raw_value(dict(document_type=DocumentTypeEnum.DT_GARANT_LETTER_SUBARENDA, data=data), None,
                                     False)

        doc_list = [
            new_user_doc.db_value()
        ]
        new_batch_db_object = DocumentBatchDbObject(documents=doc_list, batch_type=DocumentBatchTypeEnum.DBT_NEW_LLC,
                                                    status=BatchStatusEnum.BS_NEW, _owner=self.user._id)
        new_batch_db_object.insert(self.db)

        result = self.test_client.get('/batch/document/state/?batch_id=%s&document_id=%s' % (
            unicode(new_batch_db_object._id), unicode(new_user_doc.id.db_value())))
        self.assertEqual(result.status_code, 200)
        result_data = json.loads(result.data)
        del result_data['result']['document_id']
        self.assertEqual(result_data, {u'result': {u'state': u'new', u'links': {u'pdf': None, u'jpeg': []}}})

        result = self.test_client.post('/batch/document/render/', data={'batch_id': unicode(new_batch_db_object._id),
                                                                        'document_id': unicode(
                                                                            new_user_doc.id.db_value())})
        self.assertEqual(result.status_code, 200)
        result_data = json.loads(result.data)
        self.assertEqual(result_data, {u'result': True})

        result = self.test_client.get('/batch/document/state/?batch_id=%s&document_id=%s' % (
            unicode(new_batch_db_object._id), unicode(new_user_doc.id.db_value())))
        self.assertEqual(result.status_code, 200)
        result_data = json.loads(result.data)
        self.assertEqual(result_data['result']['state'], 'rendered')
        self.assertTrue(result_data['result']['links']['pdf'].startswith(u'http://service.zz/storage/'))
    def test_async_render_empty_soglasie_sobstvennikov(self):

        data = {}

        new_user_doc = UserDocument()
        new_user_doc.parse_raw_value(
            dict(document_type=DocumentTypeEnum.DT_SOGLASIE_SOBSTVENNIKOV,
                 data=data), None, False)

        doc_list = [new_user_doc.db_value()]
        new_batch_db_object = DocumentBatchDbObject(
            documents=doc_list,
            batch_type=DocumentBatchTypeEnum.DBT_NEW_LLC,
            status=BatchStatusEnum.BS_NEW,
            _owner=self.user._id)
        new_batch_db_object.insert(self.db)

        result = self.test_client.get(
            '/batch/document/state/?batch_id=%s&document_id=%s' % (unicode(
                new_batch_db_object._id), unicode(new_user_doc.id.db_value())))
        self.assertEqual(result.status_code, 200)
        result_data = json.loads(result.data)
        del result_data['result']['document_id']
        self.assertEqual(result_data, {
            u'result': {
                u'state': u'new',
                u'links': {
                    u'pdf': None,
                    u'jpeg': []
                }
            }
        })

        result = self.test_client.post('/batch/document/render/',
                                       data={
                                           'batch_id':
                                           unicode(new_batch_db_object._id),
                                           'document_id':
                                           unicode(new_user_doc.id.db_value())
                                       })
        self.assertEqual(result.status_code, 200)
        result_data = json.loads(result.data)
        self.assertEqual(result_data, {u'result': True})

        result = self.test_client.get(
            '/batch/document/state/?batch_id=%s&document_id=%s' % (unicode(
                new_batch_db_object._id), unicode(new_user_doc.id.db_value())))
        self.assertEqual(result.status_code, 200)
        result_data = json.loads(result.data)
        self.assertEqual(result_data['result']['state'], 'rendered')
        self.assertTrue(result_data['result']['links']['pdf'].startswith(
            u'http://service.zz/storage/'))