-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |