@@ -62,6 +62,15 @@ def setup_gitee_issue_services():
6262def setup_gitee_pull_request_services ():
6363 setup_gitee_basic_services ()
6464 __setup_gitee_pull_request_services ()
65+ __setup_gitee_pull_request_services_with_commits_and_comments ()
66+ __setup_gitee_pull_request_service_action_logs ()
67+
68+
69+ def setup_gitee_pull_request_services_with_empty_commits_and_comments ():
70+ setup_gitee_basic_services ()
71+ __setup_gitee_pull_request_services ()
72+ __setup_gitee_pull_request_services_with_empty_commits_and_comments ()
73+ __setup_gitee_pull_request_service_action_logs ()
6574
6675
6776def setup_gitee_basic_services ():
@@ -142,6 +151,8 @@ def __setup_gitee_pull_request_services():
142151 body = pull_request_2 , status = 200 ,
143152 forcing_headers = pagination_pull_header_2 )
144153
154+
155+ def __setup_gitee_pull_request_services_with_commits_and_comments ():
145156 pull_request_1_comments = read_file ('data/gitee/gitee_pull_request1_comments' )
146157 httpretty .register_uri (httpretty .GET , GITEE_PULL_REQUEST_1_COMMENTS_URL ,
147158 body = pull_request_1_comments , status = 200 ,
@@ -178,6 +189,26 @@ def __setup_gitee_pull_request_services():
178189 body = pull_request_2_action_logs , status = 200 )
179190
180191
192+ def __setup_gitee_pull_request_services_with_empty_commits_and_comments ():
193+ httpretty .register_uri (httpretty .GET , GITEE_PULL_REQUEST_1_COMMENTS_URL ,
194+ body = "" , status = 404 )
195+ httpretty .register_uri (httpretty .GET , GITEE_PULL_REQUEST_1_COMMITS_URL ,
196+ body = "" , status = 404 )
197+ httpretty .register_uri (httpretty .GET , GITEE_PULL_REQUEST_2_COMMENTS_URL ,
198+ body = "" , status = 404 )
199+ httpretty .register_uri (httpretty .GET , GITEE_PULL_REQUEST_2_COMMITS_URL ,
200+ body = "" , status = 404 )
201+
202+
203+ def __setup_gitee_pull_request_service_action_logs ():
204+ pull_request_1_action_logs = read_file ('data/gitee/gitee_pull_request1_action_logs' )
205+ httpretty .register_uri (httpretty .GET , GITEE_PULL_REQUEST_1_OPERATE_LOGS_URL ,
206+ body = pull_request_1_action_logs , status = 200 )
207+ pull_request_2_action_logs = read_file ('data/gitee/gitee_pull_request2_action_logs' )
208+ httpretty .register_uri (httpretty .GET , GITEE_PULL_REQUEST_2_OPERATE_LOGS_URL ,
209+ body = pull_request_2_action_logs , status = 200 )
210+
211+
181212def setup_refresh_access_token_service ():
182213 httpretty .register_uri (httpretty .POST , GITEE_REFRESH_TOKEN_URL , body = "" , status = 200 )
183214
@@ -320,6 +351,31 @@ def test_fetch_pulls(self):
320351 self .assertEqual (pull ['data' ]['merged_by' ], None )
321352 self .assertEqual (pull ['data' ]['merged_by_data' ], [])
322353
354+ @httpretty .activate
355+ def test_fetch_pulls_with_empty_commits_and_comments (self ):
356+ setup_gitee_pull_request_services_with_empty_commits_and_comments ()
357+ from_date = datetime .datetime (2019 , 1 , 1 )
358+ gitee = Gitee ("gitee_example" , "repo" , "[aaa]" )
359+ pulls = [pr for pr in gitee .fetch (category = CATEGORY_PULL_REQUEST , from_date = from_date )]
360+
361+ self .assertEqual (len (pulls ), 2 )
362+ pull = pulls [0 ]
363+ self .assertEqual (len (pull ['data' ]['review_comments_data' ]), 0 )
364+ # check if the testers_data there
365+ self .assertTrue ('tester_data' not in pull ['data' ])
366+ self .assertEqual (pull ['data' ]['commits_data' ], [])
367+ self .assertEqual (pull ['data' ]['merged_by' ], "willemjiang" )
368+ self .assertEqual (pull ['data' ]['merged_by_data' ]['login' ], "willemjiang" )
369+
370+ pull = pulls [1 ]
371+ self .assertEqual (len (pull ['data' ]['review_comments_data' ]), 0 )
372+ self .assertEqual (len (pull ['data' ]['review_comments_data' ]), 0 )
373+ # check if the testers_data there
374+ self .assertTrue ('tester_data' not in pull ['data' ])
375+ self .assertEqual (pull ['data' ]['commits_data' ], [])
376+ self .assertEqual (pull ['data' ]['merged_by' ], None )
377+ self .assertEqual (pull ['data' ]['merged_by_data' ], [])
378+
323379 def test_has_resuming (self ):
324380 """Test if it returns True when has_resuming is called"""
325381
0 commit comments