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
Yusei Tahara
erp5
Commits
89eae304
Commit
89eae304
authored
Nov 21, 2013
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_research_item: add unit tests on report listing tasks total time per person on research items
parent
884bb461
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
340 additions
and
12 deletions
+340
-12
bt5/erp5_research_item/SkinTemplateItem/portal_skins/erp5_research_item/ResearchItemModule_callResearchSummaryReport.xml
...rch_item/ResearchItemModule_callResearchSummaryReport.xml
+13
-10
bt5/erp5_research_item/TestTemplateItem/portal_components/test.erp5.testResearchItemSummaryReport.py
...tal_components/test.erp5.testResearchItemSummaryReport.py
+168
-0
bt5/erp5_research_item/TestTemplateItem/portal_components/test.erp5.testResearchItemSummaryReport.xml
...al_components/test.erp5.testResearchItemSummaryReport.xml
+150
-0
bt5/erp5_research_item/bt/revision
bt5/erp5_research_item/bt/revision
+1
-1
bt5/erp5_research_item/bt/template_test_id_list
bt5/erp5_research_item/bt/template_test_id_list
+1
-0
product/ERP5/tests/testTaskReporting.py
product/ERP5/tests/testTaskReporting.py
+7
-1
No files found.
bt5/erp5_research_item/SkinTemplateItem/portal_skins/erp5_research_item/ResearchItemModule_callResearchSummaryReport.xml
View file @
89eae304
...
...
@@ -63,7 +63,6 @@ if multiplier is None:\n
\n
portal = context.getPortalObject()\n
\n
portal = context.getPortalObject()\n
simulation_state_set = set(simulation_state_list)\n
# We will use inventory API in order to find all quantities\n
before_confirmed_task_state_set = set(portal.getPortalPlannedOrderStateList() + \\\n
...
...
@@ -150,14 +149,18 @@ column_url_script_list = []\n
for item_url in item_title_dict.keys():\n
column_url_script_list.append((item_url, "getColumnUrl"))\n
\n
context = context.asContext(column_list=column_list,\n
at_date=at_date,\n
from_date=from_date,\n
simulation_state_list=simulation_state_list,\n
column_url_script_list=column_url_script_list,\n
journal=journal,\n
multiplier=multiplier,\n
listbox_line_list=listbox_line_list)\n
context_kw = {}\n
context_kw.update(column_list=column_list,\n
at_date=at_date,\n
from_date=from_date,\n
simulation_state_list=simulation_state_list,\n
column_url_script_list=column_url_script_list,\n
journal=journal,\n
multiplier=multiplier,\n
listbox_line_list=listbox_line_list)\n
context = context.getObject().asContext(**context_kw)\n
if batch_mode:\n
return context\n
return context.ResearchItemModule_viewResearchSummaryReportData()\n
...
...
@@ -165,7 +168,7 @@ return context.ResearchItemModule_viewResearchSummaryReportData()\n
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
at_date=None, from_date=None, simulation_state_list=None, journal=None, multiplier=None, **kw
</string>
</value>
<value>
<string>
at_date=None, from_date=None, simulation_state_list=None, journal=None, multiplier=None,
batch_mode=False,
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_research_item/TestTemplateItem/portal_components/test.erp5.testResearchItemSummaryReport.py
0 → 100644
View file @
89eae304
##############################################################################
#
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
DateTime
import
DateTime
from
Products.ERP5.tests.testTaskReporting
import
TestTaskReportingMixin
class
TestResearchItemSummaryReport
(
TestTaskReportingMixin
):
"""
Test Research Items Reports
"""
def
getTitle
(
self
):
return
"ResearchItemSummaryReport"
def
afterSetUp
(
self
):
"""Make sure to initialize needed categories
"""
super
(
TestResearchItemSummaryReport
,
self
).
afterSetUp
()
journal_base_category
=
self
.
portal
.
portal_categories
.
journal
for
category_id
in
(
"operation"
,
"research"
):
if
not
journal_base_category
.
has_key
(
category_id
):
journal_base_category
.
newContent
(
portal_type
=
'Category'
,
title
=
unit_id
.
title
(),
reference
=
category_id
,
id
=
category_id
)
# create items
if
not
self
.
portal
.
research_item_module
.
has_key
(
'Item_1'
):
self
.
portal
.
research_item_module
.
newContent
(
title
=
"Item_1"
,
id
=
"Item_1"
,
portal_type
=
"Research Item"
)
if
not
self
.
portal
.
research_item_module
.
has_key
(
'Item_2'
):
self
.
portal
.
research_item_module
.
newContent
(
title
=
"Item_2"
,
id
=
"Item_2"
,
portal_type
=
"Research Item"
)
def
getBusinessTemplateList
(
self
):
"""
Tuple of Business Templates we need to install
"""
bt_list
=
super
(
TestResearchItemSummaryReport
,
self
).
getBusinessTemplateList
()
return
list
(
bt_list
)
+
[
"erp5_research_item"
]
def
_makeOneTask
(
self
,
**
kw
):
task
=
super
(
TestResearchItemSummaryReport
,
self
).
_makeOneTask
(
resource
=
'product_module/development'
,
source_section
=
'organisation_module/Organisation_1'
,
destination
=
'organisation_module/Organisation_2'
,
destination_section
=
'organisation_module/Organisation_2'
,
source_project
=
'project_module/Project_1/Line_1'
,
start_date
=
DateTime
(
'2013/01/10'
),
stop_date
=
DateTime
(
'2013/02/15'
),
journal
=
"research"
,
simulation_state
=
"confirmed"
,
**
kw
)
return
task
def
testResearchSummaryReport
(
self
):
"""
Test research summary report available on item research module
"""
report
=
self
.
portal
.
research_item_module
.
ResearchItemModule_callResearchSummaryReport
def
callReport
():
return
report
(
from_date
=
from_date
,
at_date
=
at_date
,
batch_mode
=
True
,
journal
=
"research"
,
simulation_state_list
=
[
"confirmed"
])
def
getDataResult
(
result
):
data_list
=
[]
column_id_list
=
[
x
[
0
]
for
x
in
result
.
column_list
]
self
.
assertEquals
(
column_id_list
[
0
],
"source_title"
)
self
.
assertEquals
(
column_id_list
[
-
1
],
"total"
)
column_id_list
.
pop
(
0
)
column_id_list
.
pop
(
-
1
)
column_id_list
.
sort
()
column_id_list
=
[
"source_title"
]
+
column_id_list
+
[
"total"
]
for
line
in
result
.
listbox_line_list
:
line_data
=
[]
for
property_name
in
column_id_list
:
line_data
.
append
(
line
.
getProperty
(
property_name
))
data_list
.
append
(
line_data
)
data_list
.
sort
(
key
=
lambda
x
:
x
[
0
])
column_list
=
[
x
for
x
in
result
.
column_list
]
column_list
.
sort
(
key
=
lambda
x
:
column_id_list
.
index
(
x
[
0
]))
return
[
x
[
1
]
for
x
in
column_list
],
data_list
# First call it when it is empty
from_date
=
DateTime
(
"2013/01/01"
)
at_date
=
DateTime
(
"2014/01/01"
)
result
=
callReport
()
# Initially we should have only one line for an empty total
self
.
assertEquals
(([
"Worker"
,
"Total"
],
[[
"Total"
,
None
]]),
getDataResult
(
result
))
# Then create one task with no item, see if we it is displayed in the report
self
.
_makeOneTask
(
title
=
'Task 1'
,
task_line_quantity
=
3
,
source
=
'person_module/Person_1'
,
)
result
=
callReport
()
self
.
assertEquals
(([
"Worker"
,
"undefined"
,
"Total"
],
[[
"Person_1"
,
3
,
3
],
[
"Total"
,
3
,
3
]]),
getDataResult
(
result
))
# Then create one task with item, see if we it is displayed in the report
self
.
_makeOneTask
(
title
=
'Task 2'
,
task_line_quantity
=
5.2
,
source
=
'person_module/Person_2'
,
line_aggregate_relative_url
=
'research_item_module/Item_1'
,
)
result
=
callReport
()
self
.
assertEquals
(([
"Worker"
,
"undefined"
,
"Item_1"
,
"Total"
],
[[
"Person_1"
,
3
,
None
,
3
],
[
"Person_2"
,
None
,
5.2
,
5.2
],
[
"Total"
,
3
,
5.2
,
8.2
]]),
getDataResult
(
result
))
# 3 additional tasks to check sums
self
.
_makeOneTask
(
title
=
'Task 3'
,
task_line_quantity
=
2.4
,
source
=
'person_module/Person_2'
,
line_aggregate_relative_url
=
'research_item_module/Item_1'
,
)
self
.
_makeOneTask
(
title
=
'Task 4'
,
task_line_quantity
=
1.7
,
source
=
'person_module/Person_1'
,
line_aggregate_relative_url
=
'research_item_module/Item_2'
,
)
self
.
_makeOneTask
(
title
=
'Task 5'
,
task_line_quantity
=
0.9
,
source
=
'person_module/Person_2'
,
line_aggregate_relative_url
=
'research_item_module/Item_2'
,
)
result
=
callReport
()
self
.
assertEquals
(([
"Worker"
,
"undefined"
,
"Item_1"
,
"Item_2"
,
"Total"
],
[[
"Person_1"
,
3
,
None
,
1.7
,
4.7
],
[
"Person_2"
,
None
,
7.6
,
0.9
,
8.5
],
[
"Total"
,
3
,
7.6
,
2.6
,
13.2
]]),
getDataResult
(
result
))
bt5/erp5_research_item/TestTemplateItem/portal_components/test.erp5.testResearchItemSummaryReport.xml
0 → 100644
View file @
89eae304
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testResearchItemSummaryReport
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testResearchItemSummaryReport
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
seb
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1385030033.93
</float>
<string>
GMT+1
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
bt5/erp5_research_item/bt/revision
View file @
89eae304
6
\ No newline at end of file
8
\ No newline at end of file
bt5/erp5_research_item/bt/template_test_id_list
0 → 100644
View file @
89eae304
test.erp5.testResearchItemSummaryReport
\ No newline at end of file
product/ERP5/tests/testTaskReporting.py
View file @
89eae304
...
...
@@ -44,15 +44,21 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
'erp5_project'
,
'erp5_simulation_test'
)
@
reindex
def
_makeOneTask
(
self
,
simulation_state
=
'planned'
,
**
kw
):
def
_makeOneTask
(
self
,
simulation_state
=
'planned'
,
line_aggregate_relative_url
=
None
,
**
kw
):
"""Create a task, support many options"""
task
=
self
.
portal
.
task_module
.
newContent
(
portal_type
=
'Task'
,
specialise
=
self
.
business_process
)
task
.
_edit
(
**
kw
)
if
line_aggregate_relative_url
:
task_line
,
=
task
.
objectValues
(
portal_type
=
"Task Line"
)
task_line
.
setAggregate
(
line_aggregate_relative_url
)
if
simulation_state
==
'planned'
:
task
.
plan
()
if
simulation_state
==
'confirmed'
:
task
.
confirm
()
return
task
def
afterSetUp
(
self
):
"""Setup the fixture.
...
...
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