@@ -152,9 +152,9 @@ def test_relations_no_match(self):
152152 self .assertEqual (b .bundle_id .base_id .name , 'master' )
153153
154154 def test_relations_pr (self ):
155- self .Branch .create ({
155+ dev_branch = self .Branch .create ({
156156 'remote_id' : self .remote_odoo_dev .id ,
157- 'name' : 'master-test-tri' ,
157+ 'name' : 'master-test-tri-imp ' ,
158158 'is_pr' : False ,
159159 })
160160
@@ -167,17 +167,19 @@ def test_relations_pr(self):
167167 'login' : 'Pr author'
168168 },
169169 }
170- b = self .Branch .create ({
170+ pr_branch = self .Branch .create ({
171171 'remote_id' : self .remote_odoo_dev .id ,
172172 'name' : '100' ,
173173 'is_pr' : True ,
174174 })
175175
176- self .assertEqual (b .bundle_id .name , 'master-test-tri-imp' )
177- self .assertEqual (b .bundle_id .base_id .name , 'master' )
178- self .assertEqual (b .bundle_id .previous_major_version_base_id .name , '13.0' )
179- self .assertEqual (sorted (b .bundle_id .intermediate_version_base_ids .mapped ('name' )), ['saas-13.1' , 'saas-13.2' ])
176+ bundle = pr_branch .bundle_id
180177
178+ self .assertEqual (bundle .name , 'master-test-tri-imp' )
179+ self .assertEqual (bundle .base_id .name , 'master' )
180+ self .assertEqual (bundle .previous_major_version_base_id .name , '13.0' )
181+ self .assertEqual (sorted (bundle .intermediate_version_base_ids .mapped ('name' )), ['saas-13.1' , 'saas-13.2' ])
182+ self .assertIn (dev_branch , bundle .branch_ids )
181183
182184class TestBranchForbidden (RunbotCase ):
183185 """Test that a branch matching the repo forbidden regex, goes to dummy bundle"""
@@ -309,14 +311,17 @@ def test_bundle_team_attribution(self):
309311 self .stop_patcher ('isfile' )
310312 self .stop_patcher ('isdir' ) # needed to create the user avatar
311313 create_context = {'no_reset_password' : True , 'mail_create_nolog' : True , 'mail_create_nosubscribe' : True , 'mail_notrack' : True }
312- test_user = new_test_user (self .env , login = 'testrunbot' , name = 'testrunbot (tru)' , context = create_context )
314+ committer_user = new_test_user (self .env , login = 'testrunbot' , name = 'testrunbot (tru)' , email = 'trut@somewhere.com' , context = create_context )
315+ author_user = new_test_user (self .env , login = 'testrunbot_author' , name = 'test author (aut)' , email = 'aut@somewhere.com' , context = create_context )
316+ github_user = new_test_user (self .env , login = 'github_author' , name = 'github author (gaut)' , email = 'gaut@somewhere.com' , context = create_context )
317+ github_user .github_login = 'gaut_github'
313318
314319 team = self .env ['runbot.team' ].create ({
315320 'name' : 'Test Team' ,
316321 'project_id' : self .project .id ,
317322 })
318323
319- team .user_ids += test_user
324+ team .user_ids += committer_user
320325
321326 branch = self .Branch .create ({
322327 'remote_id' : self .remote_odoo_dev .id ,
@@ -332,6 +337,7 @@ def test_bundle_team_attribution(self):
332337
333338 bundle = self .env ['runbot.bundle' ].search ([('name' , '=' , branch .name )])
334339 self .assertEqual (bundle .team_id , team )
340+ self .assertEqual (bundle .author_ids , committer_user , 'The only involved author should be the one based on bundle ngram' )
335341
336342 # now test that a team can be manually set on a bundle
337343 other_team = self .env ['runbot.team' ].create ({
@@ -341,3 +347,39 @@ def test_bundle_team_attribution(self):
341347
342348 bundle .team_id = other_team
343349 self .assertEqual (bundle .team_id , other_team )
350+
351+ # testing the author_ids based on commit author and committers
352+ new_commit = self .Commit .create ({
353+ 'name' : 'd0d0caca' ,
354+ 'tree_hash' : 'cacad0d0' ,
355+ 'repo_id' : self .repo_odoo .id ,
356+ 'author' : 'aut' ,
357+ 'author_email' : author_user .email ,
358+ 'committer' : 'test runbot' ,
359+ 'committer_email' : committer_user .email ,
360+ })
361+
362+ branch .head = new_commit
363+ self .assertEqual (bundle .team_id , other_team , 'Team should be unchanged as it wa manually set' )
364+
365+ self .assertIn (committer_user , bundle .author_ids )
366+ self .assertIn (author_user , bundle .author_ids )
367+ self .assertEqual (2 , len (bundle .author_ids ))
368+ self .patchers ['github_patcher' ].return_value = {
369+ 'base' : {'ref' : 'saas-19.1' },
370+ 'head' : {'label' : 'dev:saas-19.1-test-tru' , 'repo' : {'full_name' : 'dev/odoo' }},
371+ 'title' : '[IMP] Title' ,
372+ 'body' : 'Body' ,
373+ 'user' : {
374+ 'login' : github_user .github_login ,
375+ },
376+ }
377+ pr_branch = self .Branch .create ({
378+ 'remote_id' : self .remote_odoo_dev .id ,
379+ 'name' : '100' ,
380+ 'is_pr' : True ,
381+ })
382+
383+ self .assertIn (pr_branch , bundle .branch_ids )
384+ self .assertIn (github_user , bundle .author_ids )
385+ self .assertEqual (3 , len (bundle .author_ids ))
0 commit comments