Skip to content

Commit

Permalink
[IMP] Add tests for cmis_web_alf
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Oct 25, 2016
1 parent 53e67b4 commit 2e94231
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmis_web_alf/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import test_fields
from . import test_cmis_backend
54 changes: 54 additions & 0 deletions cmis_web_alf/tests/test_cmis_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# Copyright 2016 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import mock

from openerp.tests import common


class TestCmisBackend(common.SavepointCase):

def setUp(self):
super(TestCmisBackend, self).setUp()
self.cmis_backend = self.env['cmis.backend']
self.backend_instance = self.env.ref('cmis.cmis_backend_alfresco')

def test_get_content_details_url(self):
with mock.patch("openerp.addons.cmis.models.cmis_backend."
"CmisBackend.get_cmis_repository"
) as mocked_get_repository:
mocked_cmis_repository = mock.MagicMock()
mocked_get_repository.return_value = mocked_cmis_repository
mocked_cmis_object = mock.MagicMock()
mocked_cmis_repository.getObject.return_value = mocked_cmis_object
# test folder url without cmis:path
mocked_cmis_object.getProperties.return_value = {
'cmis:baseTypeId': 'cmis:folder',
'cmis:path': None,
'alfcmis:nodeRef': 'alfnoderef'}
url = self.backend_instance.get_content_details_url('my_id')
self.assertEqual(
url,
'http://localhost:8080/share/page/folder-details'
'?nodeRef=alfnoderef')
# test folder url with cmis:path
mocked_cmis_object.getProperties.return_value = {
'cmis:baseTypeId': 'cmis:folder',
'cmis:path': '/odoo/my-folder',
'alfcmis:nodeRef': 'alfnoderef'}
url = self.backend_instance.get_content_details_url('my_id')
self.assertEqual(
url,
'http://localhost:8080/share/page/repository'
'#filter=path%7C%2Fodoo%2Fmy-folder')
# test document
mocked_cmis_object.getProperties.return_value = {
'cmis:baseTypeId': 'cmis:document',
'alfcmis:nodeRef': 'alfnoderef'}
url = self.backend_instance.get_content_details_url('my_id')
self.assertEqual(
url,
'http://localhost:8080/share/page/document-details'
'?nodeRef=alfnoderef')
22 changes: 22 additions & 0 deletions cmis_web_alf/tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.addons.cmis_field.tests import common


class TestCmisFields(common.BaseTestCmis):

def test_cmis_folder_get_desciption(self):
inst = self.env['cmis.test.model'].create({'name': 'folder_name'})
# get_description is the method call by the method fields_get
# to return to the UI the desciption of the UI
descr = inst._fields['cmis_folder'].get_description(self.env)
backend_description = descr.get('backend')
share_location = backend_description.get(
'share_location')
alfresco_api_location = backend_description.get(
'alfresco_api_location')
self.assertEqual(
self.cmis_backend.share_location, share_location)
self.assertEqual(
self.cmis_backend.alfresco_api_location, alfresco_api_location)

0 comments on commit 2e94231

Please sign in to comment.