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
Amer
erp5
Commits
5f458f4c
Commit
5f458f4c
authored
Nov 08, 2015
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_dat_notebook bt5: Add test for module imports and Base_saveImage
parent
197e24c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
2 deletions
+63
-2
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
...ateItem/portal_components/test.erp5.testExecuteJupyter.py
+63
-2
No files found.
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
View file @
5f458f4c
...
...
@@ -25,15 +25,16 @@
#
##############################################################################
from
Products.ERP5Type.tests.
SecurityTestCase
import
Security
TestCase
from
Products.ERP5Type.tests.
ERP5TypeTestCase
import
ERP5Type
TestCase
from
Products.ERP5Type.tests.utils
import
addUserToDeveloperRole
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
,
removeZODBPythonScript
import
time
import
json
import
base64
import
transaction
class
TestExecuteJupyter
(
Security
TestCase
):
class
TestExecuteJupyter
(
ERP5Type
TestCase
):
def
afterSetUp
(
self
):
"""
...
...
@@ -332,3 +333,63 @@ portal.%s()
expected_result
=
portal
.
getTitle
()
self
.
assertEquals
(
json
.
loads
(
result
)[
'code_result'
].
rstrip
(),
expected_result
)
def
testSavingModuleObjectLocalVariables
(
self
):
"""
Test to check the saving of module objects in local_variable_dict
and if they work as expected.
"""
portal
=
self
.
portal
self
.
login
(
'dev_user'
)
jupyter_code
=
"""
import imghdr as imh
import sys
"""
reference
=
'Test.Notebook.ModuleObject %s'
%
time
.
time
()
portal
.
Base_executeJupyter
(
reference
=
reference
,
python_expression
=
jupyter_code
)
self
.
tic
()
jupyter_code
=
"print imh.__name__"
result
=
portal
.
Base_executeJupyter
(
reference
=
reference
,
python_expression
=
jupyter_code
)
self
.
assertEquals
(
json
.
loads
(
result
)[
'code_result'
].
rstrip
(),
'imghdr'
)
self
.
assertEquals
(
json
.
loads
(
result
)[
'mime_type'
].
rstrip
(),
'text/plain'
)
def
testBaseDisplayImageERP5Image
(
self
):
"""
Test the fucntioning of Base_displayImage external method of erp5_data_notebook
BT5 for ERP5 image object as parameter and change
"""
self
.
image_module
=
self
.
portal
.
getDefaultModule
(
'Image'
)
self
.
assertTrue
(
self
.
image_module
is
not
None
)
# Create a new ERP5 image object
reference
=
'testBase_displayImageReference'
data
=
'qwertyuiopasdfghjklzxcvbnm<somerandomcharacterstosaveasimagedata>'
self
.
image_module
.
newContent
(
portal_type
=
'Image'
,
id
=
'testBase_displayImageID'
,
reference
=
reference
,
data
=
data
,
filename
=
'test.png'
)
self
.
tic
()
# Call Base_displayImage from inside of Base_runJupyter
jupyter_code
=
"""
image = context.portal_catalog.getResultValue(portal_type='Image',reference=%s)
context.Base_displayImage(image_object=image)
"""
%
reference
local_variable_dict
=
{
'imports'
:
{},
'variables'
:
{}}
result
=
self
.
portal
.
Base_runJupyter
(
jupyter_code
=
jupyter_code
,
old_local_variable_dict
=
local_variable_dict
)
self
.
assertEquals
(
result
[
'result_string'
],
base64
.
b64encode
(
data
))
self
.
assertEquals
(
result
[
'mime_type'
],
'image/png'
)
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