def test_statehtml(self):
        result_url = '/plot/b3c84d96-4dc7-4532-a864-3573202f202a'
        state = {'state': 'PENDING',
                 'success': False,
                 'failure': False,
                 'ready': False,
                 'result': result_url,
                 'task': 'pythontask',
                 }
        self.request.matchdict['script'] = 'plot'
        views = Views(self.request)
        views.statejson = Mock(return_value=state)
        views.celery.tasks = {'plot': 'pythontask'}

        result = views.statehtml()

        self.assertDictEqual(result, state)
    def test_statejson(self):
        self.config.add_route('result', '/{script}/{taskid}')
        self.request.matchdict['script'] = 'plot'
        self.request.matchdict['taskid'] = 'b3c84d96-4dc7-4532-a864-3573202f202a'
        views = Views(self.request)
        task_result = Mock(AsyncResult)
        task_result.id = 'b3c84d96-4dc7-4532-a864-3573202f202a'
        task_result.state = 'PENDING'
        task_result.ready.return_value = False
        task_result.successful.return_value = False
        task_result.failed.return_value = False
        views.celery.AsyncResult = Mock(return_value=task_result)

        result = views.statejson()

        result_url = '/plot/b3c84d96-4dc7-4532-a864-3573202f202a'
        expected_result = {'state': 'PENDING',
                           'ready': False,
                           'success': False,
                           'failure': False,
                           'result': result_url}
        self.assertDictEqual(result, expected_result)