Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Co Auth disabled #4332

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cla-backend/cla/models/github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,12 +1388,12 @@ def get_author_summary(commit, pr, installation_id) -> List[UserCommitSummary]:
# check for co-author details
# issue # 3884
commit_authors.append(commit_author_summary)
co_authors = cla.utils.get_co_authors_from_commit(commit)
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
for co_author in co_authors:
commit_authors.append(
executor.submit(get_co_author_commits, co_author, commit, pr, installation_id).result()
)
# co_authors = cla.utils.get_co_authors_from_commit(commit)
# with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
# for co_author in co_authors:
# commit_authors.append(
# executor.submit(get_co_author_commits, co_author, commit, pr, installation_id).result()
# )

return commit_authors
except (GithubException, IncompletableObject) as exc:
Expand Down
62 changes: 31 additions & 31 deletions cla-backend/cla/tests/unit/test_github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "fake_author@example.com"
pull_request.get_commits.return_value.__iter__.return_value = [commit]
# commit.author.email = "fake_author@example.com"
# 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):
Expand Down
Loading