Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "Splitted expressions tests into smaller methods"

This reverts commit c253282.
  • Loading branch information...
commit 7f4dbdc036a4439ed3e4954625fe91596b314a36 1 parent c2150d4
Anssi Kääriäinen authored October 03, 2012

Showing 1 changed file with 15 additions and 28 deletions. Show diff stats Hide diff stats

  1. 43  tests/modeltests/expressions/tests.py
43  tests/modeltests/expressions/tests.py
@@ -9,7 +9,7 @@
9 9
 
10 10
 
11 11
 class ExpressionsTests(TestCase):
12  
-    def setUp(self):
  12
+    def test_filter(self):
13 13
         Company.objects.create(
14 14
             name="Example Inc.", num_employees=2300, num_chairs=5, is_large=False,
15 15
             ceo=Employee.objects.create(firstname="Joe", lastname="Smith")
@@ -23,8 +23,6 @@ def setUp(self):
23 23
             ceo=Employee.objects.create(firstname="Max", lastname="Mustermann")
24 24
         )
25 25
 
26  
-
27  
-    def test_filter(self):
28 26
         company_query = Company.objects.values(
29 27
             "name", "num_employees", "num_chairs", "is_large"
30 28
         ).order_by(
@@ -160,13 +158,6 @@ def test_filter(self):
160 158
             ],
161 159
             lambda o: o,
162 160
         )
163  
-
164  
-    def test_comparisons(self):
165  
-        company_query = Company.objects.values(
166  
-            "name", "num_employees", "num_chairs", "is_large"
167  
-        ).order_by(
168  
-            "name", "num_employees", "num_chairs", "is_large"
169  
-        )
170 161
         # The comparison operators and the bitwise unary not can be used
171 162
         # to assign to boolean fields
172 163
         for expression in (
@@ -189,19 +180,19 @@ def test_comparisons(self):
189 180
             self.assertQuerysetEqual(
190 181
                 company_query, [
191 182
                     {
192  
-                        'num_chairs': 5,
  183
+                        'num_chairs': 5294600,
193 184
                         'name': 'Example Inc.',
194 185
                         'num_employees': 2300,
195 186
                         'is_large': True
196 187
                     },
197 188
                     {
198  
-                        'num_chairs': 4,
  189
+                        'num_chairs': 15,
199 190
                         'name': 'Foobar Ltd.',
200 191
                         'num_employees': 3,
201 192
                         'is_large': False
202 193
                     },
203 194
                     {
204  
-                        'num_chairs': 1,
  195
+                        'num_chairs': 1088,
205 196
                         'name': 'Test GmbH',
206 197
                         'num_employees': 32,
207 198
                         'is_large': False
@@ -239,31 +230,28 @@ def test_comparisons(self):
239 230
             lambda c: six.text_type(c.point_of_contact),
240 231
         )
241 232
 
242  
-    def test_joins(self):
243 233
         c = Company.objects.all()[0]
244  
-        c.point_of_contact = Employee.objects.create(
245  
-            firstname="Guido", lastname="van Rossum")
246  
-        old_ceo = c.ceo
247  
-        c.ceo = c.point_of_contact
  234
+        c.point_of_contact = Employee.objects.create(firstname="Guido", lastname="van Rossum")
248 235
         c.save()
249 236
 
250 237
         # F Expressions can also span joins
251 238
         self.assertQuerysetEqual(
252  
-            Company.objects.filter(
253  
-                ceo__firstname=F("point_of_contact__firstname")),
254  
-            [
255  
-                "Example Inc.",
  239
+            Company.objects.filter(ceo__firstname=F("point_of_contact__firstname")), [
  240
+                "Foobar Ltd.",
  241
+                "Test GmbH",
256 242
             ],
257 243
             lambda c: c.name
258 244
         )
259  
-        c.ceo = old_ceo
260  
-        c.save()
261  
-        # Guido is point of contanct but not CEO. For the null cases we do
262  
-        # not generate a match.
  245
+
263 246
         Company.objects.exclude(
264 247
             ceo__firstname=F("point_of_contact__firstname")
265 248
         ).update(name="foo")
266  
-        self.assertEqual(Company.objects.filter(name="foo").count(), 1)
  249
+        self.assertEqual(
  250
+            Company.objects.exclude(
  251
+                ceo__firstname=F('point_of_contact__firstname')
  252
+            ).get().name,
  253
+            "foo",
  254
+        )
267 255
 
268 256
         self.assertRaises(FieldError,
269 257
             lambda: Company.objects.exclude(
@@ -271,7 +259,6 @@ def test_joins(self):
271 259
             ).update(name=F('point_of_contact__lastname'))
272 260
         )
273 261
 
274  
-    def test_save(self):
275 262
         # F expressions can be used to update attributes on single objects
276 263
         test_gmbh = Company.objects.get(name="Test GmbH")
277 264
         self.assertEqual(test_gmbh.num_employees, 32)

0 notes on commit 7f4dbdc

Please sign in to comment.
Something went wrong with that request. Please try again.