Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard
erp5
Commits
8f199004
Commit
8f199004
authored
Feb 27, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add tests for Business Package and Business Configuration
parent
8537741d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
327 additions
and
70 deletions
+327
-70
bt5/erp5_business_package/TestTemplateItem/portal_components/test.erp5.testBusinessPackage.py
...teItem/portal_components/test.erp5.testBusinessPackage.py
+327
-70
No files found.
bt5/erp5_business_package/TestTemplateItem/portal_components/test.erp5.testBusinessPackage.py
View file @
8f199004
...
@@ -30,9 +30,7 @@ import time
...
@@ -30,9 +30,7 @@ import time
import
os
import
os
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
from
urllib
import
pathname2url
from
urllib
import
pathname2url
#import tempfile
from
Products.ERP5.Document.BusinessPackage
import
createInstallationData
from
Products.ERP5.Document.BusinessPackage
import
InstallationTree
,
createInstallationData
#from Products.ERP5Type.tests.runUnitTest import tests_home
class
TestBusinessPackage
(
ERP5TypeTestCase
):
class
TestBusinessPackage
(
ERP5TypeTestCase
):
"""
"""
...
@@ -87,8 +85,6 @@ class TestBusinessPackage(ERP5TypeTestCase):
...
@@ -87,8 +85,6 @@ class TestBusinessPackage(ERP5TypeTestCase):
if
not
title
:
if
not
title
:
title
=
bp_id
title
=
bp_id
package
=
self
.
portal
.
portal_templates
.
newContent
(
id
=
bp_id
,
portal_type
=
'Business Package'
)
package
=
self
.
portal
.
portal_templates
.
newContent
(
id
=
bp_id
,
portal_type
=
'Business Package'
)
#self.assertTrue(package.getBuildingState() == 'draft')
#self.assertTrue(package.getInstallationState() == 'not_installed')
package
.
edit
(
title
=
bp_id
,
package
.
edit
(
title
=
bp_id
,
version
=
'1.0'
,
version
=
'1.0'
,
description
=
'package for live test'
)
description
=
'package for live test'
)
...
@@ -136,69 +132,188 @@ class TestBusinessPackage(ERP5TypeTestCase):
...
@@ -136,69 +132,188 @@ class TestBusinessPackage(ERP5TypeTestCase):
package
.
install
()
package
.
install
()
self
.
tic
()
self
.
tic
()
def
test_fileImportAndReinstallWithProperty
(
self
):
def
_createBusinessManager
(
self
,
bm_id
=
None
,
title
=
None
):
if
not
bm_id
:
bm_id
=
'manager_%s'
%
str
(
time
.
time
())
if
not
title
:
title
=
bm_id
manager
=
self
.
portal
.
portal_templates
.
newContent
(
id
=
bm_id
,
\
portal_type
=
'Business Manager'
)
self
.
tic
()
return
manager
def
_installationOfBusinessManagerViaTemplateTool
(
self
):
"""
"""
Test Business Package for Path and ObjectProperty Items together.
We try installing one or multiple Business Manager all via portal_templates,
Here we export path as well propertie(s) for different objects and check
keeping in mind that any operation done on BM should result in a BM which
if we are able to install them back using Business Package
can be easlily mapped with OFS.
"""
"""
package
=
self
.
_createBusinessPackage
(
bp_id
=
'erp5_export_path_and_property'
)
manager
=
self
.
_createBusinessManager
(
)
file_path_list
=
[
'portal_catalog/erp5_mysql_innodb'
,]
portal_templates
=
self
.
portal
.
portal_templates
property_list
=
[
'portal_catalog | default_erp5_catalog_id'
]
package
.
edi
t
(
test_catalog_1
=
self
.
portal
.
portal_catalog
.
newConten
t
(
template_path_list
=
file_path_list
,
portal_type
=
'Catalog'
,
template_object_property_list
=
property_list
title
=
'Test Catalog 1 for Multiple BP5 Installation'
,
)
)
path_catalog_1
=
test_catalog_1
.
getRelativeUrl
()
path_item_catalog_1
=
'%s | %s | %s'
%
(
path_catalog_1
,
1
,
1
)
path_item_list
=
[
path_item_catalog_1
]
manager
.
_setTemplatePathList
(
path_item_list
)
built_manager
=
manager
.
build
()
self
.
tic
()
self
.
tic
()
package_path
=
self
.
_buildAndExportBusinessPackage
(
package
)
bm_list
=
[]
import_package
=
self
.
_importBusinessPackage
(
package
,
package_path
)
bm_list
.
append
(
built_manager
)
self
.
_installBusinessPackage
(
import_package
)
self
.
portal
.
portal_catalog
.
manage_delObjects
(
\
[
test_catalog_1
.
getId
(),])
self
.
tic
()
# Test that the catalogs don't exist on site anymore
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
path_catalog_1
))
portal_templates
.
installMultipleBusinessManager
(
bm_list
)
self
.
tic
()
catalog_1
=
self
.
portal
.
restrictedTraverse
(
path_catalog_1
)
self
.
assertEquals
(
catalog_1
.
getTitle
(),
\
'Test Catalog 1 for Multiple BP5 Installation'
)
def
test_fileImportAndReinstallForDocument
(
self
):
def
reduceBusinessManagerWithTwoConflictingPath
(
self
):
"""
"""
Test Business Package build and install with test document.
Test the final Business Manager for Business Manager which have same path
at different layer
"""
portal_templates
=
self
.
portal
.
portal_templates
manager_1
=
self
.
_createBusinessManager
()
manager_2
=
self
.
_createBusinessManager
()
Expected result: Installs the exported object to the path expected on site.
test_catalog_1
=
self
.
portal
.
portal_catalog
.
newContent
(
portal_type
=
'Catalog'
,
title
=
'Test Catalog 1 for Multiple BP5 Installation'
,
)
path_catalog_1
=
test_catalog_1
.
getRelativeUrl
()
path_item_catalog_1
=
'%s | %s | %s'
%
(
path_catalog_1
,
1
,
1
)
path_item_list_1
=
[
path_item_catalog_1
]
manager_1
.
_setTemplatePathList
(
path_item_list_1
)
built_manager_1
=
manager_1
.
build
()
self
.
tic
()
test_catalog_1
.
edit
(
title
=
'Test Catalog 2 for Multiple BP5 Installation'
,
)
path_item_catalog_2
=
'%s | %s | %s'
%
(
path_catalog_1
,
1
,
2
)
path_item_list_2
=
[
path_item_catalog_2
]
manager_2
.
_setTemplatePathList
(
path_item_list_2
)
built_manager_2
=
manager_2
.
build
()
self
.
tic
()
self
.
portal
.
portal_catalog
.
manage_delObjects
(
\
[
test_catalog_1
.
getId
(),])
self
.
tic
()
# Test that the catalogs don't exist on site anymore
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
path_catalog_1
))
bm_list
=
[]
bm_list
.
append
(
built_manager_1
)
bm_list
.
append
(
built_manager_2
)
portal_templates
.
installMultipleBusinessManager
(
bm_list
)
self
.
tic
()
catalog_1
=
self
.
portal
.
restrictedTraverse
(
path_catalog_1
)
self
.
assertEquals
(
catalog_1
.
getTitle
(),
\
'Test Catalog 2 for Multiple BP5 Installation'
)
def
test_UpdateVersionOfBusinessManager
(
self
):
"""
"""
package
=
self
.
_createBusinessPackage
(
bp_id
=
'erp5_mysql_innodb_catalog_1'
)
* install bm A which add one workflow W1
document_file
=
self
.
portal
.
document_module
.
newContent
(
* install bm B which surcharge workflow W2
portal_type
=
'File'
,
* drop workflow W2 from bm configuration
title
=
'Test Document'
,
* update bp5 B: ensure that the ZODB contains W1
reference
=
'erp5-package.Test.Document'
,
"""
data
=
'test file'
,
portal_templates
=
self
.
portal
.
portal_templates
content_type
=
None
)
managerA
=
self
.
_createBusinessManager
()
managerB
=
self
.
_createBusinessManager
()
test_catalog_A
=
self
.
portal
.
portal_catalog
.
newContent
(
portal_type
=
'Catalog'
,
title
=
'Test Catalog A for Multiple BM Installation'
,
)
# Add catalog to the path list for Business Manager and build the object
path_catalog_A
=
test_catalog_A
.
getRelativeUrl
()
path_item_catalog_A
=
'%s | %s | %s'
%
(
path_catalog_A
,
1
,
1
)
path_item_list_A
=
[
path_item_catalog_A
]
managerA
.
_setTemplatePathList
(
path_item_list_A
)
self
.
tic
()
self
.
tic
()
built_manager_A
=
managerA
.
build
()
file_path
=
document_file
.
getRelativeUrl
()
# Delete the catalog object
package
.
edit
(
template_path_list
=
file_path
)
self
.
portal
.
portal_catalog
.
manage_delObjects
(
[
test_catalog_A
.
getId
(),])
self
.
tic
()
self
.
tic
()
#
Build packag
e
#
Test that the catalog don't exist on site anymor
e
package_path
=
self
.
_buildAndExportBusinessPackage
(
package
)
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
path_catalog_A
)
)
#
Delete the document
#
Install the Business Manager A
self
.
portal
.
document_module
.
manage_delObjects
([
document_file
.
getID
(),
])
portal_templates
.
installMultipleBusinessManager
([
built_manager_A
])
self
.
tic
()
self
.
tic
()
# Assert that the file is gone
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
file_path
))
import_package
=
self
.
_importBusinessPackage
(
package
,
package_path
)
# Test that the catalog exists
catalog_1
=
self
.
portal
.
restrictedTraverse
(
path_catalog_A
)
self
.
assertEquals
(
catalog_1
.
getTitle
(),
\
'Test Catalog A for Multiple BM Installation'
)
# Install package
# Create new Business Manager B with some different object
self
.
_installBusinessPackage
(
import_package
)
path_document_B
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'File'
,
reference
=
'erp5-package.Test.Document'
,
data
=
'test data'
,
)
self
.
tic
()
path_item_document_B
=
'%s | %s | %s'
%
(
path_document_B
.
getRelativeUrl
(),
1
,
1
)
managerB
.
_setTemplatePathList
([
path_item_document_B
])
self
.
tic
()
built_manager_B
=
managerB
.
build
()
#
Test if the file is back
#
Delete the document object
self
.
assertIsNotNone
(
self
.
portal
.
restrictedTraverse
(
file_path
))
self
.
portal
.
document_module
.
manage_delObjects
(
document
=
self
.
portal
.
restrictedTraverse
(
file_path
)
[
path_document_B
.
getId
(),]
)
self
.
assertEquals
(
document
.
title
,
'Test Document'
)
self
.
tic
(
)
def
_sameFileImportAndReinstallOnTwoPackages
(
self
):
# Add an empty path list in managerA
managerA
.
_setTemplatePathList
([])
self
.
tic
()
built_manager_A
=
managerA
.
build
()
# Try installing built Business Managers A and B together
bm_list
=
[]
bm_list
.
append
(
built_manager_A
)
bm_list
.
append
(
built_manager_B
)
portal_templates
.
installMultipleBusinessManager
(
bm_list
)
# Check if the catalog still exists
catalog_1
=
self
.
portal
.
restrictedTraverse
(
path_catalog_A
)
self
.
assertEquals
(
catalog_1
.
getTitle
(),
\
'Test Catalog A for Multiple BM Installation'
)
def
_differentFileImportAndReinstallOnTwoPackages
(
self
):
"""
"""
Test two Business
Packag
es build and installation of same file.
Test two Business
Templat
es build and installation of same file.
Here we will be using Insatallation Tree to install in the two packages
Here we will be using Insatallation Tree in Template Tool to install
all together, rather than doing installation one after another.
in the two configurations all together, rather than doing installation
one after another.
Expected result: If we install same object from 2 different business packages,
Expected result: If we install same object from 2 different business packages,
then in that case the installation object should compare between the
then in that case the installation object should compare between the
...
@@ -208,48 +323,190 @@ class TestBusinessPackage(ERP5TypeTestCase):
...
@@ -208,48 +323,190 @@ class TestBusinessPackage(ERP5TypeTestCase):
old_package
=
self
.
_createBusinessPackage
()
old_package
=
self
.
_createBusinessPackage
()
new_package
=
self
.
_createBusinessPackage
()
new_package
=
self
.
_createBusinessPackage
()
portal_templates
=
self
.
portal
.
portal_templates
test_catalog_1
=
self
.
portal
.
portal_catalog
.
newContent
(
portal_type
=
'Catalog'
,
title
=
'Test Catalog 1 for Multiple BP5 Installation'
,
)
test_catalog_2
=
self
.
portal
.
portal_catalog
.
newContent
(
portal_type
=
'Catalog'
,
title
=
'Test Catalog 2 for Multiple BP5 Installation'
,
)
self
.
tic
()
# Update the property for the above mentioned objects so that we can use
# them in tests
test_catalog_1
.
edit
(
sql_catalog_datetime_search_keys
=
[
'alarm.alarm_date'
,
'alarm_date'
,
'catalog.creation_date'
,
'catalog.grouping_date'
,
'catalog.modification_date'
],
)
test_catalog_2
.
edit
(
sql_catalog_datetime_search_keys
=
[
'creation_date'
,
'date'
,
'delivery.start_date'
,
'delivery.start_date_range_max'
,
'delivery.start_date_range_min'
,
],
)
property_list
=
[
'sql_catalog_datetime_search_keys_list'
,
'sql_catalog_full_text_search_keys_list'
,
]
path_1
=
test_catalog_1
.
getRelativeUrl
()
path_2
=
test_catalog_2
.
getRelativeUrl
()
prop_list_1
=
[]
prop_list_2
=
[]
for
prop_id
in
property_list
:
prop_line_1
=
'%s | %s'
%
(
path_1
,
prop_id
)
prop_line_2
=
'%s | %s'
%
(
path_2
,
prop_id
)
prop_list_1
.
append
(
prop_line_1
)
prop_list_2
.
append
(
prop_line_2
)
old_package
.
edit
(
template_path_list
=
[
path_1
,],
template_object_property_list
=
prop_list_1
,
)
new_package
.
edit
(
template_path_list
=
[
path_2
,],
template_object_property_list
=
prop_list_2
,
)
self
.
tic
()
# Build both the packages
old_package_path
=
self
.
_buildAndExportBusinessPackage
(
old_package
)
new_package_path
=
self
.
_buildAndExportBusinessPackage
(
new_package
)
self
.
tic
()
import_old_package
=
self
.
_importBusinessPackage
(
old_package
,
old_package_path
)
import_new_package
=
self
.
_importBusinessPackage
(
new_package
,
new_package_path
)
# Get installation data from the list of packages which we want to install
package_list
=
[
import_old_package
,
import_new_package
]
# Delete document from site
self
.
portal
.
portal_catalog
.
manage_delObjects
(
\
[
test_catalog_1
.
getId
(),
test_catalog_2
.
getId
(),
])
self
.
tic
()
# Test that the catalogs don't exist on site anymore
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
path_1
))
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
path_2
))
# Install multiple Business Package all together
portal_templates
.
installMultipleBusinessPackage
(
package_list
)
catalog_1
=
self
.
portal
.
restrictedTraverse
(
path_1
)
catalog_2
=
self
.
portal
.
restrictedTraverse
(
path_2
)
self
.
assertEquals
(
catalog_1
.
getTitle
(),
\
'Test Catalog 1 for Multiple BP5 Installation'
)
self
.
assertEquals
(
catalog_2
.
getTitle
(),
\
'Test Catalog 2 for Multiple BP5 Installation'
)
def
_fileImportAndReinstallWithProperty
(
self
):
"""
Test Business Package for Path and ObjectProperty Items together.
Here we export path as well propertie(s) for different objects and check
if we are able to install them back using Business Package
"""
bp_id
=
'erp5_mysql_innodb_catalog_%s'
%
time
.
time
()
package
=
self
.
_createBusinessPackage
(
bp_id
=
bp_id
)
catalog_path
=
'portal_catalog/erp5_mysql_innodb'
file_path_list
=
(
'portal_catalog/erp5_mysql_innodb'
,
'portal_catalog/erp5_mysql_innodb/**'
,
)
#erp5_catalog = self.portal.unrestrictedTraverse(catalog_path)
property_list
=
[
'sql_catalog_datetime_search_keys_list'
,
'sql_catalog_full_text_search_keys_list'
,
'sql_catalog_keyword_search_keys_list'
,
'sql_catalog_local_role_keys_list'
,
'sql_catalog_multivalue_keys_list'
,
'sql_catalog_related_keys_list'
,
'sql_catalog_request_keys_list'
,
'sql_search_result_keys_list'
,
'sql_search_tables_list'
,
'sql_catalog_role_keys_list'
,
'sql_catalog_scriptable_keys_list'
,
'sql_catalog_search_keys_list'
,
'sql_catalog_security_uid_columns_list'
,
'sql_catalog_topic_search_keys_list'
]
prop_list
=
[]
for
prop_id
in
property_list
:
prop_line
=
'%s | %s'
%
(
catalog_path
,
prop_id
)
prop_list
.
append
(
prop_line
)
package
.
edit
(
template_path_list
=
file_path_list
,
template_object_property_list
=
prop_list
)
self
.
tic
()
package_path
=
self
.
_buildAndExportBusinessPackage
(
package
)
import_package
=
self
.
_importBusinessPackage
(
package
,
package_path
)
self
.
_installBusinessPackage
(
import_package
)
def
fileImportAndReinstallForDocument
(
self
):
"""
Test Business Package build and install with test document.
Expected result: Installs the exported object to the path expected on site.
"""
bp_id
=
'erp5_mysql_innodb_catalog_%s'
%
time
.
time
()
package
=
self
.
_createBusinessPackage
(
bp_id
=
bp_id
)
document_file
=
self
.
portal
.
document_module
.
newContent
(
document_file
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'File'
,
portal_type
=
'File'
,
title
=
'Test Document'
,
title
=
'Test Document'
,
reference
=
'erp5-package.Test.Document
.Two.BP
'
,
reference
=
'erp5-package.Test.Document'
,
data
=
'test file'
,
data
=
'test file'
,
content_type
=
None
)
content_type
=
None
)
self
.
tic
()
self
.
tic
()
file_path
=
document_file
.
getRelativeUrl
()
file_path
=
document_file
.
getRelativeUrl
()
old_package
.
edit
(
template_path_list
=
[
file_path
,])
property_list
=
[
'%s | title'
%
file_path
,]
new_package
.
edit
(
template_path_list
=
[
file_path
,])
package
.
edit
(
self
.
tic
()
template_path_list
=
file_path
,
template_object_property_list
=
property_list
,
# Build both the packages
)
self
.
_buildAndExportBusinessPackage
(
old_package
)
self
.
_buildAndExportBusinessPackage
(
new_package
)
self
.
tic
()
self
.
tic
()
# Get installation data from the list of packages which we want to install
# Build package
package_list
=
[
old_package
,
new_package
]
package_path
=
self
.
_buildAndExportBusinessPackage
(
package
)
final_data
,
conflicted_data
=
createInstallationData
(
package_list
)
# Delete
document from site
# Delete
the document
self
.
portal
.
document_module
.
manage_delObjects
([
document_file
.
getId
(),])
self
.
portal
.
document_module
.
manage_delObjects
([
document_file
.
getId
(),])
self
.
tic
()
self
.
tic
()
# Assert that the file is gone
# Test if the file doesn't exist on site anymore
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
file_path
))
self
.
assertRaises
(
KeyError
,
lambda
:
self
.
portal
.
restrictedTraverse
(
file_path
))
if
not
conflicted_data
:
import_package
=
self
.
_importBusinessPackage
(
package
,
package_path
)
# Create InstallationTree object
installation_tree
=
InstallationTree
(
final_data
)
# We try to install pakcages via mapping the installation tree to ZODB
# As both have exactly same document we expect that only one of them get installed
installation_tree
.
mapToERP5Site
(
self
.
portal
)
# Install package
self
.
_installBusinessPackage
(
import_package
)
# Test if the file is back
# Test if the file is back
self
.
assertIsNotNone
(
self
.
portal
.
restrictedTraverse
(
file_path
))
self
.
assertIsNotNone
(
self
.
portal
.
restrictedTraverse
(
file_path
))
document
=
self
.
portal
.
restrictedTraverse
(
file_path
)
document
=
self
.
portal
.
restrictedTraverse
(
file_path
)
self
.
assertEquals
(
document
.
title
,
document_file
.
title
)
self
.
assertEquals
(
document
.
title
,
'Test Document'
)
def
_AddConflictedFileAtSamePathViaTwoPackages
(
self
):
def
_AddConflictedFileAtSamePathViaTwoPackages
(
self
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment