-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add function to get specific app's details
Adds `get_specific_github_app_details` function to bots service. This allows us to get `GithubInstallationInfo` for the app we want. It fails with a new exception if the app can't be found. This is because this feature will be used to get the app that made a comment or status check. If we don't use the same to edit said comment it won't work. On top of that we need to start saving the ID of the apps we selected for Torngit adapter instances
- Loading branch information
1 parent
2492b5e
commit 6b8670d
Showing
9 changed files
with
154 additions
and
12 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
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
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,51 @@ | ||
import pytest | ||
from shared.typings.torngit import GithubInstallationInfo | ||
|
||
from database.models.core import GithubAppInstallation | ||
from database.tests.factories.core import OwnerFactory | ||
from helpers.exceptions import RequestedGithubAppNotFound | ||
from services.bots.github_apps import get_specific_github_app_details | ||
|
||
|
||
class TestGetSpecificGithubAppDetails(object): | ||
def _get_owner_with_apps(self, dbsession): | ||
owner = OwnerFactory(service="github") | ||
app_1 = GithubAppInstallation( | ||
owner=owner, | ||
installation_id=1200, | ||
app_id=12, | ||
) | ||
app_2 = GithubAppInstallation( | ||
owner=owner, | ||
installation_id=1500, | ||
app_id=15, | ||
pem_path="some_path", | ||
) | ||
dbsession.add_all([owner, app_1, app_2]) | ||
dbsession.flush() | ||
assert owner.github_app_installations == [app_1, app_2] | ||
return owner | ||
|
||
def test_get_specific_github_app_details(self, dbsession): | ||
owner = self._get_owner_with_apps(dbsession) | ||
assert get_specific_github_app_details( | ||
owner, owner.github_app_installations[0].id, "commit_id_for_logs" | ||
) == GithubInstallationInfo( | ||
id=owner.github_app_installations[0].id, | ||
installation_id=1200, | ||
app_id=12, | ||
pem_path=None, | ||
) | ||
assert get_specific_github_app_details( | ||
owner, owner.github_app_installations[1].id, "commit_id_for_logs" | ||
) == GithubInstallationInfo( | ||
id=owner.github_app_installations[1].id, | ||
installation_id=1500, | ||
app_id=15, | ||
pem_path="some_path", | ||
) | ||
|
||
def test_get_specific_github_app_not_found(self, dbsession): | ||
owner = self._get_owner_with_apps(dbsession) | ||
with pytest.raises(RequestedGithubAppNotFound): | ||
get_specific_github_app_details(owner, 123456, "commit_id_for_logs") |
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