Skip to content

Commit d2729ab

Browse files
committed
test: add integration tests (box/box-codegen#561)
1 parent f518c54 commit d2729ab

File tree

8 files changed

+75
-7
lines changed

8 files changed

+75
-7
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "2994c4a", "specHash": "6ca858e", "version": "1.4.1" }
1+
{ "engineHash": "66f851a", "specHash": "6ca858e", "version": "1.4.1" }

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
4040
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
4141
BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }}
42+
APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }}
43+
APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }}
4244
WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }}
4345
run: |
4446
tox
@@ -73,3 +75,5 @@ jobs:
7375
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
7476
BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }}
7577
WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }}
78+
APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }}
79+
APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Now select `Authorization` and submit application to be reviewed by account admi
113113
3. Set environment variable: `JWT_CONFIG_BASE_64` with base64 encoded jwt configuration file
114114
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.
115115
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.
116+
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.
116117

117118
### Running tests
118119

docs/app_item_associations.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ This operation is performed by calling function `get_file_app_item_associations`
1616
See the endpoint docs at
1717
[API Reference](https://developer.box.com/reference/get-files-id-app-item-associations/).
1818

19-
_Currently we don't have an example for calling `get_file_app_item_associations` in integration tests_
19+
<!-- sample get_files_id_app_item_associations -->
20+
21+
```python
22+
client.app_item_associations.get_file_app_item_associations(file_id)
23+
```
2024

2125
### Arguments
2226

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

55-
_Currently we don't have an example for calling `get_folder_app_item_associations` in integration tests_
59+
<!-- sample get_folders_id_app_item_associations -->
60+
61+
```python
62+
client.app_item_associations.get_folder_app_item_associations(folder_id)
63+
```
5664

5765
### Arguments
5866

docs/files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ See the endpoint docs at
1818
<!-- sample get_files_id -->
1919

2020
```python
21-
client.files.get_file_by_id(file.id)
21+
client.files.get_file_by_id(file_id, fields=["is_associated_with_app_item"])
2222
```
2323

2424
### Arguments

docs/folders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ See the endpoint docs at
2828
<!-- sample get_folders_id -->
2929

3030
```python
31-
client.folders.get_folder_by_id(new_folder.id)
31+
client.folders.get_folder_by_id(folder_id, fields=["is_associated_with_app_item"])
3232
```
3333

3434
### Arguments

test/app_item_associations.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from box_sdk_gen.internal.utils import to_string
2+
3+
from box_sdk_gen.client import BoxClient
4+
5+
from box_sdk_gen.schemas.app_item_associations import AppItemAssociations
6+
7+
from box_sdk_gen.schemas.app_item_association import AppItemAssociation
8+
9+
from box_sdk_gen.schemas.file_full import FileFull
10+
11+
from box_sdk_gen.schemas.folder_full import FolderFull
12+
13+
from box_sdk_gen.internal.utils import get_uuid
14+
15+
from box_sdk_gen.internal.utils import get_env_var
16+
17+
from test.commons import get_default_client_with_user_subject
18+
19+
20+
def testListFileAppItemAssocations():
21+
client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID'))
22+
file_id: str = get_env_var('APP_ITEM_ASSOCIATION_FILE_ID')
23+
file_app_item_associations: AppItemAssociations = (
24+
client.app_item_associations.get_file_app_item_associations(file_id)
25+
)
26+
assert len(file_app_item_associations.entries) == 1
27+
association: AppItemAssociation = file_app_item_associations.entries[0]
28+
assert not association.id == ''
29+
assert to_string(association.app_item.application_type) == 'hubs'
30+
assert to_string(association.app_item.type) == 'app_item'
31+
assert to_string(association.item.type) == 'file'
32+
assert association.item.id == file_id
33+
file: FileFull = client.files.get_file_by_id(
34+
file_id, fields=['is_associated_with_app_item']
35+
)
36+
assert file.is_associated_with_app_item == True
37+
38+
39+
def testListFolderAppItemAssocations():
40+
client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID'))
41+
folder_id: str = get_env_var('APP_ITEM_ASSOCIATION_FOLDER_ID')
42+
folder_app_item_associations: AppItemAssociations = (
43+
client.app_item_associations.get_folder_app_item_associations(folder_id)
44+
)
45+
assert len(folder_app_item_associations.entries) == 1
46+
association: AppItemAssociation = folder_app_item_associations.entries[0]
47+
assert not association.id == ''
48+
assert to_string(association.app_item.application_type) == 'hubs'
49+
assert to_string(association.app_item.type) == 'app_item'
50+
assert to_string(association.item.type) == 'folder'
51+
assert association.item.id == folder_id
52+
folder: FolderFull = client.folders.get_folder_by_id(
53+
folder_id, fields=['is_associated_with_app_item']
54+
)
55+
assert folder.is_associated_with_app_item == True

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ commands =
2020
pytest {posargs} --disable-pytest-warnings
2121
deps = -rrequirements-test.txt
2222
allowlist_externals = pytest
23-
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
23+
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
2424

2525
[testenv:pycodestyle]
2626
commands =
@@ -45,7 +45,7 @@ commands =
4545
deps =
4646
coverage
4747
-rrequirements-test.txt
48-
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
48+
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
4949

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

0 commit comments

Comments
 (0)