Exemplo n.º 1
0
    def test_sort_related(self):
        "Sorts on a reverse foreign key property."
        view = DataView(json=[
            {
                'concept': self.first_name.pk
            },
            {
                'concept': self.last_name.pk
            },
            {
                'concept': self.project_name.pk,
                'sort': 'asc',
                'visible': False
            },
        ])

        proc = QueryProcessor(view=view)
        queryset = proc.get_queryset()
        exporter = proc.get_exporter(export.BaseExporter)

        iterable = proc.get_iterable(queryset=queryset)
        reader = exporter.manual_read(iterable)

        self.assertEqual(list(exporter.write(reader)),
                         [(3, u'Erick', u'Smith'), (4, u'Aaron', u'Harris'),
                          (5, u'Zac', u'Cook'), (6, u'Mel', u'Brooks'),
                          (1, u'Eric', u'Smith'), (2, u'Erin', u'Jones')])
Exemplo n.º 2
0
    def setUp(self):
        management.call_command('avocado', 'init', 'tests', quiet=True)

        field = DataField.objects.get(field_name='salary')
        concept = field.concepts.all()[0]

        view = DataView(json=[{
            'concept': concept.pk,
            'visible': False,
            'sort': 'desc',
        }])

        self.pks = list(models.Employee.objects.values_list('pk', flat=True)
                        .order_by('-title__salary'))

        proc = QueryProcessor(view=view)
        queryset = proc.get_queryset()
        self.iterable = proc.get_iterable(queryset=queryset)
        self.exporter = proc.get_exporter(export.BaseExporter)
Exemplo n.º 3
0
    def test_sort_related(self):
        "Sorts on a reverse foreign key property."
        view = DataView(json=[
            {'concept': self.first_name.pk},
            {'concept': self.last_name.pk},
            {'concept': self.project_name.pk, 'sort': 'asc', 'visible': False},
        ])

        proc = QueryProcessor(view=view)
        queryset = proc.get_queryset()
        exporter = proc.get_exporter(export.BaseExporter)

        iterable = proc.get_iterable(queryset=queryset)
        reader = exporter.manual_read(iterable)

        self.assertEqual(list(exporter.write(reader)), [
            (3, u'Erick', u'Smith'),
            (4, u'Aaron', u'Harris'),
            (5, u'Zac', u'Cook'),
            (6, u'Mel', u'Brooks'),
            (1, u'Eric', u'Smith'),
            (2, u'Erin', u'Jones')
        ])