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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
erp5
Commits
9d713deb
Commit
9d713deb
authored
Oct 06, 2015
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_data_notebook bt5: Add test for Error Handling from JupyterCompile portal_component
parent
0f361067
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
...ateItem/portal_components/test.erp5.testExecuteJupyter.py
+74
-0
No files found.
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
View file @
9d713deb
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
from
Products.ERP5Type.tests.SecurityTestCase
import
SecurityTestCase
from
Products.ERP5Type.tests.SecurityTestCase
import
SecurityTestCase
from
Products.ERP5Type.tests.utils
import
addUserToDeveloperRole
from
Products.ERP5Type.tests.utils
import
addUserToDeveloperRole
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
import
time
import
time
import
json
import
json
...
@@ -68,6 +69,79 @@ class TestExecuteJupyter(SecurityTestCase):
...
@@ -68,6 +69,79 @@ class TestExecuteJupyter(SecurityTestCase):
batch_mode
=
True
batch_mode
=
True
)
)
def
testJupyterCompileErrorHandling
(
self
):
"""
Test if JupyterCompile portal_component can handle error in efficinet way.
Take the case in wich one line in a statement is valid and another is not.
"""
portal
=
self
.
getPortalObject
()
script_id
=
"JupyterCompile_errorResult"
script_container
=
portal
.
portal_skins
.
custom
new_test_title
=
"Wendelin Test"
# Check if the existing title is different from new_test_title or not
if
portal
.
getTitle
()
==
new_test_title
:
new_test_title
=
"Wenedlin"
python_script
=
"""
context.setTitle('%s')
print an_undefined_variable
"""
%
new_test_title
# Create python_script object with the above given code and containers
createZODBPythonScript
(
script_container
,
script_id
,
''
,
python_script
)
# Call the above created script in jupyter_code
jupyter_code
=
"""
portal = context.getPortalObject()
portal.%s()
"""
%
script_id
# Make call to Base_runJupyter to run the jupyter code which is making
# a call to the newly created ZODB pyton_script
result
=
portal
.
Base_runJupyter
(
jupyter_code
=
jupyter_code
,
old_local_variable_dict
=
{})
# Test if the status of returned messgae from Base_runJupyter call is 'error'
self
.
assertEquals
(
result
[
'status'
],
'error'
)
# Test that calling Base_runJupyter shouldn't change the context Title
self
.
assertNotEqual
(
portal
.
getTitle
(),
new_test_title
)
def
testJupyterCompileErrorHandlingForTransactionAndNormalPythonScript
(
self
):
"""
Test Base_runJupyter for error handling in case python_script contains simple
python code(addition an setting varibale value) as well as transaction.
We expect that the local varibles a,b,c shouldn't set themselves due to failure
in transaction.
"""
portal
=
self
.
getPortalObject
()
new_test_title
=
"Wendelin Test"
# Check if the existing title is different from new_test_title or not
if
portal
.
getTitle
()
==
new_test_title
:
new_test_title
=
"Wenedlin"
# Python script where we use transaction as well as normal python variables
jupyter_code
=
"""
a = 1
b = 2
context.setTitle('%s')
c = a+b
print c
print an_undefined_variable
"""
%
new_test_title
# Make call to Base_runJupyter to run the jupyter code which is making
# a call to the newly created ZODB pyton_script
result
=
portal
.
Base_runJupyter
(
jupyter_code
=
jupyter_code
,
old_local_variable_dict
=
{})
# Test if the status of returned messgae from Base_runJupyter call is 'error'
self
.
assertEquals
(
result
[
'status'
],
'error'
)
# Test that calling Base_runJupyter shouldn't change the context Title
self
.
assertNotEqual
(
portal
.
getTitle
(),
new_test_title
)
# Test if the local variables a, b, c are set for there values or not
local_variable_list
=
[
'a'
,
'b'
,
'c'
]
self
.
assertFalse
(
set
(
local_variable_list
).
issubset
(
set
(
result
[
'local_variable_dict'
].
keys
())))
def
testUserCannotAccessBaseExecuteJupyter
(
self
):
def
testUserCannotAccessBaseExecuteJupyter
(
self
):
"""
"""
Test if non developer user can't access Base_executeJupyter
Test if non developer user can't access Base_executeJupyter
...
...
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