Skip to content

Commit b074eda

Browse files
committed
update
1 parent ab93218 commit b074eda

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

gittensor/utils/github_api_tools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ def get_github_identity(token: str) -> GitHubIdentityResult:
165165
return GitHubIdentityResult(None, GitHubIdentityStatus.TRANSIENT_FAILURE)
166166

167167

168+
def get_github_id(token: str) -> Optional[str]:
169+
"""Get GitHub numeric user id (as string) using a PAT."""
170+
return get_github_identity(token).github_id
171+
172+
168173
def get_merge_base_sha(repository: str, base_sha: str, head_sha: str, token: str) -> Optional[str]:
169174
"""
170175
Get the merge-base commit SHA between two refs using GitHub's compare API.

tests/utils/test_github_api_tools.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626

2727
get_github_identity = github_api_tools.get_github_identity
28+
get_github_id = github_api_tools.get_github_id
2829
get_pull_request_file_changes = github_api_tools.get_pull_request_file_changes
2930
get_merge_base_sha = github_api_tools.get_merge_base_sha
3031
find_prs_for_issue = github_api_tools.find_prs_for_issue
@@ -35,6 +36,17 @@
3536
class TestOtherGitHubAPIFunctions:
3637
"""Test suite for other GitHub API functions with existing retry logic."""
3738

39+
@patch('gittensor.utils.github_api_tools.get_github_identity')
40+
def test_get_github_id_wrapper(self, mock_get_identity):
41+
mock_get_identity.return_value = github_api_tools.GitHubIdentityResult(
42+
'12345', github_api_tools.GitHubIdentityStatus.VALID
43+
)
44+
45+
result = get_github_id('fake_token')
46+
47+
assert result == '12345'
48+
mock_get_identity.assert_called_once_with('fake_token')
49+
3850
@patch('gittensor.utils.github_api_tools.requests.get')
3951
@patch('gittensor.utils.github_api_tools.time.sleep')
4052
@patch('gittensor.utils.github_api_tools.bt.logging')

0 commit comments

Comments
 (0)