Commit 0ec51b6e authored by Iliya Manolov's avatar Iliya Manolov

[jupyter] Added tests for required eggs

parent 583ed6e7
......@@ -72,6 +72,23 @@ class TestExecuteJupyter(ERP5TypeTestCase):
notebook_code=notebook_code,
batch_mode=True
)
def checkEgg(self, import_code):
'''
Returns whether an egg is available.
'''
reference = 'Test.Notebook.EnvironmentObject.Errors.EggImport'
result = self.portal.Base_executeJupyter(
reference=reference,
python_expression=import_code
)
self.tic()
result = json.loads(result)
return result['status'] == 'ok'
def testJupyterCompileErrorRaise(self):
"""
......@@ -990,4 +1007,32 @@ print os.path
self.tic()
result = json.loads(result)
self.assertEquals(result['status'], 'ok')
\ No newline at end of file
self.assertEquals(result['status'], 'ok')
def testEggs(self):
'''
Test whether essential modules are available.
'''
self.login('dev_user')
egg_list = ['scipy', 'sklearn', 'pandas', 'matplotlib', 'math', 'sympy',
'pylab', 'openpyxl', 'statsmodels', 'datetime', 'h5py']
result_dict = {}
final_output = 'The following eggs can not be imported by Jupyter: '
noErrors = True
for egg in egg_list:
result_dict[egg] = (self.checkEgg('import %s as _' %egg))
noErrors = result_dict[egg] and noErrors
if noErrors:
final_output = 'Success'
else:
for egg, result in result_dict.iteritems():
if result is False:
final_output += ('%s, ' %egg)
final_output = final_output[:-2]
self.assertEquals(final_output, 'Success')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment