mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
Create base_attachment_object_storage to extract common code to store implementations
This commit is contained in:
committed by
Guewen Baconnier
co-authored by
Guewen Baconnier
parent
beea07d44f
commit
fea698057a
@@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
import unittest
|
||||
from odoo.addons.base.tests.test_ir_attachment import TestIrAttachment
|
||||
from ..models import ir_attachment
|
||||
from ..swift_uri import SwiftUri
|
||||
from swiftclient.exceptions import ClientException
|
||||
|
||||
@@ -11,7 +11,8 @@ class TestAttachmentSwift(TestIrAttachment):
|
||||
|
||||
def setup(self):
|
||||
super(TestAttachmentSwift, self).setUp()
|
||||
self.env['ir.config_parameter'].set_param('ir_attachment.location', 'swift')
|
||||
self.env['ir.config_parameter'].set_param('ir_attachment.location',
|
||||
'swift')
|
||||
|
||||
def test_connection(self):
|
||||
""" Test the connection to the Swift object store """
|
||||
@@ -19,15 +20,19 @@ class TestAttachmentSwift(TestIrAttachment):
|
||||
self.assertNotEquals(conn, False)
|
||||
|
||||
def test_store_file_on_swift(self):
|
||||
(self.env['ir.config_parameter'].
|
||||
set_param('ir_attachment.location', 'swift'))
|
||||
a5 = self.Attachment.create({'name': 'a5', 'datas': self.blob1_b64})
|
||||
a5bis = self.Attachment.browse(a5.id)[0]
|
||||
self.assertEquals(a5.datas, a5bis.datas)
|
||||
|
||||
def test_delete_file_on_swift(self):
|
||||
self.env['ir.config_parameter'].set_param('ir_attachment.location', 'swift')
|
||||
(self.env['ir.config_parameter'].
|
||||
set_param('ir_attachment.location', 'swift'))
|
||||
a5 = self.Attachment.create({'name': 'a5', 'datas': self.blob1_b64})
|
||||
uri = SwiftUri(a5.store_fname)
|
||||
con = self.Attachment._get_swift_connection()
|
||||
data = con.get_object(uri.container(), uri.item())
|
||||
con.get_object(uri.container(), uri.item())
|
||||
a5.unlink()
|
||||
with self.assertRaises(ClientException):
|
||||
con.get_object(uri.container(), uri.item())
|
||||
|
||||
Reference in New Issue
Block a user