@@ -48,8 +48,8 @@ def test_no_relation(self):
48
48
49
49
@utils .store_samples ('relation-list' )
50
50
def test_list_two_patch_relation (self ):
51
- relation = create_relation (2 , project = self . project )
52
- patches = relation . patches . all ( )
51
+ relation = create_relation ()
52
+ patches = create_patches ( 2 , project = self . project , related = relation )
53
53
54
54
# nobody
55
55
resp = self .client .get (self .api_url (item = patches [0 ].pk ))
@@ -101,8 +101,8 @@ def test_create_two_patch_relation_maintainer(self):
101
101
self .assertEqual (patches [1 ].related , patches [0 ].related )
102
102
103
103
def test_delete_two_patch_relation_nobody (self ):
104
- relation = create_relation (project = self . project )
105
- patch = relation . patches . all ( )[0 ]
104
+ relation = create_relation ()
105
+ patch = create_patches ( 2 , project = self . project , related = relation )[0 ]
106
106
107
107
self .assertEqual (PatchRelation .objects .count (), 1 )
108
108
@@ -112,8 +112,8 @@ def test_delete_two_patch_relation_nobody(self):
112
112
113
113
@utils .store_samples ('relation-delete' )
114
114
def test_delete_two_patch_relation_maintainer (self ):
115
- relation = create_relation (project = self . project )
116
- patch = relation . patches . all ( )[0 ]
115
+ relation = create_relation ()
116
+ patch = create_patches ( 2 , project = self . project , related = relation )[0 ]
117
117
118
118
self .assertEqual (PatchRelation .objects .count (), 1 )
119
119
@@ -145,8 +145,8 @@ def test_create_three_patch_relation(self):
145
145
self .assertEqual (patches [1 ].related , patches [2 ].related )
146
146
147
147
def test_delete_from_three_patch_relation (self ):
148
- relation = create_relation (3 , project = self . project )
149
- patch = relation . patches . all ( )[0 ]
148
+ relation = create_relation ()
149
+ patch = create_patches ( 3 , project = self . project , related = relation )[0 ]
150
150
151
151
self .assertEqual (PatchRelation .objects .count (), 1 )
152
152
@@ -159,8 +159,9 @@ def test_delete_from_three_patch_relation(self):
159
159
160
160
@utils .store_samples ('relation-extend-through-new' )
161
161
def test_extend_relation_through_new (self ):
162
- relation = create_relation (project = self .project )
163
- existing_patch_a = relation .patches .first ()
162
+ relation = create_relation ()
163
+ existing_patch_a = create_patches (
164
+ 2 , project = self .project , related = relation )[0 ]
164
165
165
166
new_patch = create_patch (project = self .project )
166
167
@@ -173,8 +174,9 @@ def test_extend_relation_through_new(self):
173
174
self .assertEqual (relation .patches .count (), 3 )
174
175
175
176
def test_extend_relation_through_old (self ):
176
- relation = create_relation (project = self .project )
177
- existing_patch_a = relation .patches .first ()
177
+ relation = create_relation ()
178
+ existing_patch_a = create_patches (
179
+ 2 , project = self .project , related = relation )[0 ]
178
180
179
181
new_patch = create_patch (project = self .project )
180
182
@@ -188,8 +190,9 @@ def test_extend_relation_through_old(self):
188
190
self .assertEqual (relation .patches .count (), 3 )
189
191
190
192
def test_extend_relation_through_new_two (self ):
191
- relation = create_relation (project = self .project )
192
- existing_patch_a = relation .patches .first ()
193
+ relation = create_relation ()
194
+ existing_patch_a = create_patches (
195
+ 2 , project = self .project , related = relation )[0 ]
193
196
194
197
new_patch_a = create_patch (project = self .project )
195
198
new_patch_b = create_patch (project = self .project )
@@ -210,8 +213,9 @@ def test_extend_relation_through_new_two(self):
210
213
211
214
@utils .store_samples ('relation-extend-through-old' )
212
215
def test_extend_relation_through_old_two (self ):
213
- relation = create_relation (project = self .project )
214
- existing_patch_a = relation .patches .first ()
216
+ relation = create_relation ()
217
+ existing_patch_a = create_patches (
218
+ 2 , project = self .project , related = relation )[0 ]
215
219
216
220
new_patch_a = create_patch (project = self .project )
217
221
new_patch_b = create_patch (project = self .project )
@@ -232,9 +236,10 @@ def test_extend_relation_through_old_two(self):
232
236
self .assertEqual (relation .patches .count (), 4 )
233
237
234
238
def test_remove_one_patch_from_relation_bad (self ):
235
- relation = create_relation (3 , project = self .project )
236
- keep_patch_a = relation .patches .all ()[1 ]
237
- keep_patch_b = relation .patches .all ()[2 ]
239
+ relation = create_relation ()
240
+ patches = create_patches (3 , project = self .project , related = relation )
241
+ keep_patch_a = patches [1 ]
242
+ keep_patch_b = patches [1 ]
238
243
239
244
# this should do nothing - it is interpreted as
240
245
# _adding_ keep_patch_b again which is a no-op.
@@ -248,8 +253,9 @@ def test_remove_one_patch_from_relation_bad(self):
248
253
self .assertEqual (relation .patches .count (), 3 )
249
254
250
255
def test_remove_one_patch_from_relation_good (self ):
251
- relation = create_relation (3 , project = self .project )
252
- target_patch = relation .patches .all ()[0 ]
256
+ relation = create_relation ()
257
+ target_patch = create_patches (
258
+ 3 , project = self .project , related = relation )[0 ]
253
259
254
260
# maintainer
255
261
self .client .force_authenticate (user = self .maintainer )
@@ -263,8 +269,10 @@ def test_remove_one_patch_from_relation_good(self):
263
269
@utils .store_samples ('relation-forbid-moving-between-relations' )
264
270
def test_forbid_moving_patch_between_relations (self ):
265
271
"""Test the break-before-make logic"""
266
- relation_a = create_relation (project = self .project )
267
- relation_b = create_relation (project = self .project )
272
+ relation_a = create_relation ()
273
+ create_patches (2 , project = self .project , related = relation_a )
274
+ relation_b = create_relation ()
275
+ create_patches (2 , project = self .project , related = relation_b )
268
276
269
277
patch_a = relation_a .patches .first ()
270
278
patch_b = relation_b .patches .first ()
0 commit comments