コード例 #1
0
ファイル: utils.py プロジェクト: goldenhelix/avocado
    def test_get_rows(self):
        context = DataContext()
        view = DataView()

        # Unless we tell the function to evaluate the rows, it should return
        # rows as a generator so we need to exclicitly evaluate it here.
        result = utils.get_result_rows(context, view, {})
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())

        # Now, have the method evaluate the rows.
        result = utils.get_result_rows(context, view, {}, evaluate_rows=True)
        self.assertEqual(len(result['rows']), Employee.objects.count())
コード例 #2
0
    def test_get_rows(self):
        context = DataContext()
        view = DataView()

        # Unless we tell the function to evaluate the rows, it should return
        # rows as a generator so we need to exclicitly evaluate it here.
        result = utils.get_result_rows(context, view, {})
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())

        # Now, have the method evaluate the rows.
        result = utils.get_result_rows(context, view, {}, evaluate_rows=True)
        self.assertEqual(len(result['rows']), Employee.objects.count())
コード例 #3
0
    def test_pages(self):
        context = DataContext()
        view = DataView()
        query_options = {
            'page': 1,
            'stop_page': 10,
        }
        result = utils.get_result_rows(context, view, query_options)
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())

        query_options = {
            'page': 1,
            'stop_page': 1,
        }
        result = utils.get_result_rows(context, view, query_options)
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())
コード例 #4
0
    def get(self, request, **kwargs):
        params = self.get_params(request)

        # Get the request's view and context
        view = self.get_view(request)
        context = self.get_context(request)

        # Configure the query options used for retrieving the results.
        query_options = {
            'export_type': HTMLExporter.short_name,
            'query_name': self._get_query_name(request),
        }
        query_options.update(**kwargs)
        query_options.update(params)

        try:
            row_data = utils.get_result_rows(context,
                                             view,
                                             query_options,
                                             request=request)
        except ValueError:
            raise Http404

        return process_results(request, PREVIEW_RESULT_PROCESSOR_NAME,
                               row_data)
コード例 #5
0
ファイル: utils.py プロジェクト: goldenhelix/avocado
    def test_pages(self):
        context = DataContext()
        view = DataView()
        query_options = {
            'page': 1,
            'stop_page': 10,
        }
        result = utils.get_result_rows(context, view, query_options)
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())

        query_options = {
            'page': 1,
            'stop_page': 1,
        }
        result = utils.get_result_rows(context, view, query_options)
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())
コード例 #6
0
 def test_export_type(self):
     context = DataContext()
     view = DataView()
     export_type = 'json'
     query_options = {
         'export_type': export_type,
     }
     result = utils.get_result_rows(context, view, query_options)
     self.assertEqual(len(list(result['rows'])), Employee.objects.count())
     self.assertEqual(result['export_type'], export_type)
コード例 #7
0
ファイル: utils.py プロジェクト: goldenhelix/avocado
 def test_export_type(self):
     context = DataContext()
     view = DataView()
     export_type = 'json'
     query_options = {
         'export_type': export_type,
     }
     result = utils.get_result_rows(context, view, query_options)
     self.assertEqual(len(list(result['rows'])), Employee.objects.count())
     self.assertEqual(result['export_type'], export_type)
コード例 #8
0
ファイル: utils.py プロジェクト: goldenhelix/avocado
 def test_processor(self):
     context = DataContext()
     view = DataView()
     processor = 'manager'
     query_options = {
         'processor': processor,
     }
     result = utils.get_result_rows(context, view, query_options)
     self.assertEqual(len(list(result['rows'])),
                      Employee.objects.filter(is_manager=True).count())
     self.assertTrue(isinstance(result['processor'], ManagerQueryProcessor))
コード例 #9
0
 def test_processor(self):
     context = DataContext()
     view = DataView()
     processor = 'manager'
     query_options = {
         'processor': processor,
     }
     result = utils.get_result_rows(context, view, query_options)
     self.assertEqual(len(list(result['rows'])),
                      Employee.objects.filter(is_manager=True).count())
     self.assertTrue(isinstance(result['processor'], ManagerQueryProcessor))
