Skip to content

chore: Fix GitHub actions and integration tests (box/box-codegen#712) #550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "0e509a3", "specHash": "f737b7b", "version": "1.13.0" }
{ "engineHash": "5f0371b", "specHash": "f737b7b", "version": "1.13.0" }
18 changes: 12 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
Expand All @@ -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
Expand All @@ -44,17 +44,20 @@ 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

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
Expand All @@ -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 }}
4 changes: 2 additions & 2 deletions .github/workflows/spell-check-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions docs/integration_mappings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
```
Expand Down Expand Up @@ -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)
)
```

Expand Down Expand Up @@ -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
)
```

Expand Down
75 changes: 58 additions & 17 deletions test/integration_mappings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from box_sdk_gen.internal.utils import to_string

import pytest

from box_sdk_gen.client import BoxClient
Expand All @@ -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,
)
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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():
Expand Down
Loading