-
-
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.
fix(ai-autofix): Accept git repo provider format from sentry (#272)
Sentry side repo providers come in the format integrations:github etc Fixes TIMESERIES-ANALYSIS-SERVICE-2N
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
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
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,45 @@ | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
from seer.automation.codebase.repo_client import RepoClient | ||
from seer.automation.models import InitializationError | ||
|
||
|
||
class TestRepoClient(unittest.TestCase): | ||
@patch("seer.automation.codebase.repo_client.Github") | ||
@patch("seer.automation.codebase.repo_client.get_github_auth") | ||
def test_repo_client_accepts_github_provider(self, mock_get_github_auth, mock_github): | ||
# Mocking Github class and get_github_auth function to simulate GitHub API responses and authentication | ||
mock_github_instance = mock_github.return_value | ||
mock_github_instance.get_repo.return_value.default_branch = "main" | ||
mock_get_github_auth.return_value = ( | ||
None # Assuming get_github_auth returns None for simplicity | ||
) | ||
client = RepoClient(repo_provider="github", repo_owner="test_owner", repo_name="test_repo") | ||
self.assertEqual(client.provider, "github") | ||
|
||
@patch("seer.automation.codebase.repo_client.Github") | ||
@patch("seer.automation.codebase.repo_client.get_github_auth") | ||
def test_repo_client_accepts_integrations_github_provider( | ||
self, mock_get_github_auth, mock_github | ||
): | ||
# Mocking Github class and get_github_auth function to simulate GitHub API responses and authentication | ||
mock_github_instance = mock_github.return_value | ||
mock_github_instance.get_repo.return_value.default_branch = "main" | ||
mock_get_github_auth.return_value = ( | ||
None # Assuming get_github_auth returns None for simplicity | ||
) | ||
client = RepoClient( | ||
repo_provider="integrations:github", repo_owner="test_owner", repo_name="test_repo" | ||
) | ||
self.assertEqual(client.provider, "github") | ||
|
||
@patch("seer.automation.codebase.repo_client.get_github_auth") | ||
def test_repo_client_rejects_unsupported_provider(self, mock_get_github_auth): | ||
mock_get_github_auth.return_value = ( | ||
None # Assuming get_github_auth returns None for simplicity | ||
) | ||
with self.assertRaises(InitializationError): | ||
RepoClient( | ||
repo_provider="unsupported_provider", repo_owner="test_owner", repo_name="test_repo" | ||
) |