diff --git a/muk_attachment_lobject/__manifest__.py b/muk_attachment_lobject/__manifest__.py index 81aa61d..ef49cc2 100644 --- a/muk_attachment_lobject/__manifest__.py +++ b/muk_attachment_lobject/__manifest__.py @@ -20,7 +20,7 @@ { "name": "MuK Large Objects Attachment", "summary": """Large Objects Attachment Location""", - "version": '12.0.2.1.0', + "version": '12.0.2.1.1', "category": 'Extra Tools', "license": "AGPL-3", "website": "http://www.mukit.at", diff --git a/muk_attachment_lobject/tests/__init__.py b/muk_attachment_lobject/tests/__init__.py index 9f04135..12b9b64 100644 --- a/muk_attachment_lobject/tests/__init__.py +++ b/muk_attachment_lobject/tests/__init__.py @@ -17,4 +17,5 @@ # ################################################################################### -from . import test_attachment \ No newline at end of file +from . import test_attachment +from . import test_download \ No newline at end of file diff --git a/muk_attachment_lobject/tests/test_attachment.py b/muk_attachment_lobject/tests/test_attachment.py index a7a496f..aa2102c 100644 --- a/muk_attachment_lobject/tests/test_attachment.py +++ b/muk_attachment_lobject/tests/test_attachment.py @@ -34,12 +34,12 @@ class AttachmentTestCase(common.HttpCase): super(AttachmentTestCase, 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(AttachmentTestCase, self).tearDown() def test_attachment(self): - self.param.set_param('ir_attachment.location', 'lobject') attach = self.attachment.create({ 'name': "Test", 'datas': base64.b64encode(b"\xff data")}) @@ -58,5 +58,4 @@ class AttachmentTestCase(common.HttpCase): @unittest.skip("The test takes a long time and is therefore skipped by default.") def test_migration(self): - self.param.set_param('ir_attachment.location', 'lobject') self.attachment.force_storage() \ No newline at end of file diff --git a/muk_attachment_lobject/tests/test_download.py b/muk_attachment_lobject/tests/test_download.py new file mode 100644 index 0000000..9b0be8e --- /dev/null +++ b/muk_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 . +# +################################################################################### + +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)) + + + + + \ No newline at end of file