def test_editresultfigures_remove_session(self): """ Tests result dictionary has the expected keys / values and call to `editresultfigures` correctly redirects to '/project/figure/displayresultfigures' on session removal """ cherrypy.request.method = 'POST' TestFactory.create_figure(self.operation.id, self.test_user.id, self.test_project.id, name="figure1", path="path-to-figure1", session_name="test") TestFactory.create_figure(self.operation.id, self.test_user.id, self.test_project.id, name="figure2", path="path-to-figure2", session_name="test") figs, _ = dao.get_previews(self.test_project.id, self.test_user.id, "test") self.assertEqual(len(figs['test']), 2) data = {'old_session_name': 'test', 'new_session_name': 'test_renamed'} self._expect_redirect('/project/figure/displayresultfigures', self.figure_c.editresultfigures, remove_session=True, **data) figs, previews = dao.get_previews(self.test_project.id, self.test_user.id, "test") self.assertEqual(len(figs['test']), 0) self.assertEqual(previews, {})
def test_displayresultfigures(self): """ Tests result dictionary for the expected key/value """ figure1 = TestFactory.create_figure(self.operation.id, self.test_user.id, self.test_project.id, name="figure1", path="path-to-figure1", session_name="test") figure2 = TestFactory.create_figure(self.operation.id, self.test_user.id, self.test_project.id, name="figure2", path="path-to-figure2", session_name="test") result_dict = self.figure_c.displayresultfigures() figures = result_dict['selected_sessions_data']['test'] self.assertEqual(set([fig.id for fig in figures]), {figure1.id, figure2.id})
def test_editresultfigures_rename_session(self): """ Tests result dictionary has the expected keys / values and call to `editresultfigures` correctly redirects to '/project/figure/displayresultfigures' on session renaming """ cherrypy.request.method = 'POST' TestFactory.create_figure(self.operation.id, self.test_user.id, self.test_project.id, name="figure1", path="path-to-figure1", session_name="test") TestFactory.create_figure(self.operation.id, self.test_user.id, self.test_project.id, name="figure2", path="path-to-figure2", session_name="test") figs, _ = dao.get_previews(self.test_project.id, self.test_user.id, "test") self.assertEqual(len(figs['test']), 2) data = {'old_session_name': 'test', 'new_session_name': 'test_renamed'} self._expect_redirect('/project/figure/displayresultfigures', self.figure_c.editresultfigures, rename_session=True, **data) figs, previews = dao.get_previews(self.test_project.id, self.test_user.id, "test") self.assertEqual(len(figs['test']), 0) self.assertEqual(previews['test_renamed'], 2)
def test_editresultfigures_remove_fig(self): """ Tests call to `editresultfigures` correctly redirects to '/project/figure/displayresultfigures' on figure removal """ cherrypy.request.method = 'POST' figure1 = TestFactory.create_figure(self.operation.id, self.test_user.id, self.test_project.id, name="figure1", path="path-to-figure1", session_name="test") figs = dao.get_figures_for_operation(self.operation.id) self.assertEqual(len(figs), 1) data = {'figure_id': figure1.id} self._expect_redirect('/project/figure/displayresultfigures', self.figure_c.editresultfigures, remove_figure=True, **data) figs = dao.get_figures_for_operation(self.operation.id) self.assertEqual(len(figs), 0)