Browse Source

publish muk_attachment_lobject - 12.0

pull/9/head
MuK IT GmbH 5 years ago
parent
commit
17a4f8318e
  1. 2
      muk_attachment_lobject/__manifest__.py
  2. 3
      muk_attachment_lobject/tests/__init__.py
  3. 3
      muk_attachment_lobject/tests/test_attachment.py
  4. 73
      muk_attachment_lobject/tests/test_download.py

2
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",

3
muk_attachment_lobject/tests/__init__.py

@ -17,4 +17,5 @@
#
###################################################################################
from . import test_attachment
from . import test_attachment
from . import test_download

3
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()

73
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 <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))
Loading…
Cancel
Save