@@ -334,8 +334,8 @@ def test_fileify_logging_when_wrong_version_pk(self, mock_logger):
334
334
tasks .fileify (version_pk = 345343 , commit = None , build = 1 )
335
335
mock_logger .warning .assert_called_with ("Version not found for given kwargs. {'pk': 345343}" )
336
336
337
- @patch ('readthedocs.projects.tasks .GitHubService.send_build_status' )
338
- def test_send_build_status_task_with_remote_repo (self , send_build_status ):
337
+ @patch ('readthedocs.oauth.services.github .GitHubService.send_build_status' )
338
+ def test_send_build_status_with_remote_repo_github (self , send_build_status ):
339
339
self .project .repo = 'https://github.com/test/test/'
340
340
self .project .save ()
341
341
@@ -356,8 +356,8 @@ def test_send_build_status_task_with_remote_repo(self, send_build_status):
356
356
)
357
357
self .assertEqual (Message .objects .filter (user = self .eric ).count (), 0 )
358
358
359
- @patch ('readthedocs.projects.tasks .GitHubService.send_build_status' )
360
- def test_send_build_status_task_with_social_account (self , send_build_status ):
359
+ @patch ('readthedocs.oauth.services.github .GitHubService.send_build_status' )
360
+ def test_send_build_status_with_social_account_github (self , send_build_status ):
361
361
social_account = get (SocialAccount , user = self .eric , provider = 'github' )
362
362
363
363
self .project .repo = 'https://github.com/test/test/'
@@ -376,8 +376,8 @@ def test_send_build_status_task_with_social_account(self, send_build_status):
376
376
)
377
377
self .assertEqual (Message .objects .filter (user = self .eric ).count (), 0 )
378
378
379
- @patch ('readthedocs.projects.tasks .GitHubService.send_build_status' )
380
- def test_send_build_status_task_without_remote_repo_or_social_account (self , send_build_status ):
379
+ @patch ('readthedocs.oauth.services.github .GitHubService.send_build_status' )
380
+ def test_send_build_status_no_remote_repo_or_social_account_github (self , send_build_status ):
381
381
self .project .repo = 'https://github.com/test/test/'
382
382
self .project .save ()
383
383
external_version = get (Version , project = self .project , type = EXTERNAL )
@@ -390,3 +390,60 @@ def test_send_build_status_task_without_remote_repo_or_social_account(self, send
390
390
391
391
send_build_status .assert_not_called ()
392
392
self .assertEqual (Message .objects .filter (user = self .eric ).count (), 1 )
393
+
394
+ @patch ('readthedocs.oauth.services.gitlab.GitLabService.send_build_status' )
395
+ def test_send_build_status_with_remote_repo_gitlab (self , send_build_status ):
396
+ self .project .repo = 'https://gitlab.com/test/test/'
397
+ self .project .save ()
398
+
399
+ social_account = get (SocialAccount , provider = 'gitlab' )
400
+ remote_repo = get (RemoteRepository , account = social_account , project = self .project )
401
+ remote_repo .users .add (self .eric )
402
+
403
+ external_version = get (Version , project = self .project , type = EXTERNAL )
404
+ external_build = get (
405
+ Build , project = self .project , version = external_version
406
+ )
407
+ tasks .send_build_status (
408
+ external_build .id , external_build .commit , BUILD_STATUS_SUCCESS
409
+ )
410
+
411
+ send_build_status .assert_called_once_with (
412
+ external_build , external_build .commit , BUILD_STATUS_SUCCESS
413
+ )
414
+ self .assertEqual (Message .objects .filter (user = self .eric ).count (), 0 )
415
+
416
+ @patch ('readthedocs.oauth.services.gitlab.GitLabService.send_build_status' )
417
+ def test_send_build_status_with_social_account_gitlab (self , send_build_status ):
418
+ social_account = get (SocialAccount , user = self .eric , provider = 'gitlab' )
419
+
420
+ self .project .repo = 'https://gitlab.com/test/test/'
421
+ self .project .save ()
422
+
423
+ external_version = get (Version , project = self .project , type = EXTERNAL )
424
+ external_build = get (
425
+ Build , project = self .project , version = external_version
426
+ )
427
+ tasks .send_build_status (
428
+ external_build .id , external_build .commit , BUILD_STATUS_SUCCESS
429
+ )
430
+
431
+ send_build_status .assert_called_once_with (
432
+ external_build , external_build .commit , BUILD_STATUS_SUCCESS
433
+ )
434
+ self .assertEqual (Message .objects .filter (user = self .eric ).count (), 0 )
435
+
436
+ @patch ('readthedocs.oauth.services.gitlab.GitLabService.send_build_status' )
437
+ def test_send_build_status_no_remote_repo_or_social_account_gitlab (self , send_build_status ):
438
+ self .project .repo = 'https://gitlab.com/test/test/'
439
+ self .project .save ()
440
+ external_version = get (Version , project = self .project , type = EXTERNAL )
441
+ external_build = get (
442
+ Build , project = self .project , version = external_version
443
+ )
444
+ tasks .send_build_status (
445
+ external_build .id , external_build .commit , BUILD_STATUS_SUCCESS
446
+ )
447
+
448
+ send_build_status .assert_not_called ()
449
+ self .assertEqual (Message .objects .filter (user = self .eric ).count (), 1 )
0 commit comments