mirror of https://github.com/muk-it/muk_base
MuK IT GmbH
6 years ago
4 changed files with 77 additions and 4 deletions
-
2muk_attachment_lobject/__manifest__.py
-
3muk_attachment_lobject/tests/__init__.py
-
3muk_attachment_lobject/tests/test_attachment.py
-
73muk_attachment_lobject/tests/test_download.py
@ -0,0 +1,73 @@ |
|||
################################################################################### |
|||
# |
|||
# Copyright (C) 2018 MuK IT GmbH |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################### |
|||
|
|||
import os |
|||
import time |
|||
import hmac |
|||
import base64 |
|||
import hashlib |
|||
import logging |
|||
|
|||
from odoo.http import request |
|||
|
|||
from odoo.addons.muk_utils.tests import common |
|||
|
|||
_path = os.path.dirname(os.path.dirname(__file__)) |
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
class DownloadTestCase(common.HttpCase): |
|||
|
|||
def setUp(self): |
|||
super(DownloadTestCase, self).setUp() |
|||
self.attachment = self.env['ir.attachment'].sudo() |
|||
self.param = self.env['ir.config_parameter'].sudo() |
|||
self.param.set_param('ir_attachment.location', 'lobject') |
|||
|
|||
def tearDown(self): |
|||
super(DownloadTestCase, self).tearDown() |
|||
|
|||
def test_attachment_download(self): |
|||
self.authenticate('admin', 'admin') |
|||
attach_01 = self.attachment.create({ |
|||
'name': "Test_01", |
|||
'datas': base64.b64encode(b"\xff data") |
|||
}) |
|||
attach_02 = self.attachment.create({ |
|||
'name': "Test_02", |
|||
}) |
|||
self.assertTrue(attach_01.datas) |
|||
self.assertFalse(attach_02.datas) |
|||
data = { |
|||
'model': 'ir.attachment', |
|||
'field': 'store_lobject', |
|||
'filename_field': 'datas_fname', |
|||
} |
|||
data.update({ |
|||
'id': attach_01.id, |
|||
}) |
|||
self.assertTrue(self.url_open('/web/lobject', data=data, csrf=True)) |
|||
data.update({ |
|||
'id': attach_02.id, |
|||
}) |
|||
self.assertTrue(self.url_open('/web/lobject', data=data, csrf=True)) |
|||
|
|||
|
|||
|
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue