def test_bokeh_row_error(self, mock_tethys, mock_scheduler, mock_bokeh, mock_log): mock_job = mock.MagicMock() mock_job.status = 'test_status' mock_job.scheduler_id = 'test_scheduler_id' mock_tethys.objects.get_subclass.return_value = mock_job mock_dask_scheduler = mock.MagicMock() mock_dask_scheduler.name = 'test_name' mock_dask_scheduler.dashboard = 'test_dashboard' mock_scheduler.objects.get.return_value = mock_dask_scheduler request = mock.MagicMock() mock_bokeh.side_effect = Exception('test_error_message') # Excute bokeh_row(request, job_id='test_id') mock_log.error.assert_called_with('The following error occurred when getting bokeh chart from scheduler' ' test_name for job test_id: test_error_message')
def test_bokeh_row(self, mock_tethys, mock_scheduler, mock_bokeh, mock_render): mock_job = mock.MagicMock() mock_job.status = 'test_status' mock_job.scheduler_id = 'test_scheduler_id' mock_tethys.objects.get_subclass.return_value = mock_job mock_dask_scheduler = mock.MagicMock() mock_dask_scheduler.dashboard = 'test_dashboard' mock_scheduler.objects.get.return_value = mock_dask_scheduler request = mock.MagicMock() mock_bokeh.return_value = 'test_script' mock_render.return_value = 'test_html' # Excute ret = bokeh_row(request, job_id='test_id') self.assertIn('"html": "test_html"', ret.content.decode('utf-8')) mock_bokeh.assert_called_with('http://test_dashboard/individual-graph')