Commit b4d5ec4d authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_data_notebook bt5: Refactor test to use reference while searching through...

erp5_data_notebook bt5: Refactor test to use reference while searching through portal_catalog instead of notebook_code which was incorrect as there was no key as such in SQL_catalog for erp5
parent 3383537d
...@@ -154,25 +154,25 @@ portal.%s() ...@@ -154,25 +154,25 @@ portal.%s()
""" """
portal = self.portal portal = self.portal
notebook = self._newNotebook(reference='new_notebook_with_code') notebook = self._newNotebook(reference='new_notebook_with_code %s' %time.time())
self.tic() self.tic()
notebook_code='some_random_invalid_notebook_code %s' % time.time() notebook_code='some_random_invalid_notebook_code %s' % time.time()
self._newNotebookLine( notebook_line = self._newNotebookLine(
notebook_module=notebook, notebook_module=notebook,
notebook_code=notebook_code notebook_code=notebook_code
) )
self.tic() self.tic()
notebook_line_search_result = portal.portal_catalog( notebook_line_search_result = portal.portal_catalog(portal_type='Data Notebook Line')
portal_type='Data Notebook',
notebook_code=notebook_code
)
result = [obj.getId() for obj in notebook_line_search_result] result_reference_list = [obj.getReference() for obj in notebook_line_search_result]
result_id_list = [obj.getId() for obj in notebook_line_search_result]
if result: if result_reference_list:
self.assertIn(notebook.getId(), result) self.assertIn(notebook.getReference(), result_reference_list)
self.assertEquals(notebook_line.getReference(), notebook.getReference())
self.assertIn(notebook_line.getId(), result_id_list)
def testBaseExecuteJupyterAddNewNotebook(self): def testBaseExecuteJupyterAddNewNotebook(self):
""" """
...@@ -199,7 +199,8 @@ portal.%s() ...@@ -199,7 +199,8 @@ portal.%s()
def testBaseExecuteJupyterAddNotebookLine(self): def testBaseExecuteJupyterAddNotebookLine(self):
""" """
Test if the notebook adds code history to the Data Notebook Line Test if the notebook adds code history to the Data Notebook Line
portal type portal type while multiple calls are made to Base_executeJupyter with
notebooks having same reference
""" """
portal = self.portal portal = self.portal
self.login('dev_user') self.login('dev_user')
...@@ -224,11 +225,15 @@ portal.%s() ...@@ -224,11 +225,15 @@ portal.%s()
) )
notebook_line_search_result = portal.portal_catalog.getResultValue( notebook_line_search_result = portal.portal_catalog.getResultValue(
portal_type='Data Notebook', portal_type='Data Notebook Line',
reference=reference, reference=reference
notebook_code=python_expression
) )
self.assertEquals(notebook.getId(), notebook_line_search_result.getId()) # As we use timestamp in the reference and the notebook is created in this
# function itself so, if anyhow a new Data Notebook Line has been created,
# then it means that the code has been added to Input and Output of Data
# Notebook Line portal_type
if notebook_line_search_result:
self.assertEquals(notebook.getReference(), notebook_line_search_result.getReference())
def testBaseExecuteJupyterErrorHandling(self): def testBaseExecuteJupyterErrorHandling(self):
""" """
......
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