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
Paul Graydon
erp5
Commits
81d05bb5
Commit
81d05bb5
authored
Feb 08, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ooo_import: py3
parent
cf511b48
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
37 deletions
+45
-37
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_getReportResultList.py
.../portal_skins/erp5_ooo_import/Base_getReportResultList.py
+1
-1
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py
...plateItem/portal_skins/erp5_ooo_import/Base_importFile.py
+3
-1
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFileLineDefaultScript.py
...skins/erp5_ooo_import/Base_importFileLineDefaultScript.py
+3
-2
product/ERP5OOo/tests/testOOoImport.py
product/ERP5OOo/tests/testOOoImport.py
+38
-33
No files found.
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_getReportResultList.py
View file @
81d05bb5
...
@@ -17,7 +17,7 @@ if active_process_path is None:
...
@@ -17,7 +17,7 @@ if active_process_path is None:
active_process_value
=
context
.
getPortalObject
().
restrictedTraverse
(
active_process_path
)
active_process_value
=
context
.
getPortalObject
().
restrictedTraverse
(
active_process_path
)
result_list
=
[[
x
.
method_id
,
x
.
result
]
for
x
in
active_process_value
.
getResultList
()]
result_list
=
[[
x
.
method_id
,
x
.
result
]
for
x
in
active_process_value
.
getResultList
()]
result_list
.
sort
()
result_list
.
sort
(
key
=
str
)
for
[
method_id
,
result
]
in
result_list
:
for
[
method_id
,
result
]
in
result_list
:
safe_id
=
context
.
Base_getSafeIdFromString
(
'result %s'
%
num
)
safe_id
=
context
.
Base_getSafeIdFromString
(
'result %s'
%
num
)
...
...
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py
View file @
81d05bb5
...
@@ -153,7 +153,9 @@ else:
...
@@ -153,7 +153,9 @@ else:
if
property_value
:
if
property_value
:
# Create a new property value
# Create a new property value
property_id
=
column_mapping
[
line_property_index
]
property_id
=
column_mapping
[
line_property_index
]
imported_line_property_dict
[
property_id
]
=
property_value
.
encode
(
'UTF-8'
)
if
six
.
PY2
:
property_value
=
property_value
.
encode
(
'UTF-8'
)
imported_line_property_dict
[
property_id
]
=
property_value
# If the line is not empty, activate an activity for it
# If the line is not empty, activate an activity for it
...
...
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFileLineDefaultScript.py
View file @
81d05bb5
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
Products.ERP5Type.Message
import
Message
from
Products.ERP5Type.Message
import
Message
import
six
#Create new ERP5 objects In Activity from OOo document
#Create new ERP5 objects In Activity from OOo document
imported_line
=
object_url
=
None
imported_line
=
object_url
=
None
...
@@ -46,7 +47,7 @@ else:
...
@@ -46,7 +47,7 @@ else:
# Separate categories from properties
# Separate categories from properties
imported_line_category_dict
=
{}
imported_line_category_dict
=
{}
for
prop_key
in
imported_line_property_dict
.
keys
(
):
for
prop_key
in
list
(
six
.
iterkeys
(
imported_line_property_dict
)
):
if
prop_key
in
base_category_list
:
if
prop_key
in
base_category_list
:
imported_line_category_dict
[
prop_key
]
=
imported_line_property_dict
.
pop
(
prop_key
)
imported_line_category_dict
[
prop_key
]
=
imported_line_property_dict
.
pop
(
prop_key
)
...
@@ -67,7 +68,7 @@ else:
...
@@ -67,7 +68,7 @@ else:
success
=
0
success
=
0
# Save the categories
# Save the categories
for
category
,
value
in
imported_line_category_dict
.
items
(
):
for
category
,
value
in
list
(
six
.
iteritems
(
imported_line_category_dict
)
):
category_dict
=
context
.
ERP5Site_getCategoriesFullPath
(
category_dict
=
context
.
ERP5Site_getCategoriesFullPath
(
category_dict
=
{
category
:
value
})
category_dict
=
{
category
:
value
})
if
category_dict
not
in
(
None
,
{}):
if
category_dict
not
in
(
None
,
{}):
...
...
product/ERP5OOo/tests/testOOoImport.py
View file @
81d05bb5
...
@@ -38,17 +38,21 @@ from Products.ERP5OOo.OOoUtils import OOoParser
...
@@ -38,17 +38,21 @@ from Products.ERP5OOo.OOoUtils import OOoParser
from
DateTime
import
DateTime
from
DateTime
import
DateTime
import
six
import
six
def
makeFilePath
(
name
):
def
makeFilePath
(
name
):
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'test_document'
,
name
)
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'test_document'
,
name
)
def
makeFileUpload
(
name
):
path
=
makeFilePath
(
name
)
return
FileUpload
(
path
,
name
)
class
TestOOoImportMixin
(
ERP5TypeTestCase
):
class
TestOOoImportMixin
(
ERP5TypeTestCase
):
gender_base_cat_id
=
'gender'
gender_base_cat_id
=
'gender'
function_base_cat_id
=
'function'
function_base_cat_id
=
'function'
def
makeFileUpload
(
self
,
name
):
path
=
makeFilePath
(
name
)
fu
=
FileUpload
(
path
,
name
)
self
.
addCleanup
(
fu
.
close
)
return
fu
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
"""
"""
Initialize the ERP5 site.
Initialize the ERP5 site.
...
@@ -91,6 +95,7 @@ class TestOOoImportMixin(ERP5TypeTestCase):
...
@@ -91,6 +95,7 @@ class TestOOoImportMixin(ERP5TypeTestCase):
self
.
portal
.
portal_categories
.
gender
,
self
.
portal
.
portal_categories
.
gender
,
self
.
portal
.
portal_categories
.
region
,
self
.
portal
.
portal_categories
.
region
,
]:
]:
parent
.
setLastId
(
'0'
)
parent
.
deleteContent
(
list
(
parent
.
objectIds
()))
parent
.
deleteContent
(
list
(
parent
.
objectIds
()))
self
.
tic
()
self
.
tic
()
...
@@ -119,7 +124,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -119,7 +124,7 @@ class TestOOoImport(TestOOoImportMixin):
## Basic steps
## Basic steps
##################################
##################################
def
stepImportRawDataFile
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportRawDataFile
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_list.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_list.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -285,7 +290,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -285,7 +290,7 @@ class TestOOoImport(TestOOoImportMixin):
sorted
([
organisation_list
[
i
].
getEmailText
()
for
i
in
range
(
num
)]))
sorted
([
organisation_list
[
i
].
getEmailText
()
for
i
in
range
(
num
)]))
def
stepImportFileNoMapping
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportFileNoMapping
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_list.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_list.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
...
@@ -302,7 +307,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -302,7 +307,7 @@ class TestOOoImport(TestOOoImportMixin):
'portal_status_message=Please%20Define%20a%20mapping.'
))
'portal_status_message=Please%20Define%20a%20mapping.'
))
def
stepImportFileWithBlankLine
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportFileWithBlankLine
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_list_blank_line.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_list_blank_line.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -317,7 +322,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -317,7 +322,7 @@ class TestOOoImport(TestOOoImportMixin):
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportFileWithCategory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportFileWithCategory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_with_categories.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_with_categories.ods'
)
# create some regions
# create some regions
region
=
self
.
portal
.
portal_categories
.
region
region
=
self
.
portal
.
portal_categories
.
region
europe
=
region
.
newContent
(
portal_type
=
'Category'
,
europe
=
region
.
newContent
(
portal_type
=
'Category'
,
...
@@ -343,7 +348,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -343,7 +348,7 @@ class TestOOoImport(TestOOoImportMixin):
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportFileWithDates
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportFileWithDates
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_with_dates.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_with_dates.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -362,7 +367,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -362,7 +367,7 @@ class TestOOoImport(TestOOoImportMixin):
This test make sure that either floats (1000,9), sientific numbers (1,00E+003)
This test make sure that either floats (1000,9), sientific numbers (1,00E+003)
or percentage (19%) are correctly imported .
or percentage (19%) are correctly imported .
"""
"""
f
=
makeFileUpload
(
'import_float_and_percentage.ods'
)
f
=
self
.
makeFileUpload
(
'import_float_and_percentage.ods'
)
currency_module
=
self
.
getPortal
().
currency_module
currency_module
=
self
.
getPortal
().
currency_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -373,7 +378,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -373,7 +378,7 @@ class TestOOoImport(TestOOoImportMixin):
currency_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
currency_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportOrganisation
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportOrganisation
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_organisation_list.ods'
)
f
=
self
.
makeFileUpload
(
'import_organisation_list.ods'
)
organisation_module
=
self
.
getPortal
().
organisation_module
organisation_module
=
self
.
getPortal
().
organisation_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -403,7 +408,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -403,7 +408,7 @@ class TestOOoImport(TestOOoImportMixin):
user
=
user_folder
.
getUserById
(
user_name
).
__of__
(
user_folder
)
user
=
user_folder
.
getUserById
(
user_name
).
__of__
(
user_folder
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
f
=
makeFileUpload
(
'import_data_with_categories.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_with_categories.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -420,7 +425,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -420,7 +425,7 @@ class TestOOoImport(TestOOoImportMixin):
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportFileWithFreeText
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportFileWithFreeText
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_with_categories.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_with_categories.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -435,7 +440,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -435,7 +440,7 @@ class TestOOoImport(TestOOoImportMixin):
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportFileWithAccentuatedText
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportFileWithAccentuatedText
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_accentuated_text.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_accentuated_text.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -450,7 +455,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -450,7 +455,7 @@ class TestOOoImport(TestOOoImportMixin):
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportXLSFile
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportXLSFile
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_list.xls'
)
f
=
self
.
makeFileUpload
(
'import_data_list.xls'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -465,7 +470,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -465,7 +470,7 @@ class TestOOoImport(TestOOoImportMixin):
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportBigFile_1
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportBigFile_1
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_big_file_1.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_big_file_1.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -480,7 +485,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -480,7 +485,7 @@ class TestOOoImport(TestOOoImportMixin):
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
person_module
.
Base_importFile
(
import_file
=
f
,
listbox
=
listbox
)
def
stepImportBigFile_2
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepImportBigFile_2
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
f
=
makeFileUpload
(
'import_data_big_file_2.ods'
)
f
=
self
.
makeFileUpload
(
'import_data_big_file_2.ods'
)
person_module
=
self
.
getPortal
().
person_module
person_module
=
self
.
getPortal
().
person_module
listbox
=
(
listbox
=
(
{
'listbox_key'
:
'001'
,
{
'listbox_key'
:
'001'
,
...
@@ -631,7 +636,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -631,7 +636,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_CategoryTool_importCategoryFile
(
self
):
def
test_CategoryTool_importCategoryFile
(
self
):
# tests simple use of CategoryTool_importCategoryFile script
# tests simple use of CategoryTool_importCategoryFile script
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category.sxc'
))
import_file
=
self
.
makeFileUpload
(
'import_region_category.sxc'
))
self
.
tic
()
self
.
tic
()
region
=
self
.
portal
.
portal_categories
.
region
region
=
self
.
portal
.
portal_categories
.
region
self
.
assertEqual
(
2
,
len
(
region
))
self
.
assertEqual
(
2
,
len
(
region
))
...
@@ -651,7 +656,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -651,7 +656,7 @@ class TestOOoImport(TestOOoImportMixin):
region
.
newContent
(
id
=
'dummy_region'
)
region
.
newContent
(
id
=
'dummy_region'
)
self
.
tic
()
self
.
tic
()
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category.sxc'
),
import_file
=
self
.
makeFileUpload
(
'import_region_category.sxc'
),
existing_category_list
=
'delete'
)
existing_category_list
=
'delete'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
2
,
len
(
region
))
self
.
assertEqual
(
2
,
len
(
region
))
...
@@ -674,7 +679,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -674,7 +679,7 @@ class TestOOoImport(TestOOoImportMixin):
)
)
self
.
tic
()
self
.
tic
()
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category.sxc'
),
import_file
=
self
.
makeFileUpload
(
'import_region_category.sxc'
),
existing_category_list
=
'delete'
)
existing_category_list
=
'delete'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
3
,
len
(
region
))
self
.
assertEqual
(
3
,
len
(
region
))
...
@@ -690,7 +695,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -690,7 +695,7 @@ class TestOOoImport(TestOOoImportMixin):
)
)
self
.
tic
()
self
.
tic
()
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category.sxc'
),
import_file
=
self
.
makeFileUpload
(
'import_region_category.sxc'
),
existing_category_list
=
'force_delete'
)
existing_category_list
=
'force_delete'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
2
,
len
(
region
))
self
.
assertEqual
(
2
,
len
(
region
))
...
@@ -702,7 +707,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -702,7 +707,7 @@ class TestOOoImport(TestOOoImportMixin):
region
.
newContent
(
id
=
'dummy_region'
)
region
.
newContent
(
id
=
'dummy_region'
)
self
.
tic
()
self
.
tic
()
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category.sxc'
),
import_file
=
self
.
makeFileUpload
(
'import_region_category.sxc'
),
existing_category_list
=
'expire'
)
existing_category_list
=
'expire'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
3
,
len
(
region
))
self
.
assertEqual
(
3
,
len
(
region
))
...
@@ -720,7 +725,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -720,7 +725,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_CategoryTool_importCategoryFileXLS
(
self
):
def
test_CategoryTool_importCategoryFileXLS
(
self
):
# tests that CategoryTool_importCategoryFile supports .xls files
# tests that CategoryTool_importCategoryFile supports .xls files
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category.xls'
))
import_file
=
self
.
makeFileUpload
(
'import_region_category.xls'
))
self
.
tic
()
self
.
tic
()
region
=
self
.
portal
.
portal_categories
.
region
region
=
self
.
portal
.
portal_categories
.
region
self
.
assertEqual
(
2
,
len
(
region
))
self
.
assertEqual
(
2
,
len
(
region
))
...
@@ -736,7 +741,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -736,7 +741,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_CategoryTool_importCategoryFile_PathStars
(
self
):
def
test_CategoryTool_importCategoryFile_PathStars
(
self
):
# tests CategoryTool_importCategoryFile with * in the paths columns
# tests CategoryTool_importCategoryFile with * in the paths columns
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category_path_stars.sxc'
))
import_file
=
self
.
makeFileUpload
(
'import_region_category_path_stars.sxc'
))
self
.
tic
()
self
.
tic
()
region
=
self
.
portal
.
portal_categories
.
region
region
=
self
.
portal
.
portal_categories
.
region
self
.
assertEqual
(
2
,
len
(
region
))
self
.
assertEqual
(
2
,
len
(
region
))
...
@@ -753,7 +758,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -753,7 +758,7 @@ class TestOOoImport(TestOOoImportMixin):
# tests CategoryTool_importCategoryFile with * in the paths columns, and no
# tests CategoryTool_importCategoryFile with * in the paths columns, and no
# ID column, and non ascii titles
# ID column, and non ascii titles
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
import_file
=
self
.
makeFileUpload
(
'import_region_category_path_stars_non_ascii.sxc'
))
'import_region_category_path_stars_non_ascii.sxc'
))
self
.
tic
()
self
.
tic
()
region
=
self
.
portal
.
portal_categories
.
region
region
=
self
.
portal
.
portal_categories
.
region
...
@@ -772,7 +777,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -772,7 +777,7 @@ class TestOOoImport(TestOOoImportMixin):
# categories ID at different level (a good candidate for an acquisition
# categories ID at different level (a good candidate for an acquisition
# bug)
# bug)
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category_duplicate_ids.sxc'
))
import_file
=
self
.
makeFileUpload
(
'import_region_category_duplicate_ids.sxc'
))
self
.
tic
()
self
.
tic
()
region
=
self
.
portal
.
portal_categories
.
region
region
=
self
.
portal
.
portal_categories
.
region
self
.
assertEqual
(
1
,
len
(
region
))
self
.
assertEqual
(
1
,
len
(
region
))
...
@@ -786,7 +791,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -786,7 +791,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_Base_getCategoriesSpreadSheetMapping
(
self
):
def
test_Base_getCategoriesSpreadSheetMapping
(
self
):
# test structure returned by Base_getCategoriesSpreadSheetMapping
# test structure returned by Base_getCategoriesSpreadSheetMapping
mapping
=
self
.
portal
.
Base_getCategoriesSpreadSheetMapping
(
mapping
=
self
.
portal
.
Base_getCategoriesSpreadSheetMapping
(
import_file
=
makeFileUpload
(
'import_region_category.sxc'
))
import_file
=
self
.
makeFileUpload
(
'import_region_category.sxc'
))
self
.
assertTrue
(
isinstance
(
mapping
,
dict
))
self
.
assertTrue
(
isinstance
(
mapping
,
dict
))
self
.
assertEqual
([
'region'
],
list
(
mapping
.
keys
()))
self
.
assertEqual
([
'region'
],
list
(
mapping
.
keys
()))
region
=
mapping
[
'region'
]
region
=
mapping
[
'region'
]
...
@@ -816,7 +821,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -816,7 +821,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_Base_getCategoriesSpreadSheetMapping_DuplicateIdsAtSameLevel
(
self
):
def
test_Base_getCategoriesSpreadSheetMapping_DuplicateIdsAtSameLevel
(
self
):
# tests Base_getCategoriesSpreadSheetMapping when a document contain same
# tests Base_getCategoriesSpreadSheetMapping when a document contain same
# categories ID at the same level, in that case, a ValueError is raised
# categories ID at the same level, in that case, a ValueError is raised
import_file
=
makeFileUpload
(
import_file
=
self
.
makeFileUpload
(
'import_region_category_duplicate_ids_same_level.sxc'
)
'import_region_category_duplicate_ids_same_level.sxc'
)
try
:
try
:
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
...
@@ -834,7 +839,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -834,7 +839,7 @@ class TestOOoImport(TestOOoImportMixin):
def
on_invalid_spreadsheet
(
message
):
def
on_invalid_spreadsheet
(
message
):
message_list
.
append
(
message
)
message_list
.
append
(
message
)
import_file
=
makeFileUpload
(
import_file
=
self
.
makeFileUpload
(
'import_region_category_duplicate_ids_same_level.sxc'
)
'import_region_category_duplicate_ids_same_level.sxc'
)
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
import_file
,
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
import_file
,
invalid_spreadsheet_error_handler
=
on_invalid_spreadsheet
)
invalid_spreadsheet_error_handler
=
on_invalid_spreadsheet
)
...
@@ -845,7 +850,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -845,7 +850,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_Base_getCategoriesSpreadSheetMapping_WrongHierarchy
(
self
):
def
test_Base_getCategoriesSpreadSheetMapping_WrongHierarchy
(
self
):
# tests Base_getCategoriesSpreadSheetMapping when the spreadsheet has an
# tests Base_getCategoriesSpreadSheetMapping when the spreadsheet has an
# invalid hierarchy (#788)
# invalid hierarchy (#788)
import_file
=
makeFileUpload
(
import_file
=
self
.
makeFileUpload
(
'import_region_category_wrong_hierarchy.sxc'
)
'import_region_category_wrong_hierarchy.sxc'
)
try
:
try
:
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
...
@@ -859,7 +864,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -859,7 +864,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_Base_getCategoriesSpreadSheetMapping_MultiplePaths
(
self
):
def
test_Base_getCategoriesSpreadSheetMapping_MultiplePaths
(
self
):
# If multiple paths is defined (for instance more than one * in paths
# If multiple paths is defined (for instance more than one * in paths
# columns), then it should be an error and the error must be reported
# columns), then it should be an error and the error must be reported
import_file
=
makeFileUpload
(
import_file
=
self
.
makeFileUpload
(
'import_region_category_multiple_paths.ods'
)
'import_region_category_multiple_paths.ods'
)
try
:
try
:
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
...
@@ -871,7 +876,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -871,7 +876,7 @@ class TestOOoImport(TestOOoImportMixin):
def
test_Base_getCategoriesSpreadSheetMapping_Id_is_reserved_property_name
(
self
):
def
test_Base_getCategoriesSpreadSheetMapping_Id_is_reserved_property_name
(
self
):
# tests Base_getCategoriesSpreadSheetMapping reserved property name are only test for path column, not all.
# tests Base_getCategoriesSpreadSheetMapping reserved property name are only test for path column, not all.
import_file
=
makeFileUpload
(
import_file
=
self
.
makeFileUpload
(
'import_region_category_with_reserved_id_in_title.sxc'
)
'import_region_category_with_reserved_id_in_title.sxc'
)
mapping
=
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
mapping
=
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
import_file
=
import_file
)
import_file
=
import_file
)
...
@@ -897,7 +902,7 @@ class TestOOoImport(TestOOoImportMixin):
...
@@ -897,7 +902,7 @@ class TestOOoImport(TestOOoImportMixin):
return
True
return
True
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
self
.
portal
.
portal_categories
.
Base_getCategoriesSpreadSheetMapping
(
import_file
=
makeFileUpload
(
'import_category_with_reserved_id_in_id.sxc'
),
import_file
=
self
.
makeFileUpload
(
'import_category_with_reserved_id_in_id.sxc'
),
invalid_spreadsheet_error_handler
=
on_invalid_spreadsheet
)
invalid_spreadsheet_error_handler
=
on_invalid_spreadsheet
)
self
.
assertEqual
(
message_set
,
{
self
.
assertEqual
(
message_set
,
{
...
@@ -948,7 +953,7 @@ class TestOOoImportWeb(TestOOoImportMixin):
...
@@ -948,7 +953,7 @@ class TestOOoImportWeb(TestOOoImportMixin):
dummy_expired_region
.
expire
()
dummy_expired_region
.
expire
()
self
.
tic
()
self
.
tic
()
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
self
.
portal
.
portal_categories
.
CategoryTool_importCategoryFile
(
import_file
=
makeFileUpload
(
'import_region_category.sxc'
),
import_file
=
self
.
makeFileUpload
(
'import_region_category.sxc'
),
existing_category_list
=
'expire'
)
existing_category_list
=
'expire'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
4
,
len
(
region
))
self
.
assertEqual
(
4
,
len
(
region
))
...
...
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