Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cloud-consulting
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
cloud-consulting
Commits
d76ca7a4
Commit
d76ca7a4
authored
Nov 04, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addes tests for category_dict
parent
05589731
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
2 deletions
+75
-2
product/ERP5Survey/tests/testQuestionnaire.py
product/ERP5Survey/tests/testQuestionnaire.py
+75
-2
No files found.
product/ERP5Survey/tests/testQuestionnaire.py
View file @
d76ca7a4
...
...
@@ -24,6 +24,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
import
json
import
unittest
import
os
import
random
...
...
@@ -2234,13 +2235,85 @@ class TestQuestionnaire(ERP5TypeTestCase):
answer_set
=
self
.
_newAnswerSet
(
person
=
author
)
answer_set_remove_list
.
append
(
answer_set
.
getId
())
question_state
=
self
.
_newQuestionState
(
questionnaire
=
questionnaire
,
question
=
question
)
answer_set
.
setCurrentStateValue
(
question_state
)
answer
=
self
.
_newAnswer
(
answer_set
=
answer_set
,
question
=
question
)
self
.
assertNotEquals
(
None
,
questionnaire
)
self
.
assertEquals
(
None
,
answer
.
getCategoryDict
())
self
.
_newQuestionState
(
questionnaire
=
questionnaire
,
question
=
question
)
self
.
_answerQuestion
(
question
=
question
,
answer_set
=
answer_set
)
self
.
assertEquals
(
None
,
answer
.
getCategoryDict
())
# empty spreadsheet
metadata
=
{
'metadata'
:
{
'widths'
:
[
'15'
,
'15'
,
'15'
,
'15'
,
'100'
,
'150'
,
'100'
,
'200'
],
'frozenAt'
:
{
'col'
:
0
,
'row'
:
0
}}}
data
=
json
.
dumps
([{
'title'
:
'function'
,
'rows'
:
[],
'metadata'
:
metadata
}])
resp
=
answer
.
sheet_editor_save
(
data
=
data
)
self
.
assertEqual
(
resp
,
'Categories have been saved
\
n
'
)
self
.
assertEquals
({
'function'
:
[]},
answer
.
getCategoryDict
())
# category path in wrong column
rows
=
[{
'columns'
:
[{},
{},
{},
{},
{},
{},
{},
{}],
'height'
:
18
},
{
'columns'
:
[{},
{
'value'
:
'*'
},
{},
{},
{
'value'
:
'banking'
},
{
'value'
:
'Banking and Finance'
}],
'height'
:
18
}]
data
=
json
.
dumps
([{
'title'
:
'activity'
,
'rows'
:
rows
,
'metadata'
:
metadata
}])
resp
=
answer
.
sheet_editor_save
(
data
=
data
)
self
.
assertEqual
(
resp
,
''
)
# XXX how can we test status=400 and related error messages?
self
.
assertEquals
({
'function'
:
[]},
answer
.
getCategoryDict
())
# category path in right column
rows
=
[{
'columns'
:
[{},
{},
{},
{},
{},
{},
{},
{}],
'height'
:
18
},
{
'columns'
:
[{
'value'
:
'*'
},
{},
{},
{},
{
'value'
:
'industry'
},
{
'value'
:
'Industry'
}],
'height'
:
18
}]
data
=
json
.
dumps
([{
'title'
:
'activity'
,
'rows'
:
rows
,
'metadata'
:
metadata
}])
resp
=
answer
.
sheet_editor_save
(
data
=
data
)
self
.
assertEqual
(
resp
,
'Categories have been saved
\
n
'
)
self
.
assertEquals
({
'activity'
:
[{
'path'
:
'activity/industry'
,
'id'
:
'industry'
,
'title'
:
'Industry'
}]},
answer
.
getCategoryDict
())
self
.
clear_module_list
=
[
self
.
question_module
,
question_remove_list
,
self
.
answer_set_module
,
answer_set_remove_list
]
# lots of stuff
data
=
(
"""[{"title":"function","rows":[],"metadata":{"widths":["15","15","15","15","100","150","100","200"],"frozenAt":{"row":0,"col":0}}},"""
"""{"title":"product_line","rows":[],"metadata":{"widths":["15","15","15","15","100","150","100","200"],"frozenAt":{"row":0,"col":0}}},"""
"""{"title":"group","rows":[],"metadata":{"widths":["15","15","15","15","100","150","100","200"],"frozenAt":{"row":0,"col":0}}},"""
"""{"title":"grade","rows":[{"height":18,"columns":[{"value":"*"},{},{},{},{"value":"employee"},{"value":"Employee"},{},{}]},{"height":18,"""
""""columns":[{"value":"*"},{},{},{},{"value":"trainee"},{"value":"Trainee"}]}],"metadata":{"widths":["15","15","15","15","100","150","100","""
""""200"],"frozenAt":{"row":0,"col":0}}},{"title":"region","rows":[],"metadata":{"widths":["15","15","15","15","100","150","100","200"],"""
""""frozenAt":{"row":0,"col":0}}},{"title":"site","rows":[],"metadata":{"widths":["15","15","15","15","100","150","100","200"],"frozenAt":"""
"""{"row":0,"col":0}}},{"title":"publication_section","rows":[{"height":18,"columns":[{"value":"*"},{},{},{},{"value":"marketing"},{"value":"""
""""Marketing"},{},{}]},{"height":18,"columns":[{},{"value":"*"},{},{},{"value":"kallimachos"},{"value":"Kallimachos"},{},{}]},{"height":18,"""
""""columns":[{"value":"*"},{},{},{},{"value":"documentation"},{"value":"Documentation"},{},{}]},{"height":18,"columns":[{"value":"*"},{},{},{},"""
"""{"value":"contract"},{"value":"Contracts"},{},{}]},{"height":18,"columns":[{},{"value":"*"},{},{},{"value":"sale"},{"value":"Sales"}]}],"metadata":"""
"""{"widths":["15","15","15","15","100","150","100","200"],"frozenAt":{"row":0,"col":0}}},{"title":"role","rows":[],"metadata":{"widths":"""
"""["15","15","15","15","100","150","100","200"],"frozenAt":{"row":0,"col":0}}},{"title":"activity","rows":[{"height":18,"columns":[{"value":"*"}"""
""",{},{},{},{"value":"education"},{"value":"Education"},{},{}]},{"height":18,"columns":[{},{"value":"*"},{},{},{"value":"school"},{"value":"School"}]}],"""
""""metadata":{"widths":["15","15","15","15","100","150","100","200"],"frozenAt":{"row":0,"col":0}}},{"title":"nationality","rows":[],"metadata":{"widths":"""
"""["15","15","15","15","100","150","100","200"],"frozenAt":{"row":0,"col":0}}},{"title":"skill","rows":[],"metadata":{"widths":["15","15","15","15","""
""""100","150","100","200"],"frozenAt":{"row":0,"col":0}}}]"""
)
resp
=
answer
.
sheet_editor_save
(
data
=
data
)
self
.
assertEqual
(
resp
,
'Categories have been saved
\
n
'
)
self
.
assertEquals
(
{
'function'
:
[],
'product_line'
:
[],
'group'
:
[],
'grade'
:
[{
'path'
:
'grade/employee'
,
'id'
:
'employee'
,
'title'
:
'Employee'
},
{
'path'
:
'grade/trainee'
,
'id'
:
'trainee'
,
'title'
:
'Trainee'
}],
'region'
:
[],
'site'
:
[],
'publication_section'
:
[
{
'path'
:
'publication_section/marketing'
,
'id'
:
'marketing'
,
'title'
:
'Marketing'
},
{
'path'
:
'publication_section/marketing/kallimachos'
,
'id'
:
'kallimachos'
,
'title'
:
'Kallimachos'
},
{
'path'
:
'publication_section/documentation'
,
'id'
:
'documentation'
,
'title'
:
'Documentation'
},
{
'path'
:
'publication_section/contract'
,
'id'
:
'contract'
,
'title'
:
'Contracts'
},
{
'path'
:
'publication_section/contract/sale'
,
'id'
:
'sale'
,
'title'
:
'Sales'
}
],
'role'
:
[],
'activity'
:
[{
'path'
:
'activity/education'
,
'id'
:
'education'
,
'title'
:
'Education'
},
{
'path'
:
'activity/education/school'
,
'id'
:
'school'
,
'title'
:
'School'
}],
'nationality'
:
[],
'skill'
:
[]
},
answer
.
getCategoryDict
())
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