mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Add implementation of reading writing on the Swift object store
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import tests
|
||||
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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
|
||||
|
||||
|
||||
class TestAttachmentSwift(TestIrAttachment):
|
||||
|
||||
def setup(self):
|
||||
super(TestAttachmentSwift, self).setUp()
|
||||
self.env['ir.config_parameter'].set_param('ir_attachment.location', 'swift')
|
||||
|
||||
def test_connection(self):
|
||||
""" Test the connection to the Swift object store """
|
||||
conn = self.Attachment._get_swift_connection()
|
||||
self.assertNotEquals(conn, False)
|
||||
|
||||
def test_store_file_on_swift(self):
|
||||
a5 = self.Attachment.create({'name': 'a5', 'datas': self.blob1_b64})
|
||||
a5bis = self.Attachment.browse(a5.id)[0]
|
||||
|
||||
def test_delete_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})
|
||||
uri = SwiftUri(a5.store_fname)
|
||||
con = self.Attachment._get_swift_connection()
|
||||
data = 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