-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4332 from nickmango/feature/disable-co-auth
Feature/Co Auth disabled
- Loading branch information
Showing
2 changed files
with
37 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,42 +11,42 @@ | |
|
||
|
||
class TestGetPullRequestCommitAuthors(TestCase): | ||
@patch("cla.utils.get_repository_service") | ||
def test_get_pull_request_commit_with_co_author(self, mock_github_instance): | ||
# Mock data | ||
pull_request = MagicMock() | ||
pull_request.number = 123 | ||
co_author = "co_author" | ||
co_author_email = "co_author_email.gmail.com" | ||
co_author_2 = "co_author_2" | ||
co_author_email_2 = "co_author_email_2.gmail.com" | ||
commit = MagicMock() | ||
commit.sha = "fake_sha" | ||
commit.author = MagicMock() | ||
commit.author.id = 1 | ||
commit.author.login = "fake_login" | ||
commit.author.name = "Fake Author" | ||
commit.commit.message = f"fake message\n\nCo-authored-by: {co_author} <{co_author_email}>\n\nCo-authored-by: {co_author_2} <{co_author_email_2}>" | ||
# @patch("cla.utils.get_repository_service") | ||
# def test_get_pull_request_commit_with_co_author(self, mock_github_instance): | ||
# # Mock data | ||
# pull_request = MagicMock() | ||
# pull_request.number = 123 | ||
# co_author = "co_author" | ||
# co_author_email = "co_author_email.gmail.com" | ||
# co_author_2 = "co_author_2" | ||
# co_author_email_2 = "co_author_email_2.gmail.com" | ||
# commit = MagicMock() | ||
# commit.sha = "fake_sha" | ||
# commit.author = MagicMock() | ||
# commit.author.id = 1 | ||
# commit.author.login = "fake_login" | ||
# commit.author.name = "Fake Author" | ||
# commit.commit.message = f"fake message\n\nCo-authored-by: {co_author} <{co_author_email}>\n\nCo-authored-by: {co_author_2} <{co_author_email_2}>" | ||
|
||
commit.author.email = "[email protected]" | ||
pull_request.get_commits.return_value.__iter__.return_value = [commit] | ||
# commit.author.email = "[email protected]" | ||
# pull_request.get_commits.return_value.__iter__.return_value = [commit] | ||
|
||
mock_user = Mock(id=2, login="co_author_login") | ||
mock_user_2 = Mock(id=3, login="co_author_login_2") | ||
# mock_user = Mock(id=2, login="co_author_login") | ||
# mock_user_2 = Mock(id=3, login="co_author_login_2") | ||
|
||
mock_github_instance.return_value.get_github_user_by_email.side_effect = ( | ||
lambda email, _: mock_user if email == co_author_email else mock_user_2 | ||
) | ||
# mock_github_instance.return_value.get_github_user_by_email.side_effect = ( | ||
# lambda email, _: mock_user if email == co_author_email else mock_user_2 | ||
# ) | ||
|
||
# Call the function | ||
result = get_pull_request_commit_authors(pull_request, "fake_installation_id") | ||
# # Call the function | ||
# result = get_pull_request_commit_authors(pull_request, "fake_installation_id") | ||
|
||
# Assertions | ||
self.assertEqual(len(result), 3) | ||
self.assertIn(co_author_email, [author.author_email for author in result]) | ||
self.assertIn(co_author_email_2, [author.author_email for author in result]) | ||
self.assertIn("fake_login", [author.author_login for author in result]) | ||
self.assertIn("co_author_login", [author.author_login for author in result]) | ||
# # Assertions | ||
# self.assertEqual(len(result), 3) | ||
# self.assertIn(co_author_email, [author.author_email for author in result]) | ||
# self.assertIn(co_author_email_2, [author.author_email for author in result]) | ||
# self.assertIn("fake_login", [author.author_login for author in result]) | ||
# self.assertIn("co_author_login", [author.author_login for author in result]) | ||
|
||
@patch("cla.utils.get_repository_service") | ||
def test_get_co_author_commits_invalid_gh_email(self, mock_github_instance): | ||
|