@@ -48,8 +48,8 @@ def test_no_relation(self):
4848
4949 @utils .store_samples ('relation-list' )
5050 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 )
5353
5454 # nobody
5555 resp = self .client .get (self .api_url (item = patches [0 ].pk ))
@@ -101,8 +101,8 @@ def test_create_two_patch_relation_maintainer(self):
101101 self .assertEqual (patches [1 ].related , patches [0 ].related )
102102
103103 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 ]
106106
107107 self .assertEqual (PatchRelation .objects .count (), 1 )
108108
@@ -112,8 +112,8 @@ def test_delete_two_patch_relation_nobody(self):
112112
113113 @utils .store_samples ('relation-delete' )
114114 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 ]
117117
118118 self .assertEqual (PatchRelation .objects .count (), 1 )
119119
@@ -145,8 +145,8 @@ def test_create_three_patch_relation(self):
145145 self .assertEqual (patches [1 ].related , patches [2 ].related )
146146
147147 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 ]
150150
151151 self .assertEqual (PatchRelation .objects .count (), 1 )
152152
@@ -159,8 +159,9 @@ def test_delete_from_three_patch_relation(self):
159159
160160 @utils .store_samples ('relation-extend-through-new' )
161161 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 ]
164165
165166 new_patch = create_patch (project = self .project )
166167
@@ -173,8 +174,9 @@ def test_extend_relation_through_new(self):
173174 self .assertEqual (relation .patches .count (), 3 )
174175
175176 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 ]
178180
179181 new_patch = create_patch (project = self .project )
180182
@@ -188,8 +190,9 @@ def test_extend_relation_through_old(self):
188190 self .assertEqual (relation .patches .count (), 3 )
189191
190192 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 ]
193196
194197 new_patch_a = create_patch (project = self .project )
195198 new_patch_b = create_patch (project = self .project )
@@ -210,8 +213,9 @@ def test_extend_relation_through_new_two(self):
210213
211214 @utils .store_samples ('relation-extend-through-old' )
212215 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 ]
215219
216220 new_patch_a = create_patch (project = self .project )
217221 new_patch_b = create_patch (project = self .project )
@@ -232,9 +236,10 @@ def test_extend_relation_through_old_two(self):
232236 self .assertEqual (relation .patches .count (), 4 )
233237
234238 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 ]
238243
239244 # this should do nothing - it is interpreted as
240245 # _adding_ keep_patch_b again which is a no-op.
@@ -248,8 +253,9 @@ def test_remove_one_patch_from_relation_bad(self):
248253 self .assertEqual (relation .patches .count (), 3 )
249254
250255 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 ]
253259
254260 # maintainer
255261 self .client .force_authenticate (user = self .maintainer )
@@ -263,8 +269,10 @@ def test_remove_one_patch_from_relation_good(self):
263269 @utils .store_samples ('relation-forbid-moving-between-relations' )
264270 def test_forbid_moving_patch_between_relations (self ):
265271 """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 )
268276
269277 patch_a = relation_a .patches .first ()
270278 patch_b = relation_b .patches .first ()
0 commit comments