forked from communitybridge/easycla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[communitybridge#3884] Feature/PR Co-authors
- Handled use case for getting co-author info in a given commit Signed-off-by: Harold Wanyama <hwanyama@contractor.linuxfoundation.org>
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright The Linux Foundation and each contributor to CommunityBridge. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from cla.utils import get_co_authors_from_commit | ||
|
||
FAKE_COMMIT = { | ||
"commit": { | ||
"author": { | ||
"name": "Harold Wanyama", | ||
"email": "hwanyama@contractor.linuxfoundation.org", | ||
"date": "2023-04-12T02:10:24Z", | ||
}, | ||
"committer": { | ||
"name": "Harold Wanyama", | ||
"email": "hwanyama@contractor.linuxfoundation.org", | ||
"date": "2023-04-12T02:10:24Z", | ||
}, | ||
"message": "Test 2\n\nCo-authored-by: Harold <wanyaland@gmail.com>", | ||
"tree": { | ||
"sha": "9db529464eac36c3e8825cd1c15cdaa571168d0a", | ||
"url": "https://api.github.com/repos/nabzo-bella/repo1/git/trees/9db529464eac36c3e8825cd1c15cdaa571168d0a", | ||
}, | ||
} | ||
} | ||
|
||
def test_get_commit_co_authors(): | ||
"""Test get commit co authors""" | ||
commit = FAKE_COMMIT | ||
co_authors = get_co_authors_from_commit(commit) | ||
assert co_authors == [('Harold', 'wanyaland@gmail.com')] | ||
for author in co_authors: | ||
assert isinstance(author, tuple) | ||
assert len(author) == 2 | ||
assert author[0] == 'Harold' | ||
assert author[1] == 'wanyaland@gmail.com' | ||
|
||
def test_get_co_author_no_name(): | ||
"""Test get commit co authors""" | ||
commit = FAKE_COMMIT | ||
commit['commit']['message'] = "Test 2\n\nCo-authored-by: <wanyaland@gmail.com" | ||
co_authors = get_co_authors_from_commit(commit) | ||
assert len(co_authors) == 0 |
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