summaryrefslogtreecommitdiff
path: root/tests/extra_regress
diff options
context:
space:
mode:
authorDražen Odobašić <dodobas@candela-it.com>2015-09-11 19:33:12 -0400
committerTim Graham <timograham@gmail.com>2015-09-12 11:40:50 -0400
commitb1e33ceceda1e75ff68c7deed8f6659683a195d3 (patch)
treee4e446f69194f2dc3c9c7ee3ecf48290ea8d4d31 /tests/extra_regress
parent84b0a8d2aad042fb573df5055b6153770d0929ac (diff)
downloaddjango-b1e33ceceda1e75ff68c7deed8f6659683a195d3.tar.gz
Fixed #23395 -- Limited line lengths to 119 characters.
Diffstat (limited to 'tests/extra_regress')
-rw-r--r--tests/extra_regress/tests.py112
1 files changed, 93 insertions, 19 deletions
diff --git a/tests/extra_regress/tests.py b/tests/extra_regress/tests.py
index aba6e326e1..242487a060 100644
--- a/tests/extra_regress/tests.py
+++ b/tests/extra_regress/tests.py
@@ -185,100 +185,174 @@ class ExtraRegressTests(TestCase):
obj.save()
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values()),
- [{'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first', 'id': obj.pk, 'first': 'first'}]
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values()
+ ),
+ [{
+ 'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first',
+ 'id': obj.pk, 'first': 'first'
+ }]
)
# Extra clauses after an empty values clause are still included
self.assertEqual(
- list(TestObject.objects.values().extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
- [{'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first', 'id': obj.pk, 'first': 'first'}]
+ list(
+ TestObject.objects
+ .values()
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ ),
+ [{
+ 'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first',
+ 'id': obj.pk, 'first': 'first'
+ }]
)
# Extra columns are ignored if not mentioned in the values() clause
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values('first', 'second')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values('first', 'second')
+ ),
[{'second': 'second', 'first': 'first'}]
)
# Extra columns after a non-empty values() clause are ignored
self.assertEqual(
- list(TestObject.objects.values('first', 'second').extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
+ list(
+ TestObject.objects
+ .values('first', 'second')
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ ),
[{'second': 'second', 'first': 'first'}]
)
# Extra columns can be partially returned
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values('first', 'second', 'foo')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values('first', 'second', 'foo')
+ ),
[{'second': 'second', 'foo': 'first', 'first': 'first'}]
)
# Also works if only extra columns are included
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values('foo', 'whiz')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values('foo', 'whiz')
+ ),
[{'foo': 'first', 'whiz': 'third'}]
)
# Values list works the same way
# All columns are returned for an empty values_list()
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list()),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list()
+ ),
[('first', 'second', 'third', obj.pk, 'first', 'second', 'third')]
)
# Extra columns after an empty values_list() are still included
self.assertEqual(
- list(TestObject.objects.values_list().extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
+ list(
+ TestObject.objects
+ .values_list()
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ ),
[('first', 'second', 'third', obj.pk, 'first', 'second', 'third')]
)
# Extra columns ignored completely if not mentioned in values_list()
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('first', 'second')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('first', 'second')
+ ),
[('first', 'second')]
)
# Extra columns after a non-empty values_list() clause are ignored completely
self.assertEqual(
- list(TestObject.objects.values_list('first', 'second').extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
+ list(
+ TestObject.objects
+ .values_list('first', 'second')
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ ),
[('first', 'second')]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('second', flat=True)),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('second', flat=True)
+ ),
['second']
)
# Only the extra columns specified in the values_list() are returned
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('first', 'second', 'whiz')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('first', 'second', 'whiz')
+ ),
[('first', 'second', 'third')]
)
# ...also works if only extra columns are included
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('foo', 'whiz')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('foo', 'whiz')
+ ),
[('first', 'third')]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('whiz', flat=True)),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('whiz', flat=True)
+ ),
['third']
)
# ... and values are returned in the order they are specified
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('whiz', 'foo')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('whiz', 'foo')
+ ),
[('third', 'first')]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('first', 'id')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('first', 'id')
+ ),
[('first', obj.pk)]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('whiz', 'first', 'bar', 'id')),
+ list(
+ TestObject.objects
+ .extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))
+ .values_list('whiz', 'first', 'bar', 'id')
+ ),
[('third', 'first', 'second', obj.pk)]
)