@@ -62,10 +62,10 @@ class QueryingTests(TestCase):
62
62
@classmethod
63
63
def setUpTestData (cls ):
64
64
cls .egypt = Exhibit .objects .create (
65
- exhibit_name = "Ancient Egypt" ,
65
+ name = "Ancient Egypt" ,
66
66
sections = [
67
67
Section (
68
- section_number = 1 ,
68
+ number = 1 ,
69
69
artifacts = [
70
70
Artifact (
71
71
name = "Ptolemaic Crown" ,
@@ -78,10 +78,10 @@ def setUpTestData(cls):
78
78
],
79
79
)
80
80
cls .wonders = Exhibit .objects .create (
81
- exhibit_name = "Wonders of the Ancient World" ,
81
+ name = "Wonders of the Ancient World" ,
82
82
sections = [
83
83
Section (
84
- section_number = 1 ,
84
+ number = 1 ,
85
85
artifacts = [
86
86
Artifact (
87
87
name = "Statue of Zeus" ,
@@ -93,7 +93,7 @@ def setUpTestData(cls):
93
93
],
94
94
),
95
95
Section (
96
- section_number = 2 ,
96
+ number = 2 ,
97
97
artifacts = [
98
98
Artifact (
99
99
name = "Lighthouse of Alexandria" ,
@@ -104,10 +104,10 @@ def setUpTestData(cls):
104
104
],
105
105
)
106
106
cls .new_descoveries = Exhibit .objects .create (
107
- exhibit_name = "New Discoveries" ,
107
+ name = "New Discoveries" ,
108
108
sections = [
109
109
Section (
110
- section_number = 2 ,
110
+ number = 2 ,
111
111
artifacts = [
112
112
Artifact (
113
113
name = "Lighthouse of Alexandria" ,
@@ -118,9 +118,9 @@ def setUpTestData(cls):
118
118
],
119
119
)
120
120
cls .lost_empires = Exhibit .objects .create (
121
- exhibit_name = "Lost Empires" ,
121
+ name = "Lost Empires" ,
122
122
main_section = Section (
123
- section_number = 3 ,
123
+ number = 3 ,
124
124
artifacts = [
125
125
Artifact (
126
126
name = "Bronze Statue" ,
@@ -149,12 +149,12 @@ def setUpTestData(cls):
149
149
150
150
def test_exact (self ):
151
151
self .assertCountEqual (
152
- Exhibit .objects .filter (sections__section_number = 1 ), [self .egypt , self .wonders ]
152
+ Exhibit .objects .filter (sections__number = 1 ), [self .egypt , self .wonders ]
153
153
)
154
154
155
155
def test_array_index (self ):
156
156
self .assertCountEqual (
157
- Exhibit .objects .filter (sections__0__section_number = 1 ),
157
+ Exhibit .objects .filter (sections__0__number = 1 ),
158
158
[self .egypt , self .wonders ],
159
159
)
160
160
@@ -168,7 +168,7 @@ def test_nested_array_index(self):
168
168
169
169
def test_array_slice (self ):
170
170
self .assertSequenceEqual (
171
- Exhibit .objects .filter (sections__0_1__section_number = 2 ), [self .new_descoveries ]
171
+ Exhibit .objects .filter (sections__0_1__number = 2 ), [self .new_descoveries ]
172
172
)
173
173
174
174
def test_filter_unsupported_lookups_in_json (self ):
@@ -196,16 +196,16 @@ def test_len(self):
196
196
self .assertCountEqual (Exhibit .objects .filter (sections__1__artifacts__len = 1 ), [self .wonders ])
197
197
198
198
def test_in (self ):
199
- self .assertCountEqual (Exhibit .objects .filter (sections__section_number__in = [10 ]), [])
199
+ self .assertCountEqual (Exhibit .objects .filter (sections__number__in = [10 ]), [])
200
200
self .assertCountEqual (
201
- Exhibit .objects .filter (sections__section_number__in = [1 ]),
201
+ Exhibit .objects .filter (sections__number__in = [1 ]),
202
202
[self .egypt , self .wonders ],
203
203
)
204
204
self .assertCountEqual (
205
- Exhibit .objects .filter (sections__section_number__in = [2 ]),
205
+ Exhibit .objects .filter (sections__number__in = [2 ]),
206
206
[self .new_descoveries , self .wonders ],
207
207
)
208
- self .assertCountEqual (Exhibit .objects .filter (sections__section_number__in = [3 ]), [])
208
+ self .assertCountEqual (Exhibit .objects .filter (sections__number__in = [3 ]), [])
209
209
210
210
def test_iexact (self ):
211
211
self .assertCountEqual (
@@ -215,24 +215,24 @@ def test_iexact(self):
215
215
216
216
def test_gt (self ):
217
217
self .assertCountEqual (
218
- Exhibit .objects .filter (sections__section_number__gt = 1 ),
218
+ Exhibit .objects .filter (sections__number__gt = 1 ),
219
219
[self .new_descoveries , self .wonders ],
220
220
)
221
221
222
222
def test_gte (self ):
223
223
self .assertCountEqual (
224
- Exhibit .objects .filter (sections__section_number__gte = 1 ),
224
+ Exhibit .objects .filter (sections__number__gte = 1 ),
225
225
[self .egypt , self .new_descoveries , self .wonders ],
226
226
)
227
227
228
228
def test_lt (self ):
229
229
self .assertCountEqual (
230
- Exhibit .objects .filter (sections__section_number__lt = 2 ), [self .egypt , self .wonders ]
230
+ Exhibit .objects .filter (sections__number__lt = 2 ), [self .egypt , self .wonders ]
231
231
)
232
232
233
233
def test_lte (self ):
234
234
self .assertCountEqual (
235
- Exhibit .objects .filter (sections__section_number__lte = 2 ),
235
+ Exhibit .objects .filter (sections__number__lte = 2 ),
236
236
[self .egypt , self .wonders , self .new_descoveries ],
237
237
)
238
238
@@ -255,20 +255,20 @@ def test_invalid_field(self):
255
255
def test_invalid_lookup (self ):
256
256
msg = "Unsupported lookup 'return' for EmbeddedModelArrayField of 'IntegerField'"
257
257
with self .assertRaisesMessage (FieldDoesNotExist , msg ):
258
- Exhibit .objects .filter (sections__section_number__return = 3 )
258
+ Exhibit .objects .filter (sections__number__return = 3 )
259
259
260
260
def test_invalid_operation (self ):
261
261
msg = "Unsupported lookup 'rage' for EmbeddedModelArrayField of 'IntegerField'"
262
262
with self .assertRaisesMessage (FieldDoesNotExist , msg ):
263
- Exhibit .objects .filter (sections__section_number__rage = [10 ])
263
+ Exhibit .objects .filter (sections__number__rage = [10 ])
264
264
265
265
def test_missing_lookup_suggestions (self ):
266
266
msg = (
267
267
"Unsupported lookup 'ltee' for EmbeddedModelArrayField of 'IntegerField', "
268
268
"perhaps you meant lte or lt?"
269
269
)
270
270
with self .assertRaisesMessage (FieldDoesNotExist , msg ):
271
- Exhibit .objects .filter (sections__section_number__ltee = 3 )
271
+ Exhibit .objects .filter (sections__number__ltee = 3 )
272
272
273
273
def test_nested_lookup (self ):
274
274
msg = "Cannot perform multiple levels of array traversal in a query."
@@ -277,11 +277,11 @@ def test_nested_lookup(self):
277
277
278
278
def test_foreign_field_exact (self ):
279
279
"""Querying from a foreign key to an EmbeddedModelArrayField."""
280
- qs = Tour .objects .filter (exhibit__sections__section_number = 1 )
280
+ qs = Tour .objects .filter (exhibit__sections__number = 1 )
281
281
self .assertCountEqual (qs , [self .egypt_tour , self .wonders_tour ])
282
282
283
283
def test_foreign_field_with_slice (self ):
284
- qs = Tour .objects .filter (exhibit__sections__0_2__section_number__in = [1 , 2 ])
284
+ qs = Tour .objects .filter (exhibit__sections__0_2__number__in = [1 , 2 ])
285
285
self .assertCountEqual (qs , [self .wonders_tour , self .egypt_tour ])
286
286
287
287
0 commit comments