コード例 #10
0
 def test_limit(self):
     context = DataContext()
     view = DataView()
     limit = 2
     query_options = {
         'limit': limit,
         'page': 1,
     }
     result = utils.get_result_rows(context, view, query_options)
     self.assertEqual(len(list(result['rows'])), limit)
     self.assertEqual(result['limit'], limit)
コード例 #11
0
ファイル: utils.py プロジェクト: goldenhelix/avocado
 def test_limit(self):
     context = DataContext()
     view = DataView()
     limit = 2
     query_options = {
         'limit': limit,
         'page': 1,
     }
     result = utils.get_result_rows(context, view, query_options)
     self.assertEqual(len(list(result['rows'])), limit)
     self.assertEqual(result['limit'], limit)
コード例 #12
0
    def test_get_order_only(self):
        field = DataField.objects.get(field_name='salary')
        concept = field.concepts.all()[0]

        context = DataContext()
        view = DataView(json=[{
            'concept': concept.pk,
            'visible': False,
            'sort': 'desc',
        }])
        result = utils.get_result_rows(context, view, {})
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())
コード例 #13
0
ファイル: utils.py プロジェクト: goldenhelix/avocado
    def test_get_order_only(self):
        field = DataField.objects.get(field_name='salary')
        concept = field.concepts.all()[0]

        context = DataContext()
        view = DataView(json=[{
            'concept': concept.pk,
            'visible': False,
            'sort': 'desc',
        }])
        result = utils.get_result_rows(context, view, {})
        self.assertEqual(len(list(result['rows'])), Employee.objects.count())
コード例 #14
0
    def get(self, request, **kwargs):
        params = self.get_params(request)

        # Configure the query options used for retrieving the results.
        query_options = {
            'export_type': JSONExporter.short_name.lower(),
            'query_name': self._get_query_name(request),
        }
        query_options.update(**kwargs)
        query_options.update(params)

        try:
            row_data = query_utils.get_result_rows(request.instance.context,
                                                   request.instance.view,
                                                   query_options,
                                                   request=request)
        except ValueError:
            raise Http404

        return process_results(request, QUERY_RESULT_PROCESSOR_NAME, row_data)
コード例 #15
0
ファイル: exporter.py プロジェクト: goldenhelix/serrano
    def get(self, request, export_type, **kwargs):
        view = self.get_view(request)
        context = self.get_context(request)

        params = self.get_params(request)

        # Configure the query options used for retrieving the results.
        query_options = {
            'export_type': export_type,
            'query_name': self._get_query_name(request, export_type),
        }
        query_options.update(**kwargs)
        query_options.update(params)

        try:
            row_data = utils.get_result_rows(context, view, query_options)
        except ValueError:
            raise Http404

        return process_results(
            request, EXPORTER_RESULT_PROCESSOR_NAME, row_data)
コード例 #16
0
ファイル: results.py プロジェクト: goldenhelix/serrano
    def get(self, request, **kwargs):
        params = self.get_params(request)

        # Configure the query options used for retrieving the results.
        query_options = {
            'export_type': JSONExporter.short_name.lower(),
            'query_name': self._get_query_name(request),
        }
        query_options.update(**kwargs)
        query_options.update(params)

        try:
            row_data = query_utils.get_result_rows(
                request.instance.context,
                request.instance.view,
                query_options)
        except ValueError:
            raise Http404

        return process_results(
            request, QUERY_RESULT_PROCESSOR_NAME, row_data)
コード例 #17
0
ファイル: preview.py プロジェクト: chop-dbhi/serrano
    def get(self, request, **kwargs):
        params = self.get_params(request)

        # Get the request's view and context
        view = self.get_view(request)
        context = self.get_context(request)

        # Configure the query options used for retrieving the results.
        query_options = {
            'export_type': HTMLExporter.short_name,
            'query_name': self._get_query_name(request),
        }
        query_options.update(**kwargs)
        query_options.update(params)

        try:
            row_data = utils.get_result_rows(context, view, query_options,
                                             request=request)
        except ValueError:
            raise Http404

        return process_results(
            request, PREVIEW_RESULT_PROCESSOR_NAME, row_data)