diff --git a/config.py b/config.py index 050b1c36..eba87065 100644 --- a/config.py +++ b/config.py @@ -55,6 +55,6 @@ def get_env_var(name: str) -> str: USER_ID = -1 INSTALLATION_ID = -1 OWNER_NAME = "installation-test" -OWNER_TYPE = "O" +OWNER_TYPE = "Organization" USER_NAME = "username-test" UNIQUE_ISSUE_ID = "O/gitautoai/test#1" diff --git a/services/gitauto_handler.py b/services/gitauto_handler.py index 0f1e21c4..c33cf85f 100644 --- a/services/gitauto_handler.py +++ b/services/gitauto_handler.py @@ -50,7 +50,7 @@ async def handle_gitauto(payload: GitHubLabeledPayload, trigger_type: str) -> No issue_number: int = issue["number"] installation_id: int = payload["installation"]["id"] repo: RepositoryInfo = payload["repository"] - owner_type = payload["repository"]["owner"]["type"][0] + owner_type = payload["repository"]["owner"]["type"] owner: str = repo["owner"]["login"] owner_id: int = repo["owner"]["id"] repo_name: str = repo["name"] diff --git a/services/webhook_handler.py b/services/webhook_handler.py index 4141897f..5bab5b20 100644 --- a/services/webhook_handler.py +++ b/services/webhook_handler.py @@ -27,7 +27,7 @@ async def handle_installation_created(payload: GitHubInstallationPayload) -> None: """Creates installation records on GitAuto APP installation""" installation_id: int = payload["installation"]["id"] - owner_type: str = payload["installation"]["account"]["type"][0] + owner_type: str = payload["installation"]["account"]["type"] owner_name: str = payload["installation"]["account"]["login"] owner_id: int = payload["installation"]["account"]["id"] user_id: int = payload["sender"]["id"] @@ -111,6 +111,6 @@ async def handle_webhook_event(event_name: str, payload: GitHubEventPayload) -> if not match: return issue_number = match.group(1) - owner_type = payload["repository"]["owner"]["type"][0] + owner_type = payload["repository"]["owner"]["type"] unique_issue_id = f"{owner_type}/{payload['repository']['owner']['login']}/{payload['repository']['name']}#{issue_number}" supabase_manager.set_issue_to_merged(unique_issue_id=unique_issue_id) diff --git a/tests/services/supabase/test_gitauto_manager.py b/tests/services/supabase/test_gitauto_manager.py index bf34b941..02f58ae2 100644 --- a/tests/services/supabase/test_gitauto_manager.py +++ b/tests/services/supabase/test_gitauto_manager.py @@ -1,6 +1,6 @@ # run this file locally with: python -m tests.services.supabase.test_gitauto_manager import os - +from config import OWNER_TYPE from services.supabase import SupabaseManager SUPABASE_SERVICE_ROLE_KEY = os.getenv("SUPABASE_SERVICE_ROLE_KEY") @@ -40,7 +40,7 @@ def test_create_update_user_request_works() -> None: # insert data into the db -> create installation supabase_manager.create_installation( installation_id=installation_id, - owner_type="O", + owner_type=OWNER_TYPE, owner_name="gitautoai", owner_id=-1, user_id=user_id, @@ -87,7 +87,7 @@ def test_complete_and_update_usage_record_only_updates_one_record() -> None: # insert data into the db -> create installation supabase_manager.create_installation( installation_id=installation_id, - owner_type="O", + owner_type=OWNER_TYPE, owner_name="gitautoai", owner_id=-1, user_id=user_id,