From 5358e1af2caada6fa4171162963fcd34694cf723 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 17 Apr 2025 09:38:56 -0700 Subject: [PATCH 1/3] chore: Update .codegen.json with commit hash of codegen and openapi spec --- .codegen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codegen.json b/.codegen.json index e1b02a9..3c304dd 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "0e509a3", "specHash": "f737b7b", "version": "1.13.0" } +{ "engineHash": "17a66fe", "specHash": "f737b7b", "version": "1.13.0" } From 39ceb8a7c42e6c6f7df101aa94949c5c03ae8e3e Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Tue, 22 Apr 2025 07:17:26 -0700 Subject: [PATCH 2/3] test: Improve `Slack` integration mapping test (box/box-codegen#710) --- .codegen.json | 2 +- .github/workflows/build.yml | 6 +++ README.md | 1 + docs/integration_mappings.md | 8 ++-- test/integration_mappings.py | 75 ++++++++++++++++++++++++++++-------- 5 files changed, 71 insertions(+), 21 deletions(-) diff --git a/.codegen.json b/.codegen.json index 3c304dd..80398b5 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "17a66fe", "specHash": "f737b7b", "version": "1.13.0" } +{ "engineHash": "90eaba8", "specHash": "f737b7b", "version": "1.13.0" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e4f550..375ecb1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,9 @@ jobs: APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }} WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }} APP_ITEM_SHARED_LINK: ${{ secrets.APP_ITEM_SHARED_LINK }} + SLACK_AUTOMATION_USER_ID: ${{ secrets.SLACK_AUTOMATION_USER_ID }} + SLACK_ORG_ID: ${{ secrets.SLACK_ORG_ID }} + SLACK_PARTNER_ITEM_ID: ${{ secrets.SLACK_PARTNER_ITEM_ID }} run: | tox @@ -80,3 +83,6 @@ jobs: APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }} APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }} APP_ITEM_SHARED_LINK: ${{ secrets.APP_ITEM_SHARED_LINK }} + SLACK_AUTOMATION_USER_ID: ${{ secrets.SLACK_AUTOMATION_USER_ID }} + SLACK_ORG_ID: ${{ secrets.SLACK_ORG_ID }} + SLACK_PARTNER_ITEM_ID: ${{ secrets.SLACK_PARTNER_ITEM_ID }} diff --git a/README.md b/README.md index 41cfa98..16aab67 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ Now select `Authorization` and submit application to be reviewed by account admi 5. Set environment variable: `WORKFLOW_FOLDER_ID` with the ID of the Relay workflow that deletes the file that triggered the workflow. The workflow should have a manual start to be able to start it from the API. 6. Set environment variable: `APP_ITEM_ASSOCIATION_FILE_ID` to the ID of the file with associated app item and `APP_ITEM_ASSOCIATION_FOLDER_ID` to the ID of the folder with associated app item. 7. Set environment variable: `APP_ITEM_SHARED_LINK` to the shared link associated with app item. +8. Set environment variable: `SLACK_AUTOMATION_USER_ID` to the ID of the user responsible for the Slack automation, `SLACK_ORG_ID` to the ID of the Slack organization and `SLACK_PARTNER_ITEM_ID` to the ID of the Slack partner item. ### Running tests diff --git a/docs/integration_mappings.md b/docs/integration_mappings.md index 00f600c..793eee0 100644 --- a/docs/integration_mappings.md +++ b/docs/integration_mappings.md @@ -69,7 +69,9 @@ See the endpoint docs at ```python user_client.integration_mappings.create_slack_integration_mapping( - IntegrationMappingPartnerItemSlack(id=partner_item_id, slack_org_id=slack_org_id), + IntegrationMappingPartnerItemSlack( + id=slack_partner_item_id, slack_org_id=slack_org_id + ), IntegrationMappingBoxItemSlack(id=folder.id), ) ``` @@ -108,7 +110,7 @@ See the endpoint docs at ```python user_client.integration_mappings.update_slack_integration_mapping_by_id( - integration_mapping_id, box_item=IntegrationMappingBoxItemSlack(id="1234567") + slack_integration_mapping.id, box_item=IntegrationMappingBoxItemSlack(id=folder.id) ) ``` @@ -145,7 +147,7 @@ See the endpoint docs at ```python user_client.integration_mappings.delete_slack_integration_mapping_by_id( - integration_mapping_id + slack_integration_mapping.id ) ``` diff --git a/test/integration_mappings.py b/test/integration_mappings.py index 8c111ff..a7d938c 100644 --- a/test/integration_mappings.py +++ b/test/integration_mappings.py @@ -1,3 +1,5 @@ +from box_sdk_gen.internal.utils import to_string + import pytest from box_sdk_gen.client import BoxClient @@ -6,6 +8,20 @@ from box_sdk_gen.managers.folders import CreateFolderParent +from box_sdk_gen.managers.user_collaborations import CreateCollaborationItem + +from box_sdk_gen.managers.user_collaborations import CreateCollaborationItemTypeField + +from box_sdk_gen.managers.user_collaborations import CreateCollaborationAccessibleBy + +from box_sdk_gen.managers.user_collaborations import ( + CreateCollaborationAccessibleByTypeField, +) + +from box_sdk_gen.managers.user_collaborations import CreateCollaborationRole + +from box_sdk_gen.schemas.integration_mappings import IntegrationMappings + from box_sdk_gen.schemas.integration_mapping_partner_item_slack import ( IntegrationMappingPartnerItemSlack, ) @@ -14,7 +30,7 @@ IntegrationMappingBoxItemSlack, ) -from box_sdk_gen.schemas.integration_mappings import IntegrationMappings +from box_sdk_gen.schemas.integration_mapping import IntegrationMapping from box_sdk_gen.schemas.integration_mapping_partner_item_teams_create_request import ( IntegrationMappingPartnerItemTeamsCreateRequest, @@ -32,6 +48,8 @@ from box_sdk_gen.internal.utils import get_env_var +from box_sdk_gen.internal.utils import to_string + from test.commons import get_default_client from test.commons import get_default_client_with_user_subject @@ -40,35 +58,58 @@ def testSlackIntegrationMappings(): - folder: FolderFull = client.folders.create_folder( - get_uuid(), CreateFolderParent(id='0') - ) - slack_org_id: str = '1' - partner_item_id: str = '1' user_id: str = get_env_var('USER_ID') + slack_automation_user_id: str = get_env_var('SLACK_AUTOMATION_USER_ID') + slack_org_id: str = get_env_var('SLACK_ORG_ID') + slack_partner_item_id: str = get_env_var('SLACK_PARTNER_ITEM_ID') user_client: BoxClient = get_default_client_with_user_subject(user_id) - with pytest.raises(Exception): + folder: FolderFull = user_client.folders.create_folder( + get_uuid(), CreateFolderParent(id='0') + ) + user_client.user_collaborations.create_collaboration( + CreateCollaborationItem( + type=CreateCollaborationItemTypeField.FOLDER, id=folder.id + ), + CreateCollaborationAccessibleBy( + type=CreateCollaborationAccessibleByTypeField.USER, + id=slack_automation_user_id, + ), + CreateCollaborationRole.CO_OWNER, + ) + slack_integrations: IntegrationMappings = ( + user_client.integration_mappings.get_slack_integration_mapping() + ) + if len(slack_integrations.entries) == 0: user_client.integration_mappings.create_slack_integration_mapping( IntegrationMappingPartnerItemSlack( - id=partner_item_id, slack_org_id=slack_org_id + id=slack_partner_item_id, slack_org_id=slack_org_id ), IntegrationMappingBoxItemSlack(id=folder.id), ) - integration_mappings: IntegrationMappings = ( + slack_mappings: IntegrationMappings = ( user_client.integration_mappings.get_slack_integration_mapping() ) - assert len(integration_mappings.entries) == 0 - integration_mapping_id: str = '123456' - with pytest.raises(Exception): + assert len(slack_mappings.entries) >= 1 + slack_integration_mapping: IntegrationMapping = slack_mappings.entries[0] + assert to_string(slack_integration_mapping.integration_type) == 'slack' + assert to_string(slack_integration_mapping.type) == 'integration_mapping' + assert to_string(slack_integration_mapping.box_item.type) == 'folder' + assert slack_integration_mapping.partner_item.id == slack_partner_item_id + assert slack_integration_mapping.partner_item.slack_workspace_id == slack_org_id + assert to_string(slack_integration_mapping.partner_item.type) == 'channel' + updated_slack_mapping: IntegrationMapping = ( user_client.integration_mappings.update_slack_integration_mapping_by_id( - integration_mapping_id, - box_item=IntegrationMappingBoxItemSlack(id='1234567'), + slack_integration_mapping.id, + box_item=IntegrationMappingBoxItemSlack(id=folder.id), ) - with pytest.raises(Exception): + ) + assert to_string(updated_slack_mapping.box_item.type) == 'folder' + assert updated_slack_mapping.box_item.id == folder.id + if len(slack_mappings.entries) > 2: user_client.integration_mappings.delete_slack_integration_mapping_by_id( - integration_mapping_id + slack_integration_mapping.id ) - client.folders.delete_folder_by_id(folder.id) + user_client.folders.delete_folder_by_id(folder.id) def testTeamsIntegrationMappings(): From b68d1e713190c4b1fb6809488c0cbb4675e740bc Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 23 Apr 2025 07:43:28 -0700 Subject: [PATCH 3/3] chore: Fix `GitHub` actions and integration tests (box/box-codegen#712) --- .codegen.json | 2 +- .github/workflows/build.yml | 12 ++++++------ .github/workflows/spell-check-lint.yml | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.codegen.json b/.codegen.json index 80398b5..068f6fa 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "90eaba8", "specHash": "f737b7b", "version": "1.13.0" } +{ "engineHash": "5f0371b", "specHash": "f737b7b", "version": "1.13.0" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 375ecb1..a419259 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: max-parallel: 1 matrix: @@ -20,9 +20,9 @@ jobs: name: Build with Python ${{ matrix.python-version }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -52,12 +52,12 @@ jobs: coverage: name: Coverage report - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install dependencies diff --git a/.github/workflows/spell-check-lint.yml b/.github/workflows/spell-check-lint.yml index fe371f1..659bbd3 100644 --- a/.github/workflows/spell-check-lint.yml +++ b/.github/workflows/spell-check-lint.yml @@ -9,9 +9,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout current repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout spellchecker - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: refs/heads/main repository: box/box-sdk-spellchecker