Skip to content

Commit

Permalink
test: add integration tests (box/box-codegen#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed Sep 5, 2024
1 parent f518c54 commit d2729ab
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "2994c4a", "specHash": "6ca858e", "version": "1.4.1" }
{ "engineHash": "66f851a", "specHash": "6ca858e", "version": "1.4.1" }
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }}
APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }}
APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }}
WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }}
run: |
tox
Expand Down Expand Up @@ -73,3 +75,5 @@ jobs:
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }}
WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }}
APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }}
APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Now select `Authorization` and submit application to be reviewed by account admi
3. Set environment variable: `JWT_CONFIG_BASE_64` with base64 encoded jwt configuration file
4. Set environment variable: `BOX_FILE_REQUEST_ID` with ID of file request already created in the user account, `BOX_EXTERNAL_USER_EMAIL` with email of free external user which not belongs to any enterprise.
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.

### Running tests

Expand Down
12 changes: 10 additions & 2 deletions docs/app_item_associations.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ This operation is performed by calling function `get_file_app_item_associations`
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-files-id-app-item-associations/).

_Currently we don't have an example for calling `get_file_app_item_associations` in integration tests_
<!-- sample get_files_id_app_item_associations -->

```python
client.app_item_associations.get_file_app_item_associations(file_id)
```

### Arguments

Expand Down Expand Up @@ -52,7 +56,11 @@ This operation is performed by calling function `get_folder_app_item_association
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-folders-id-app-item-associations/).

_Currently we don't have an example for calling `get_folder_app_item_associations` in integration tests_
<!-- sample get_folders_id_app_item_associations -->

```python
client.app_item_associations.get_folder_app_item_associations(folder_id)
```

### Arguments

Expand Down
2 changes: 1 addition & 1 deletion docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ See the endpoint docs at
<!-- sample get_files_id -->

```python
client.files.get_file_by_id(file.id)
client.files.get_file_by_id(file_id, fields=["is_associated_with_app_item"])
```

### Arguments
Expand Down
2 changes: 1 addition & 1 deletion docs/folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See the endpoint docs at
<!-- sample get_folders_id -->

```python
client.folders.get_folder_by_id(new_folder.id)
client.folders.get_folder_by_id(folder_id, fields=["is_associated_with_app_item"])
```

### Arguments
Expand Down
55 changes: 55 additions & 0 deletions test/app_item_associations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from box_sdk_gen.internal.utils import to_string

from box_sdk_gen.client import BoxClient

from box_sdk_gen.schemas.app_item_associations import AppItemAssociations

from box_sdk_gen.schemas.app_item_association import AppItemAssociation

from box_sdk_gen.schemas.file_full import FileFull

from box_sdk_gen.schemas.folder_full import FolderFull

from box_sdk_gen.internal.utils import get_uuid

from box_sdk_gen.internal.utils import get_env_var

from test.commons import get_default_client_with_user_subject


def testListFileAppItemAssocations():
client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID'))
file_id: str = get_env_var('APP_ITEM_ASSOCIATION_FILE_ID')
file_app_item_associations: AppItemAssociations = (
client.app_item_associations.get_file_app_item_associations(file_id)
)
assert len(file_app_item_associations.entries) == 1
association: AppItemAssociation = file_app_item_associations.entries[0]
assert not association.id == ''
assert to_string(association.app_item.application_type) == 'hubs'
assert to_string(association.app_item.type) == 'app_item'
assert to_string(association.item.type) == 'file'
assert association.item.id == file_id
file: FileFull = client.files.get_file_by_id(
file_id, fields=['is_associated_with_app_item']
)
assert file.is_associated_with_app_item == True


def testListFolderAppItemAssocations():
client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID'))
folder_id: str = get_env_var('APP_ITEM_ASSOCIATION_FOLDER_ID')
folder_app_item_associations: AppItemAssociations = (
client.app_item_associations.get_folder_app_item_associations(folder_id)
)
assert len(folder_app_item_associations.entries) == 1
association: AppItemAssociation = folder_app_item_associations.entries[0]
assert not association.id == ''
assert to_string(association.app_item.application_type) == 'hubs'
assert to_string(association.app_item.type) == 'app_item'
assert to_string(association.item.type) == 'folder'
assert association.item.id == folder_id
folder: FolderFull = client.folders.get_folder_by_id(
folder_id, fields=['is_associated_with_app_item']
)
assert folder.is_associated_with_app_item == True
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ commands =
pytest {posargs} --disable-pytest-warnings
deps = -rrequirements-test.txt
allowlist_externals = pytest
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID

[testenv:pycodestyle]
commands =
Expand All @@ -45,7 +45,7 @@ commands =
deps =
coverage
-rrequirements-test.txt
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID

[testenv:py310-build]
description = Build the source and binary wheel packages for distribution.
Expand Down

0 comments on commit d2729ab

Please sign in to comment.