Ejemplo n.º 1
0
    def test_execute_and_wait(self):
        query = Notebook()

        query.execute = Mock(return_value={'history_uuid': 1, 'status': 0})
        query.check_status = Mock(side_effect=check_status_side_effect)
        request = Mock()

        resp = query.execute_and_wait(request=request)
        assert_equal(1, resp['history_uuid'])
        assert_equal(2, query.check_status.call_count)
Ejemplo n.º 2
0
    def test_execute_and_wait(self):
        query = Notebook()

        query.execute = Mock(return_value={'history_uuid': 1, 'status': 0})
        query.check_status = Mock(side_effect=check_status_side_effect)
        query.fetch_result_data = Mock(return_value={'results': [[1], [2]]})
        request = Mock()

        resp = query.execute_and_wait(request=request, include_results=True)

        assert_equal(0, resp.get('status'), resp)
        assert_equal('available', resp['query_status']['status'], resp)
        assert_equal([[1], [2]], resp.get('results'), resp)

        assert_equal(2, query.check_status.call_count)
Ejemplo n.º 3
0
    def test_check_status(self):
        query = Notebook()

        request = Mock()
        operation_id = Mock()

        with patch(
                'notebook.api.Document2.objects.get_by_uuid') as get_by_uuid:
            with patch('notebook.api.get_api') as get_api:
                with patch('notebook.api.Notebook') as NotebookMock:
                    get_api.return_value = Mock(check_status=Mock(
                        return_value={'status': 0}))
                    resp = query.check_status(request=request,
                                              operation_id=operation_id)

                    assert_equal(0, resp['status'])
                    assert_equal(0, resp['query_status']['status'])