def test(self): p = QueryProcessor(view=self.v, tree=Employee) q = p.get_queryset() i = p.get_iterable(queryset=q) self.assertEqual(len(list(i)), 6)
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')])
def test_none_post(self): p = QueryProcessor(view=self.v, tree=Employee) # Change to an empty queryset q = p.get_queryset().none() i = p.get_iterable(queryset=q) self.assertEqual(len(list(i)), 0)
def test_none_pre(self): p = QueryProcessor(view=self.v, tree=Employee) # Pass in an empty queryset q = p.get_queryset(queryset=Employee.objects.none()) # Pass in an empty form this queryset i = p.get_iterable(queryset=q) self.assertEqual(len(list(i)), 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)
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') ])